xref: /openbmc/phosphor-bmc-code-mgmt/bmc/reset-cs0-aspeed (revision cab87e9cdeeb3e166d6d577511f6be4dc7721aca)
1*cab87e9cSJagpal Singh Gill#!/bin/sh
2*cab87e9cSJagpal Singh Gill
3*cab87e9cSJagpal Singh Gill# Write 1 to /sys/class/watchdog/watchdog1/access_cs0 to reset the boot code
4*cab87e9cSJagpal Singh Gill# selection and reset the chip select, so that the next boot is from the
5*cab87e9cSJagpal Singh Gill# primary chip.
6*cab87e9cSJagpal Singh Gill# This needs to be done in the shutdown script after umount the rootfs,
7*cab87e9cSJagpal Singh Gill# otherwise the filesystem will get error because the content is switched
8*cab87e9cSJagpal Singh Gill# back to CS0 chip.
9*cab87e9cSJagpal Singh Gill
10*cab87e9cSJagpal Singh GillSHUTDOWN_EXTRA_SCRIPT="/run/initramfs/shutdown_task_after_umount"
11*cab87e9cSJagpal Singh Gill
12*cab87e9cSJagpal Singh Gillcat <<'EOF' >"${SHUTDOWN_EXTRA_SCRIPT}"
13*cab87e9cSJagpal Singh Gill#!/bin/sh
14*cab87e9cSJagpal Singh GillACCESS_CS0="/sys/class/watchdog/watchdog1/access_cs0"
15*cab87e9cSJagpal Singh Gillif [ -f "${ACCESS_CS0}" ]; then
16*cab87e9cSJagpal Singh Gill    echo "Reset aspeed chip select"
17*cab87e9cSJagpal Singh Gill    echo 1 > "${ACCESS_CS0}"
18*cab87e9cSJagpal Singh Gillfi
19*cab87e9cSJagpal Singh GillEOF
20*cab87e9cSJagpal Singh Gillchmod +x "${SHUTDOWN_EXTRA_SCRIPT}"
21*cab87e9cSJagpal Singh Gill
22*cab87e9cSJagpal Singh Gill
23*cab87e9cSJagpal Singh Gill# Insert the shutdown_task_after_umount into the shutdown script
24*cab87e9cSJagpal Singh Gill# This change could be apply to obmc-shutdown.sh in obmc-phosphor-initfs.bb
25*cab87e9cSJagpal Singh Gill# if this is accepted.
26*cab87e9cSJagpal Singh Gillsed -i "s/echo Remaining mounts/\/run\/initramfs\/shutdown_task_after_umount\\necho Remaining mounts/" /run/initramfs/shutdown
27