Skip to content

Commit 866b0b7

Browse files
Avinash95francois-berder
authored andcommitted
pistachio_bub.h: improve failsafe mechanism
Previous failsafe implementation worked only after an upgrade, change the implementation so that - it works irrespective of upgrades - if an image fails to boot 5 times continuously switch to another partition and try - if both partition start failing, each will be tried 5 times alternatively and infinitely. Enable setexpr command to perform arithmetic operations. Change-Id: I29eb3a6d42b066cec14b5d1066a7a4986e2a9ad5 Signed-off-by: Avinash Tahakik <[email protected]>
1 parent 01394aa commit 866b0b7

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

include/configs/pistachio_bub.h

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,8 @@
226226
#define CONFIG_ENV_SPI_BUS 1
227227
#define CONFIG_ENV_SPI_CS 0
228228

229-
#define UPGRADE_CHECK_RESET \
230-
"if test ${attempt_upgrade} -eq 1; then " \
231-
"reset; " \
232-
"fi;"
229+
#define CONFIG_CMD_SETEXPR
230+
233231
#define USB_BOOTCOMMAND \
234232
"sf probe 1:0;" \
235233
"mtdparts default;" \
@@ -278,30 +276,31 @@
278276
"ubifsload $loadaddr $bootdir$bootfile && " \
279277
"ubifsload $fdtaddr $bootdir$fdtfile && " \
280278
"bootm $loadaddr - $fdtaddr\";" \
281-
"run ubifs_bootm_cmd"
282-
283-
#define DUAL_NAND_BOOTCOMMAND_RESET \
284-
DUAL_NAND_BOOTCOMMAND " || " UPGRADE_CHECK_RESET
279+
"run ubifs_bootm_cmd || reset;"
285280

286281
#ifdef CONFIG_BOOTCOUNT_LIMIT
287282

288283
#define CONFIG_SYS_BOOTCOUNT_ADDR 0x18102120
289284

290285
#define ALT_BOOTCOMMAND \
291-
"if test ${attempt_upgrade} -eq 1; then " \
292-
"if test ${boot_partition} -eq 0; then " \
293-
"setenv boot_partition 1;" \
294-
"else " \
295-
"setenv boot_partition 0;" \
296-
"fi;" \
297-
"setenv attempt_upgrade 0;" \
298-
"saveenv;" \
299-
"fi;" \
286+
"setexpr bootcount_temp $bootcount - 1;" \
287+
"setexpr switch_partition $bootcount_temp % $bootlimit;" \
288+
"if test ${switch_partition} -eq 0; then " \
289+
"if test ${boot_partition} -eq 0; then " \
290+
"echo **Switching to partition 1;" \
291+
"setenv boot_partition 1;" \
292+
"else " \
293+
"echo **Switching to partition 0;" \
294+
"setenv boot_partition 0;" \
295+
"fi;" \
296+
"env delete bootcount_temp;" \
297+
"env delete switch_partition;" \
298+
"saveenv;" \
299+
"fi;" \
300300
DUAL_NAND_BOOTCOMMAND
301301

302302
#define BOOTCOUNT_VARIABLES \
303303
"bootlimit=5\0" \
304-
"attempt_upgrade=0\0" \
305304
"altbootcmd="ALT_BOOTCOMMAND"\0"
306305

307306
#else
@@ -337,7 +336,7 @@
337336

338337
#else
339338

340-
#define CONFIG_BOOTCOMMAND DUAL_NAND_BOOTCOMMAND_RESET
339+
#define CONFIG_BOOTCOMMAND DUAL_NAND_BOOTCOMMAND
341340

342341
#endif
343342

@@ -363,7 +362,7 @@
363362
"nandboot="NAND_BOOTCOMMAND"\0" \
364363
"ethboot="ETH_BOOTCOMMAND"\0" \
365364
"netboot="NET_BOOTCOMMAND"\0" \
366-
"dualnandboot="DUAL_NAND_BOOTCOMMAND_RESET"\0" \
365+
"dualnandboot="DUAL_NAND_BOOTCOMMAND"\0" \
367366
BOOTCOUNT_VARIABLES \
368367
"u_memload=0x00800000\0" \
369368
"u_memsize=0x08000000\0" \

0 commit comments

Comments
 (0)