Lei YU | 984cef5 | 2021-12-17 11:28:21 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | # Write 1 to /sys/class/watchdog/watchdog1/access_cs0 to reset the boot code |
| 4 | # selection and reset the chip select, so that the next boot is from the |
| 5 | # primary chip. |
| 6 | # This needs to be done in the shutdown script after umount the rootfs, |
| 7 | # otherwise the filesystem will get error because the content is switched |
| 8 | # back to CS0 chip. |
| 9 | |
| 10 | SHUTDOWN_EXTRA_SCRIPT="/run/initramfs/shutdown_task_after_umount" |
| 11 | |
| 12 | cat <<'EOF' >"${SHUTDOWN_EXTRA_SCRIPT}" |
| 13 | #!/bin/sh |
| 14 | ACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0" |
| 15 | if [ -f "${ACCESS_CS0}" ]; then |
| 16 | echo "Reset aspeed chip select" |
| 17 | echo 1 > "${ACCESS_CS0}" |
| 18 | fi |
| 19 | EOF |
| 20 | chmod +x "${SHUTDOWN_EXTRA_SCRIPT}" |
| 21 | |
| 22 | |
| 23 | # Insert the shutdown_task_after_umount into the shutdown script |
| 24 | # This change could be apply to obmc-shutdown.sh in obmc-phosphor-initfs.bb |
| 25 | # if this is accepted. |
| 26 | sed -i "s/echo Remaining mounts/\/run\/initramfs\/shutdown_task_after_umount\\necho Remaining mounts/" /run/initramfs/shutdown |