From a983859291e29e2cfe26df8e00814b546d865b5c Mon Sep 17 00:00:00 2001 From: Amaury Pouly Date: Mon, 26 Sep 2016 21:22:21 +0100 Subject: imx233: add capability to boot OF or updater instead of Rockbox This commit adds the necessary code in the dualboot stub (bootloader) to let rockbox control the boot process. In particular, rockbox can now choose if the next boot will be normal (boot rockbox or OF on magic key), to OF or to updater. The intents (to be added in follow-up commits) are: 1) Let the user more easily reboot to the OF. On some targets it is not trivial, especially in USB mode. 2) Automatically reboot to updater when the user drop firmware.sb at the root of the drive (currently, the user needs to do that in OF USB mode) 3) Document this OF magic Change-Id: I86df651dec048c318c6a22de74abb8c6b41aa9ad --- firmware/target/arm/imx233/debug-imx233.c | 65 +++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 3 deletions(-) (limited to 'firmware/target/arm/imx233/debug-imx233.c') diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index 89365cb148..68865efc8d 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c @@ -31,6 +31,7 @@ #include "clkctrl-imx233.h" #include "powermgmt-imx233.h" #include "rtc-imx233.h" +#include "dualboot-imx233.h" #include "dcp-imx233.h" #include "pinctrl-imx233.h" #include "ocotp-imx233.h" @@ -535,10 +536,11 @@ bool dbg_hw_info_rtc(void) lcd_clear_display(); struct imx233_rtc_info_t info = imx233_rtc_get_info(); - lcd_putsf(0, 0, "seconds: %lu", info.seconds); - lcd_putsf(0, 1, "alarm: %lu", info.alarm); + int line = 0; + lcd_putsf(0, line++, "seconds: %lu", info.seconds); + lcd_putsf(0, line++, "alarm: %lu", info.alarm); for(int i = 0; i < 6; i++) - lcd_putsf(0, i + 2, "persist%d: 0x%lx", i, info.persistent[i]); + lcd_putsf(0, line++, "persist%d: 0x%lx", i, info.persistent[i]); lcd_update(); yield(); @@ -1255,6 +1257,60 @@ bool dbg_hw_info_sdmmc(void) } } +#ifdef HAVE_DUALBOOT_STUB +bool dbg_hw_info_dualboot(void) +{ + lcd_setfont(FONT_SYSFIXED); + + while(1) + { + int button = my_get_action(HZ / 10); + switch(button) + { + case ACT_NEXT: + case ACT_PREV: + { + /* only if boot mode is supported... */ + if(!imx233_dualboot_get_field(DUALBOOT_CAP_BOOT)) + break; + /* change it */ + unsigned boot = imx233_dualboot_get_field(DUALBOOT_BOOT); + if(boot == IMX233_BOOT_NORMAL) + boot = IMX233_BOOT_OF; + else if(boot == IMX233_BOOT_OF) + boot = IMX233_BOOT_UPDATER; + else + boot = IMX233_BOOT_NORMAL; + imx233_dualboot_set_field(DUALBOOT_BOOT, boot); + break; + } + case ACT_OK: + lcd_setfont(FONT_UI); + return true; + case ACT_CANCEL: + lcd_setfont(FONT_UI); + return false; + } + + lcd_clear_display(); + int line = 0; + unsigned cap_boot = imx233_dualboot_get_field(DUALBOOT_CAP_BOOT); + lcd_putsf(0, line++, "cap_boot: %s", cap_boot ? "yes" : "no"); + if(cap_boot) + { + unsigned boot = imx233_dualboot_get_field(DUALBOOT_BOOT); + lcd_putsf(0, line++, "boot: %s", + boot == IMX233_BOOT_NORMAL ? "normal" + : boot == IMX233_BOOT_OF ? "of" + : boot == IMX233_BOOT_UPDATER ? "updater" : "?"); + } + + lcd_update(); + yield(); + } +} +#endif + static struct { const char *name; @@ -1281,6 +1337,9 @@ static struct {"timrot", dbg_hw_info_timrot}, {"button", dbg_hw_info_button}, {"sdmmc", dbg_hw_info_sdmmc}, +#ifdef HAVE_DUALBOOT_STUB + {"dualboot", dbg_hw_info_dualboot}, +#endif {"target", dbg_hw_target_info}, }; -- cgit v1.2.3