Send "shutdown complete message" over UART? #287
-
In my board after everything is unmounted and it's safe to shutdown or reboot, I wanted to push a command over UART (so it needs to complete sending the command, but we don't need to wait for a response). Essentially this is telling a slave MCU that it's safe to toggle the power off when in this state. I was hoping to get your idea on the best way to achieve this in Finit? Should this be a plugin? or can it be a script somehow which is hooked at that exact state? The idea is I really want to make sure this command successfully runs as the second to last action (and the command completes) then the system can shutdown or reboot. I want all filesystems to unmount except root (as we are accessing /dev/ttyS2 to send the message). |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Interesting! When we designed a lot of the logic in Finit it was around making sure the system never shut down, but instead was kept alive and instead rebooted on error. For this we did a very tight integration with watchdogd, which I developed closely with Finit. We have very clever integration of these two, in fact, Finit comes with its own finit-watchdogd which services can be handed over to watchdogd when it starts up. As long as there's one of them available we let it do the actual reset logic -- by saving reset cause, setting the lowest WDT timeout in the kernel, and then allow the WDT to perform the board reset. If this fails, for some reason, Finit falls back to call So, that side of things is very developed, but the code is there in |
Beta Was this translation helpful? Give feedback.
-
I wanted to follow up on this. I have a need to force a reboot using the watchdog or custom UART command to a slave SoC (because I need to toggle the reset pin of the Soc) whenever a soft reset is requested instead of using the built in kernel reset function. What's the best way to do this? I could modify the kernel behaviour but that's a bit annoying. I thought of using a hook script in finit at the last stage to send a UART message and request the slave MCU to reset. Is there any issue with doing this as the last hook point? Whats the best way to accomplish this? |
Beta Was this translation helpful? Give feedback.
Interesting! When we designed a lot of the logic in Finit it was around making sure the system never shut down, but instead was kept alive and instead rebooted on error. For this we did a very tight integration with watchdogd, which I developed closely with Finit. We have very clever integration of these two, in fact, Finit comes with its own finit-watchdogd which services can be handed over to watchdogd when it starts up. As long as there's one of them available we let it do the actual reset logic -- by saving reset cause, setting the lowest WDT timeout in the kernel, and then allow the WDT to perform the board reset. If this fails, for some reason, Finit falls back to call
reboot(RB_AUT…