I have noticed an interesting artifact once I powered up Charlie with a boost-supply attached:
Note the following facts:
The boost supply on my robot powers up the entire robot as soon as the +12v supply is plugged in, (or an external battery is turned on), as it is wired across the +12v connector, and the +5v from the Raspberry Pi “back-feeds” the GoPiGo board, turning it on too.
After shutdown, and after the GoPiGo would have powered off the Raspberry Pi, the Pi is still energized, though not running.
Because the Raspberry Pi is still energized during shutdown, things can still happen even after the GoPiGo board thinks things are done.
The Raspberry Pi is programmed to send a signal, (or de-assert a signal), when the programming for that functionality believes the board has shut itself down.
This occurs using either GoPiGo O/S and/or a curl’d installation over Raspbian Buster Legacy.
I have not tried this with Bullseye, neither have I tried it with any other O/S, (such as Ubuntu with a curl’d install).
This was tested using a Raspberry Pi 4. I have not tried it with any other version of the Raspberry Pi.
Note the following video that I took of Charlie with an external 12v supply powering the +5v boost. You can duplicate this with batteries if you have an external 5v supply powering the Raspberry Pi while an energized battery is plugged into the GoPiGo power connector.
Note:
I press the button to begin a shutdown sequence.
The power LED blinks red as expected.
The activity light flashes as the system is shutting down.
The power LED begins flashing purple - this occurs when the system reaches the “Reached Target ‘Power Off’” if you monitor the shutdown messages on an attached monitor.
This is the point when the GoPiGo robot shuts off power if no external source is being applied.
Because external power IS being applied, the power LED begins flashing purple.
Note that after the power LED begins flashing purple, the green activity LED on the Raspberry Pi board continues to flash.
After several seconds, it stops flashing and about 15 - 20 seconds later an attached monitor goes into the “No Signal” state.
My conclusion is that the GoPiGo may be removing power from the Raspberry Pi before the operating system is fully shut down.
Unfortunately, I have not been able to determine exactly what processes might be occurring after that point, but if they involve writes to storage, that could be a Bad Thing.
If you want to duplicate this, you can do so by powering up your 'bot using both batteries AND an external 5v source by following these steps:
Verify that the battery power source is supplying power to the 12v connector, and the robot is ready to be powered up via the button. (Don’t press the button!)
Verify that the robot is not powered up and the Raspberry Pi is not running.
Apply power to the Raspberry Pi’s 5v connector.
Verify that the GoPiGo robot begins the power-up sequence as if the button had been pressed.
The robot should completely power up, the power LED should turn green, the eyes and antenna light should light, (if programmed to do so), and any other programmed startup activities, (such as servo activity, speaking, moving, etc.), should complete in a normal way.
If a monitor is attached and is displaying startup messages, all startup processes should complete normally as if the power button had been pressed.
Wait for the robot to come to a completely powered-up and stable state before continuing.
Paying careful attention to the green activity LED and the GoPiGo power LED, press the power button on the GoPiGo board to begin the shutdown sequence.
Verify that the normal pattern of shutdown activities occur as programmed for your particular robot. If a monitor is attached and is showing shutdown messages, verify that the robot reached the “Power Down” target state.
Note the activity of the Raspberry Pi’s green activity LED after the GoPiGo power LED begins flashing purple.
Sorry - don’t know what you are talking about - “set the default shutdown time”, “hang-times of 90 seconds”, and “flashes purple”. Are you setting something? I wouldn’t know what or why?
After shutdown -h now the GoPiGo3 power light flashes green until I push the button, then it flashes (I think red), then everything is off totally.
Using either a SD card or attached USB media like a flash drive or USB-3 SSD,
And using the power button as would be expected in a school environment - and is the specified way to shut down the robot:
The shutdown can, and periodically does, wait for 90 seconds or more while the pigpiod service shuts down. It eventually times out and is killed.
While this timeout is taking place, the power LED flashes purple and there is no apparent activity until it stops. After the process is killed, the power LED flashes red again and the shutdown proceeds normally.
Note this takes place prior to the filesystem being flushed and unmounted.
There is a file, (system.conf), that contains a bunch of commented-out statements that represent the default values for a number of system features.
One of them is, when shutting down, how long to wait for something to end before forcefully killing it.
This “Default shutdown time” (or something like that) is set to 90 seconds.
You change that value by un-commenting the statement and changing the value to something else. (20 seconds is a good minimum.)
If something hangs, (like pigpiod), on shutdown it waits 90 seconds to kill it.
During that time, the GoPiGo thinks that the pi has stopped and it flashes the power light purple.
Since there is no activity from the activity LED, and the power LED flashes purple, it is not unreasonable for people to think the robot is completely shutdown, and as a consequence pull power.
Unfortunately, the system is NOT shut down, file systems are still mounted, and severe data corruption can occur if power is removed.
Interesting - the value to uncomment appears to be:
#DefaultTimeoutStopSec=90s
I always use a command line requested shutdown sudo shutdown -h +2 and later, after making sure there is no activity light on the RPi, press the GoPiGo3 power button (LED is usually flashing green).
I’m wondering if I used sudo shutdown -p +2 if anything different would happen. I don’t understand the difference between the -p vs. -h options.
I try not to be in a hurry about turning off the power, so the default 90s timeout on hung processes is just fine for my needs.
UPDATE: read the man page on shutdown - -h includes the poweroff:
OPTIONS
The following options are understood:
--help
Print a short help text and exit.
-H, --halt
Halt the machine.
-P, --poweroff
Power-off the machine (the default).
-r, --reboot
Reboot the machine.
-h
Equivalent to --poweroff, unless --halt is specified.
-k
Do not halt, power-off, reboot, just write wall message.
--no-wall
Do not send wall message before halt, power-off, reboot.
-c
Cancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not "+0" or "now".
The shutdown sequence I have described has been true for me, on every OS I have tried, from R4R forward. I cannot speak to Dexter OS as it has been too long since I have used it. (Since my Pi-4 upgrade.)