Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions initramfs_build/overlay/init
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,9 @@ if [ -n "${ROOT_ROPATH}" ]; then

if [ -d "${user_backup_path}" ]; then
echo "WARN: backup path present; an update did not complete as expected"
# TODO: How to recover here?
backup_path="/media/rw/upperdir/opt/neon/failed_updates"
[ -d ${backup_path} ] || mkdir -p ${backup_path}
mv "${user_backup_path}" "${backup_path}/$(date +%s)"
fi

if [ -n "${ROOT_BUPATH}" ]; then
Expand All @@ -328,7 +330,7 @@ if [ -n "${ROOT_ROPATH}" ]; then
scripts/check_update.sh "/media/rw/upperdir/" "/media/rw/upperdir/opt/neon/update.squashfs" "${rootmnt}/${ROOT_ROPATH}" "${user_backup_path}"
fi

scripts/check_reset.sh "/media/rw"
scripts/check_reset.sh "/media/rw" "${rootmnt}/${ROOT_ROPATH}" "${rootmnt}/${ROOT_BUPATH}"
# Mount read-only FS
mkdir -p /media/ro
mount -t "squashfs" -o noatime,nodiratime "${rootmnt}/${ROOT_ROPATH}" /media/ro
Expand Down
24 changes: 21 additions & 3 deletions initramfs_build/overlay/scripts/check_reset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,34 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

WRITABLE_PATH=${1}
ROOT_PATH=${2}
BACK_PATH=${3}
SIGNAL_FILE="${WRITABLE_PATH}/upperdir/opt/neon/signal_reset_device"

revert_squashfs() {
[ -f "${BACK_PATH}" ] || exit 1
[ -f "${ROOT_PATH}" ] || exit 2
mv "${ROOT_PATH}" "${ROOT_PATH}.old"
mv "${BACK_PATH}" "${ROOT_PATH}"
echo "Restored previous squashFS"
exit 0
}

set_up_gpio() {
echo "22" > /sys/class/gpio/export
echo "23" > /sys/class/gpio/export
echo "24" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio22/direction
echo "in" > /sys/class/gpio/gpio23/direction
echo "in" > /sys/class/gpio/gpio24/direction
if [ "$(cat /sys/class/gpio/gpio24/value)" = "0" ] && [ "$(cat /sys/class/gpio/gpio23/value)" = "0" ]; then
echo "Reset buttons down"
touch "${SIGNAL_FILE}"
if [ "$(cat /sys/class/gpio/gpio22/value)" = "0" ]; then
echo "All buttons down"
revert_squashfs
else
echo "Reset buttons down"
touch "${SIGNAL_FILE}"
fi
fi
}

Expand All @@ -51,4 +69,4 @@ if [ -f "${SIGNAL_FILE}" ]; then
exit 0
# TODO: Option to power off instead of continuing boot
fi

exit 0
Binary file modified overlays/02-rpi4/boot/firmware/initramfs
Binary file not shown.
2 changes: 1 addition & 1 deletion overlays/02-rpi4/boot/firmware/initramfs.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2b6c3f133c124e0b184a4a9ef7b1956b
53e90ca5f47b77dcecbb6750227a6a6a