Skip to content

Commit

Permalink
boot-scripts: use itest for comparison, as setexpr calculates in hexa…
Browse files Browse the repository at this point in the history
…decimal

If you use numbers greater than 9 for the boot attempts, you will get the wrong
result for pure letter numbers (A..F). The test command incorrectly leads to
the result that e.g. F would not be greater than 0. This leads to an incorrect
A/B switchover.

Signed-off-by: Matthias Klein <matthias@extraklein.de>
  • Loading branch information
matthiasklein committed Dec 13, 2023
1 parent 052f2a1 commit eaa9b00
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions meta-rauc-nxp/recipes-bsp/u-boot/files/boot.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ for BOOT_SLOT in "${BOOT_ORDER}"; do
# stop checking after selecting a slot

elif test "x${BOOT_SLOT}" = "xA"; then
if test ${BOOT_A_LEFT} -gt 0; then
if itest ${BOOT_A_LEFT} -gt 0; then
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
echo "Booting RAUC slot A"

Expand All @@ -24,7 +24,7 @@ for BOOT_SLOT in "${BOOT_ORDER}"; do
fi

elif test "x${BOOT_SLOT}" = "xB"; then
if test ${BOOT_B_LEFT} -gt 0; then
if itest ${BOOT_B_LEFT} -gt 0; then
setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
echo "Booting RAUC slot B"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootpart}" != "x"; then
# skip remaining slots
elif test "x${BOOT_SLOT}" = "xA"; then
if test ${BOOT_A_LEFT} -gt 0; then
if itest ${BOOT_A_LEFT} -gt 0; then
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
echo "Found valid RAUC slot A"
setenv bootpart "/dev/mmcblk0p2"
setenv raucslot "A"
setenv BOOT_DEV "mmc 0:2"
fi
elif test "x${BOOT_SLOT}" = "xB"; then
if test ${BOOT_B_LEFT} -gt 0; then
if itest ${BOOT_B_LEFT} -gt 0; then
setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
echo "Found valid RAUC slot B"
setenv bootpart "/dev/mmcblk0p3"
Expand Down
4 changes: 2 additions & 2 deletions meta-rauc-sunxi/recipes-bsp/u-boot/files/boot.cmd.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ for BOOT_SLOT in "${BOOT_ORDER}"; do
if test "x${bootpart}" != "x"; then
# skip remaining slots
elif test "x${BOOT_SLOT}" = "xA"; then
if test ${BOOT_A_LEFT} -gt 0; then
if itest ${BOOT_A_LEFT} -gt 0; then
setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1
echo "Found valid RAUC slot A"
setenv bootpart "/dev/mmcblk0p2"
setenv raucslot "A"
setenv BOOT_DEV "mmc 0:2"
fi
elif test "x${BOOT_SLOT}" = "xB"; then
if test ${BOOT_B_LEFT} -gt 0; then
if itest ${BOOT_B_LEFT} -gt 0; then
setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1
echo "Found valid RAUC slot B"
setenv bootpart "/dev/mmcblk0p3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ index 6f36a0d2c4..d093a963b9 100644
+ " if test \"x${raucslot}\" != \"x\"; then " \
+ " echo \"skip remaining slots...\"; " \
+ " elif test \"x${BOOT_SLOT}\" = \"xA\"; then " \
+ " if test ${BOOT_A_LEFT} -gt 0; then " \
+ " if itest ${BOOT_A_LEFT} -gt 0; then " \
+ " setexpr BOOT_A_LEFT ${BOOT_A_LEFT} - 1; " \
+ " echo \"Found valid RAUC slot A\"; " \
+ " setenv raucslot \"rauc.slot=A\"; " \
+ " setenv raucpart 1; set distro_bootpart 1;" \
+ " fi; " \
+ " elif test \"x${BOOT_SLOT}\" = \"xB\"; then " \
+ " if test ${BOOT_B_LEFT} -gt 0; then " \
+ " if itest ${BOOT_B_LEFT} -gt 0; then " \
+ " setexpr BOOT_B_LEFT ${BOOT_B_LEFT} - 1; " \
+ " echo \"Found valid RAUC slot B\"; " \
+ " setenv raucslot \"rauc.slot=B\"; " \
Expand Down

0 comments on commit eaa9b00

Please sign in to comment.