-
Notifications
You must be signed in to change notification settings - Fork 191
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from jluebbe/uboot-support
bootchooser: add support for uboot via fw_setenv
- Loading branch information
Showing
5 changed files
with
217 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
test -n "${BOOT_ORDER}" || setenv BOOT_ORDER "A B" | ||
test -n "${BOOT_A_LEFT}" || setenv BOOT_A_LEFT 3 | ||
test -n "${BOOT_B_LEFT}" || setenv BOOT_B_LEFT 3 | ||
|
||
setenv bootargs | ||
for BOOT_SLOT in "${BOOT_ORDER}"; do | ||
if test "x${bootargs}" != "x"; then | ||
# skip remaining slots | ||
elif test "x${BOOT_SLOT}" = "xA"; then | ||
if test ${BOOT_A_LEFT} -gt 0; then | ||
expr BOOT_A_LEFT ${BOOT_A_LEFT} - 1 | ||
echo "Found valid slot A, ${BOOT_A_LEFT} attempts remaining" | ||
setenv load_kernel "nand read ${kernel_loadaddr} ${kernel_a_nandoffset} ${kernel_size}" | ||
setenv bootargs "${default_bootargs} root=/dev/mmcblk0p1 rauc.slot=A" | ||
fi | ||
elif test "x${BOOT_SLOT}" = "xB"; then | ||
if test ${BOOT_B_LEFT} -gt 0; then | ||
expr BOOT_B_LEFT ${BOOT_B_LEFT} - 1 | ||
echo "Found valid slot B, ${BOOT_B_LEFT} attempts remaining" | ||
setenv load_kernel "nand read ${kernel_loadaddr} ${kernel_b_nandoffset} ${kernel_size}" | ||
setenv bootargs "${default_bootargs} root=/dev/mmcblk0p2 rauc.slot=B" | ||
fi | ||
fi | ||
done | ||
|
||
if test -n "${bootargs}"; then | ||
saveenv | ||
else | ||
echo "No vaild slot found, resetting tries to 3" | ||
setenv BOOT_A_LEFT 3 | ||
setenv BOOT_B_LEFT 3 | ||
saveenv | ||
reset | ||
fi | ||
|
||
echo "Loading kernel" | ||
run load_kernel | ||
echo " Starting kernel" | ||
bootm ${loadaddr_kernel} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# Command line checking | ||
if [ $# -ne 2 ]; then | ||
echo "Invalid arguments $*" | ||
exit 1 | ||
fi | ||
|
||
if [ "$1" = "BOOT_ORDER" ]; then | ||
if ! [ "$2" = "A B" -o "$2" = "B A" ]; then | ||
echo "Invalid argument for BOOT_ORDER: '$2'" | ||
exit 1 | ||
fi | ||
elif [ "$1" = "BOOT_A_LEFT" ]; then | ||
if ! [ "$2" -ge 0 -a "$2" -le 3 ]; then | ||
echo "Invalid argument for BOOT_A_LEFT: '$2'" | ||
exit 1 | ||
fi | ||
elif [ "$1" = "BOOT_B_LEFT" ]; then | ||
if ! [ "$2" -ge 0 -a "$2" -le 3 ]; then | ||
echo "Invalid argument for BOOT_B_LEFT: '$2'" | ||
exit 1 | ||
fi | ||
else | ||
echo "Invalid key: '$1'" | ||
exit 1 | ||
fi | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters