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 --- rbutil/mkimxboot/dualboot/dualboot.c | 40 +++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'rbutil/mkimxboot/dualboot/dualboot.c') diff --git a/rbutil/mkimxboot/dualboot/dualboot.c b/rbutil/mkimxboot/dualboot/dualboot.c index 82568b8893..77b816bf76 100644 --- a/rbutil/mkimxboot/dualboot/dualboot.c +++ b/rbutil/mkimxboot/dualboot/dualboot.c @@ -18,11 +18,11 @@ * KIND, either express or implied. * ****************************************************************************/ -#include "pinctrl.h" -#include "power.h" -#include "lradc.h" -#include "digctl.h" -#include "clkctrl.h" +#include "regs/pinctrl.h" +#include "regs/power.h" +#include "regs/lradc.h" +#include "regs/digctl.h" +#include "regs/clkctrl.h" #define BOOT_ROM_CONTINUE 0 /* continue boot */ #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ @@ -34,6 +34,10 @@ typedef unsigned long uint32_t; +/* we include the dualboot rtc code directly */ +#include "dualboot-imx233.h" +#include "dualboot-imx233.c" + // target specific boot context enum context_t { @@ -270,10 +274,36 @@ static inline void do_charge(void) } } +static void set_updater_bits(void) +{ + /* The OF will continue to updater if we clear 18 of PERSISTENT1. + * See dualboot-imx233.c in firmware/ for more explanation */ + HW_RTC_PERSISTENT1_CLR = 1 << 18; +} + int main(uint32_t arg, uint32_t *result_id) { if(arg == BOOT_ARG_CHARGE) do_charge(); + /* tell rockbox that we can handle boot mode */ + imx233_dualboot_set_field(DUALBOOT_CAP_BOOT, 1); + /* if we were asked to boot in a special mode, do so */ + unsigned boot_mode = imx233_dualboot_get_field(DUALBOOT_BOOT); + /* clear boot mode to avoid any loop */ + imx233_dualboot_set_field(DUALBOOT_BOOT, IMX233_BOOT_NORMAL); + switch(boot_mode) + { + case IMX233_BOOT_UPDATER: + set_updater_bits(); + /* fallthrough */ + case IMX233_BOOT_OF: + /* continue booting */ + return BOOT_ROM_CONTINUE; + case IMX233_BOOT_NORMAL: + default: + break; + } + /* normal boot */ switch(boot_decision(get_context())) { case BOOT_ROCK: -- cgit v1.2.3