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