@@ -3035,6 +3035,12 @@ FIT uImage format:
Enable booting directly to an OS from SPL.
See also: doc/README.falcon
+ CONFIG_SPL_BOOTCOUNT_LIMIT
+ Optional part of CONFIG_SPL_OS_BOOT and requires
+ CONFIG_SPL_ENV_SUPPORT. Adds the bootcount facility to
+ SPL. It is strongly encouraged to not use bootcount in
+ both SPL and full U-Boot.
+
CONFIG_SPL_DISPLAY_PRINT
For ARM, enable an optional function to print more information
about the running system.
@@ -38,6 +38,10 @@ static bd_t bdata __attribute__ ((section(".data")));
*
* Please implement your own board specific funcion to do this.
*
+ * If both CONFIG_SPL_BOOTCOUNT_LIMIT and CONFIG_SPL_ENV_SUPPORT are
+ * set this function is responsible for calling
+ * spl_bootcount_limit_exceeded();
+ *
* RETURN
* 0 to not start u-boot
* positive if u-boot should start
@@ -49,6 +53,29 @@ __weak int spl_start_uboot(void)
puts("SPL: Direct Linux boot not active!\n");
return 1;
}
+
+#if defined(CONFIG_SPL_BOOTCOUNT_LIMIT) && defined(CONFIG_SPL_ENV_SUPPORT)
+/*
+ * Determine if we have exceeded our bootlimit.
+ *
+ * @return 1 if we have exceeded our limit, 0 otherwise.
+ */
+int spl_bootcount_limit_exceeded(void)
+{
+ unsigned long bootcount = 0;
+ unsigned long bootlimit = 0;
+
+ bootcount = bootcount_load();
+ bootcount++;
+ bootcount_store (bootcount);
+ setenv_ulong("bootcount", bootcount);
+ bootlimit = getenv_ulong("bootlimit", 10, 0);
+ printf("bootcount: %ld\nbootlimit: %ld\n", bootcount, bootlimit);
+ if (bootlimit)
+ return bootcount > bootlimit;
+ return 0;
+}
+#endif /* CONFIG_BOOTCOUNT_LIMIT && CONFIG_SPL_ENV_SUPPORT */
#endif
/*
@@ -70,6 +70,8 @@ CONFIG_CMD_SPL_WRITE_SIZE Size of the parameters area to be copied
CONFIG_SPL_OS_BOOT Activate Falcon Mode.
+CONFIG_SPL_BOOTCOUNT_LIMIT Use bootcount support to fall back to U-Boot
+
Function that a board must implement
------------------------------------
@@ -78,7 +80,8 @@ void spl_board_prepare_for_linux(void) : optional
spl_start_uboot() : required
Returns "0" if SPL should start the kernel, "1" if U-Boot
- must be started.
+ must be started. Must call spl_bootcount_limit_exceeded if
+ CONFIG_SPL_BOOTCOUNT_LIMIT is to be supported
Environment variables
---------------------
@@ -89,6 +92,9 @@ mode. In this case the following variables may be supported:
boot_os : Set to yes/Yes/true/True/1 to enable booting to OS,
any other value to fall back to U-Boot (including
unset)
+bootlimit : As part of CONFIG_SPL_BOOTCOUNT_LIMIT used to set the
+ maximum number of times to try and boot the OS before
+ falling back to U-Boot.
falcon_args_file : Filename to load as the 'args' portion of falcon mode
rather than the hard-coded value.
falcon_image_file : Filename to load as the OS image portion of falcon
@@ -37,6 +37,7 @@ void spl_parse_image_header(const struct image_header *header);
void spl_board_prepare_for_linux(void);
void __noreturn jump_to_image_linux(void *arg);
int spl_start_uboot(void);
+int spl_bootcount_limit_exceeded(void);
void spl_display_print(void);
/* NAND SPL functions */
@@ -99,6 +99,7 @@ LIBS-$(CONFIG_SPL_ETH_SUPPORT) += drivers/net/phy/libphy.o
LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/net/phy/libphy.o
LIBS-$(CONFIG_SPL_MUSB_NEW_SUPPORT) += drivers/usb/musb-new/libusb_musb-new.o
LIBS-$(CONFIG_SPL_USBETH_SUPPORT) += drivers/usb/gadget/libusb_gadget.o
+LIBS-$(CONFIG_SPL_BOOTCOUNT_LIMIT) += drivers/bootcount/libbootcount.o
LIBS-$(CONFIG_SPL_WATCHDOG_SUPPORT) += drivers/watchdog/libwatchdog.o
ifneq ($(CONFIG_OMAP_COMMON),)
Add a new symbol, CONFIG_SPL_BOOTCOUNT_SUPPORT, to make use of the existing BOOTCOUNT_SUPPORT within SPL. It is strongly discouraged to use bootcount in both SPL and full U-Boot, as they use the same counter. Signed-off-by: Tom Rini <trini@ti.com> --- README | 6 ++++++ common/spl/spl.c | 27 +++++++++++++++++++++++++++ doc/README.falcon | 8 +++++++- include/spl.h | 1 + spl/Makefile | 1 + 5 files changed, 42 insertions(+), 1 deletion(-)