Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:hardware:watchdog [2020/09/21 06:58] – [Hardware watchdog] content and formatting optimized vgaetera | docs:guide-user:hardware:watchdog [2021/11/01 11:39] – [USB watchdogs] vgaetera | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| For x86 hardware you have some kmods to choose: | For x86 hardware you have some kmods to choose: | ||
| - | * '' | + | * AMD: [[packages: |
| - | * '' | + | * Intel: [[packages: |
| - | * '' | + | * Generic: [[packages: |
| There are also USB-based watchdogs, which will be discussed below in their own sub-section because they are not handled by procd in any way. | There are also USB-based watchdogs, which will be discussed below in their own sub-section because they are not handled by procd in any way. | ||
| The procd watchdog code always uses the primary watchdog device ''/ | The procd watchdog code always uses the primary watchdog device ''/ | ||
| - | You can configure what watchdog that is (ie GSC Watchdog or SoC watchdog) by disabling all but the desired watchdog in the kernel configuration, | + | You can configure what watchdog that is (i.e. GSC Watchdog or SoC watchdog) by disabling all but the desired watchdog in the kernel configuration, |
| ===== Controlling the watchdog ===== | ===== Controlling the watchdog ===== | ||
| You can see the current configuration of the watchdog service via ubus: | You can see the current configuration of the watchdog service via ubus: | ||
| - | |||
| - | If there is a watchdog available: | ||
| <code bash> | <code bash> | ||
| Line 30: | Line 28: | ||
| </ | </ | ||
| - | If no watchdog is available: | + | If no watchdog is available, the status |
| - | + | ||
| - | <code bash> | + | |
| - | # ubus call system watchdog | + | |
| - | { | + | |
| - | "status": "offline", | + | |
| - | " | + | |
| - | " | + | |
| - | } | + | |
| - | </ | + | |
| While there is no UCI configuration available for these options, you can change them in an rc script such as ''/ | While there is no UCI configuration available for these options, you can change them in an rc script such as ''/ | ||
| Line 45: | Line 34: | ||
| <code bash> | <code bash> | ||
| # Change timeout to 60s | # Change timeout to 60s | ||
| - | ubus call system watchdog '{ " | + | ubus call system watchdog ' |
| # Change frequency to 1s | # Change frequency to 1s | ||
| - | ubus call system watchdog '{ " | + | ubus call system watchdog ' |
| </ | </ | ||
| - | To stop the service: | + | To bypass procd, enable the magicclose feature, |
| <code bash> | <code bash> | ||
| - | ubus call system watchdog '{ " | + | ubus call system watchdog ' |
| + | ubus call system watchdog ' | ||
| + | while :; do echo 1 > / | ||
| </ | </ | ||
| Note that watchdog will cause a reset after it expires. | Note that watchdog will cause a reset after it expires. | ||
| - | |||
| - | ===== Manually control hardware watchdog ===== | ||
| - | If you just stop procd from tickling the hardware watchdog you still can't manually tickle watchdog: | ||
| - | |||
| - | <code bash> | ||
| - | # ubus call system watchdog ' | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | |||
| - | # echo 1 > / | ||
| - | -ash: can't create / | ||
| - | </ | ||
| - | |||
| - | But if you enable magicclose feature then you have control: | ||
| - | |||
| - | <code bash> | ||
| - | # ubus call system watchdog ' | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | |||
| - | # ubus call system watchdog ' | ||
| - | { | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | " | ||
| - | } | ||
| - | |||
| - | # echo 1 > / | ||
| - | # | ||
| - | </ | ||
| ===== USB watchdogs ===== | ===== USB watchdogs ===== | ||
| Line 110: | Line 63: | ||
| Some USB-based watchdogs are not using a serial dongle, but show up as USB HID devices and I don't know what is their protocol. | Some USB-based watchdogs are not using a serial dongle, but show up as USB HID devices and I don't know what is their protocol. | ||
| - | This is a script that will generate a Procd service to control one of such USB-serial watchdogs | + | This is a script that will generate a procd service to control one of such USB-serial watchdogs. |
| - | <code bash usb_watchdog> | + | <code bash> |
| + | cat << " | ||
| #!/bin/sh | #!/bin/sh | ||
| # Watchdog control script for USB-serial based watchdogs | # Watchdog control script for USB-serial based watchdogs | ||
| - | # The command to run the watchdog 160 seconds is | + | # The command to run the watchdog 160 seconds is: |
| - | # echo -en " | + | # echo -n -e " |
| # The " | # The " | ||
| # just write a different hexadecimal number, and adjust the number of seconds in the sleep command below. | # just write a different hexadecimal number, and adjust the number of seconds in the sleep command below. | ||
| Line 130: | Line 84: | ||
| # So I filter for ch341 serial chips. | # So I filter for ch341 serial chips. | ||
| - | usb_serial=" | + | usb_serial=" |
| + | cmd=" | ||
| if [ -z " | if [ -z " | ||
| Line 138: | Line 93: | ||
| fi | fi | ||
| - | case "${1}" in | + | case "${cmd}" in |
| - | stop) | + | (start) |
| + | echo " | ||
| + | |||
| + | while [ ! -f / | ||
| + | do | ||
| + | echo -n -e " | ||
| + | sleep 30 | ||
| + | done | ||
| + | rm / | ||
| + | echo " | ||
| + | ;; | ||
| + | |||
| + | (stop) | ||
| touch / | touch / | ||
| - | exit 0 | ||
| ;; | ;; | ||
| - | install) | + | (install) |
| - | + | cat << "EOI" > / | |
| - | cat << "EOF" > / | + | |
| #!/bin/sh / | #!/bin/sh / | ||
| + | |||
| USE_PROCD=1 | USE_PROCD=1 | ||
| START=95 | START=95 | ||
| STOP=01 | STOP=01 | ||
| + | |||
| start_service() { | start_service() { | ||
| procd_open_instance | procd_open_instance | ||
| - | procd_set_param command / | + | procd_set_param command /bin/sh / |
| # If process dies sooner than respawn_threshold, | # If process dies sooner than respawn_threshold, | ||
| procd_set_param respawn ${respawn_threshold: | procd_set_param respawn ${respawn_threshold: | ||
| Line 161: | Line 128: | ||
| } | } | ||
| - | stop_service() | + | stop_service() { |
| - | { | + | |
| / | / | ||
| } | } | ||
| - | EOF | + | EOI |
| - | chmod +x / | + | cat << "EOI" > / |
| - | + | ||
| - | cat << "EOF" > / | + | |
| - | /etc/ | + | |
| / | / | ||
| /etc/rc.d/ | /etc/rc.d/ | ||
| - | EOF | + | / |
| + | EOI | ||
| + | chmod +x / | ||
| / | / | ||
| / | / | ||
| - | |||
| - | grep -q -e usb_watchdog / | ||
| - | |||
| - | if [ " | ||
| - | then sed -i -e "/exit 0/i / | ||
| - | fi | ||
| - | exit 0 | ||
| ;; | ;; | ||
| - | remove) | + | (remove) |
| - | rm /lib/upgrade/keep.d/ | + | /etc/init.d/ |
| - | rm / | + | /etc/init.d/ |
| - | rm / | + | rm -f / |
| - | sed -i -e "s|/etc/init.d/ | + | rm -f / |
| - | exit 0 | + | rm -f /lib/upgrade/ |
| ;; | ;; | ||
| esac | esac | ||
| - | + | EOF | |
| - | echo " | + | chmod +x /etc/usb_watchdog |
| - | + | /etc/usb_watchdog install | |
| - | while [ ! -f /tmp/stop_usb_watchdog ] | + | |
| - | do | + | |
| - | echo -n -e " | + | |
| - | sleep 30 | + | |
| - | done | + | |
| - | + | ||
| - | rm / | + | |
| - | + | ||
| - | echo " | + | |
| </ | </ | ||
| Line 212: | Line 161: | ||
| <code bash> | <code bash> | ||
| - | wget --no-check-certificate -O / | + | uclient-fetch -O usb-watchdog.sh |
| - | chmod +x /etc/ | + | . ./usb-watchdog.sh |
| - | / | + | |
| </ | </ | ||