Raspberry Pi power control
Theo Markettos (89) 919 posts |
Looking in
This appears to be using the Videocore power management mailbox 0, which is undocumented, rather than the property interface mailbox 8. There’s an equivalent property message for SetPowerState (0×28001). Any particular reason it is implemented this way rather than using the official interface? |
Jeffrey Lee (213) 6048 posts |
That code has actually been there since the very beginning (albeit in a slightly different form). There’s a good chance that it predates the creation of the mailbox property interface. And since it still works, we haven’t had any reason to change it to use the newer interface. |
Chris Hall (132) 3554 posts |
I have implemented software power control for the Pi. I have used a method which is compatible with the Witty Pi (which removes power directly if GPIO 4 is taken low). During a reset GPIO 4 goes to a high impedance state. Prior to a reset GPIO 4=HIGH is used to suppress a power off request. A power off request (either from the ‘off’ pushbutton or from a low battery voltage state) causes GPIO 26 to be taken low. So .. if GPIO 26 is high then this indicates that a reset will leave power on, whereas if GPIO 26 is low then a reset will remove power as soon as the rom is reset. So my method does not offer a way to remove power directly unless a shutdown request (e.g. by push button) has already been made. So I can’t offer an option ‘remove power’ or ‘reset’ but it would be nice to alter the message that says ‘The computer is now ready to be switched off’ to make the option either ‘Power off’ or ‘Restart’ depending on the status of GPIO 26. Is there a way to do this? |
Theo Markettos (89) 919 posts |
Thanks Jeffrey. I might have a go at reworking it to use the mailbox property interface, to bring it into line with the rest. Obviously careful testing required! |
Stuart Swales (8827) 1357 posts |
Is there any chance of old RPis running RISC OS out there with firmware that doesn’t support the Videocore mailbox property interface? |
Theo Markettos (89) 919 posts |
ISTR it arriving some time in 2012. So they would have to be very old Pi 1s, which debuted February 2012. Since the firmware is on the SD card it’s simple to update at the same time as the ROM image – I don’t know what the position is for supporting ancient firmware? git blame says the documentation of the Set Power State property was last edited June 2012, so it’s been there for a long time. |
Jeffrey Lee (213) 6048 posts |
Not at the moment. However it should be relatively easy to add support for it – all it really needs is for someone to design & implement an API which the OS can use to talk to power control hardware.
Ancient firmware isn’t supported. I’m not sure exactly when the cutoff is – I know firmware from 2019 still works. |
Stuart Painting (5389) 714 posts |
January 2019 is about as far back as you can go. Any further back and you run into problems such as an inability to use 256-colour screen modes |