Files
forgefirm/scripts/ffboot
T
ScottW514 83627a6aea scripts/docs: fail loudly, fix names, document bring-up-only status
install-forgefirm.sh completed silently broken when the download, flash
write, mount or uEnv rewrite failed - add die() checks around every
critical step (audit N13/M12) and download the release asset under the
exact Scarthgap artifact name (forgefirm-image-glowforge.rootfs.wic.gz)
so uploads need no renaming. ffboot no longer depends on the never-
provisioned /etc/fw_env_mmcblk2.config: it falls back to
/etc/fw_env.config (which both the factory and ForgeFIRM images ship,
pointing at the eMMC env) and checks fw_setenv results (audit N16).
BUILD.md gets the real artifact name and marks the built u-boot
reference-only; INSTALL.md drops the stale script/ogboot names and the
cloud-connect promise, stating the image is bring-up-only (audit N11).
2026-07-26 16:15:25 -04:00

101 lines
2.1 KiB
Bash

#!/bin/sh
# (C) Copyright 2020-2026
# Scott Wiederhold, s.e.wiederhold@gmail.com
# https://community.openglow.org
# SPDX-License-Identifier: MIT
#
# This program sets the bootloader to the requested image and reboots
usage () {
cat <<END
usage: ffboot -s|e[<partition>] [-n]
-s: SDCARD OpenGlow/ForgeFIRM
-e[<partition>]: eMMC
1: Factory image 1
2: Factory image 2
4: OpenGlow/ForgeFIRM image
Default:
When run from OpenGlow/ForgeFIRM: Factory image with most recent firmwmare
When run from Factory : Factory image 1
-n: No reboot
END
}
REBOOT=1
if [ $# -gt 2 ]; then
usage
exit 2
fi
if [ $# -gt 1 ]; then
if [ $2 = "-n" ]; then
REBOOT=0
else
usage
exit 2
fi
fi
case "$1" in
-s)
MMCDEV=0
MMCPART=1
;;
-e)
MMCDEV=1
MMCPART=1
if [ -d "/factory" ]; then
V1=$(cat /factory/img1/etc/version)
V2=$(cat /factory/img2/etc/version)
if [ $V2 -gt $V1 ]; then
MMCPART=2
fi
fi
;;
-e1)
MMCDEV=1
MMCPART=1
;;
-e2)
MMCDEV=1
MMCPART=2
;;
-e4)
MMCDEV=1
MMCPART=4
;;
*)
usage
exit 2
esac
# The env always lives on the eMMC (mmcblk2 0x80000/0x82000). On the factory
# firmware and on the ForgeFIRM image, /etc/fw_env.config already points
# there; the mmcblk2-specific override is honored if someone provisioned one,
# but nothing ships it, so fall back rather than failing on a missing file
# (audit N16).
if [ -f "/etc/fw_env_mmcblk2.config" ] && [ ! -d "/factory" ]; then
FWCONFIG="/etc/fw_env_mmcblk2.config"
else
FWCONFIG="/etc/fw_env.config"
fi
if [ ! -f "$FWCONFIG" ]; then
echo "ERROR: $FWCONFIG not found; cannot switch boot device" >&2
exit 1
fi
MMCROOT="/dev/mmcblk"$(($MMCDEV + 1))"p"$MMCPART
echo "Setting to boot from $MMCROOT"
fw_setenv -c $FWCONFIG mmcdev $MMCDEV || { echo "ERROR: fw_setenv mmcdev failed" >&2; exit 1; }
fw_setenv -c $FWCONFIG mmcpart $MMCPART || { echo "ERROR: fw_setenv mmcpart failed" >&2; exit 1; }
fw_setenv -c $FWCONFIG mmcroot $MMCROOT || { echo "ERROR: fw_setenv mmcroot failed" >&2; exit 1; }
if [ $REBOOT -gt 0 ]; then
echo "Rebooting..."
reboot
fi
exit 0