mirror of
https://github.com/openglow-org/forgefirm.git
synced 2026-09-27 08:41:13 -07:00
temp_calibrate now cross-checks the factory B-equation instead of the retired linear guess.
100 lines
2.1 KiB
Bash
100 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.
|
|
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
|