diff options
author | Amaury Pouly <amaury.pouly@gmail.com> | 2016-09-26 21:22:21 +0100 |
---|---|---|
committer | Gerrit Rockbox <gerrit@rockbox.org> | 2016-12-12 12:03:08 +0100 |
commit | a983859291e29e2cfe26df8e00814b546d865b5c (patch) | |
tree | 7ba94ae05153124a52bc546d46aecb91715578b3 /rbutil/mkimxboot/dualboot/dualboot.c | |
parent | 5c50efc9cec9b0b2f0af216c4e9bf82dc3046d04 (diff) | |
download | rockbox-a983859291e29e2cfe26df8e00814b546d865b5c.tar.gz rockbox-a983859291e29e2cfe26df8e00814b546d865b5c.zip |
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
Diffstat (limited to 'rbutil/mkimxboot/dualboot/dualboot.c')
-rw-r--r-- | rbutil/mkimxboot/dualboot/dualboot.c | 40 |
1 files changed, 35 insertions, 5 deletions
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 @@ | |||
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
19 | * | 19 | * |
20 | ****************************************************************************/ | 20 | ****************************************************************************/ |
21 | #include "pinctrl.h" | 21 | #include "regs/pinctrl.h" |
22 | #include "power.h" | 22 | #include "regs/power.h" |
23 | #include "lradc.h" | 23 | #include "regs/lradc.h" |
24 | #include "digctl.h" | 24 | #include "regs/digctl.h" |
25 | #include "clkctrl.h" | 25 | #include "regs/clkctrl.h" |
26 | 26 | ||
27 | #define BOOT_ROM_CONTINUE 0 /* continue boot */ | 27 | #define BOOT_ROM_CONTINUE 0 /* continue boot */ |
28 | #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ | 28 | #define BOOT_ROM_SECTION 1 /* switch to new section *result_id */ |
@@ -34,6 +34,10 @@ | |||
34 | 34 | ||
35 | typedef unsigned long uint32_t; | 35 | typedef unsigned long uint32_t; |
36 | 36 | ||
37 | /* we include the dualboot rtc code directly */ | ||
38 | #include "dualboot-imx233.h" | ||
39 | #include "dualboot-imx233.c" | ||
40 | |||
37 | // target specific boot context | 41 | // target specific boot context |
38 | enum context_t | 42 | enum context_t |
39 | { | 43 | { |
@@ -270,10 +274,36 @@ static inline void do_charge(void) | |||
270 | } | 274 | } |
271 | } | 275 | } |
272 | 276 | ||
277 | static void set_updater_bits(void) | ||
278 | { | ||
279 | /* The OF will continue to updater if we clear 18 of PERSISTENT1. | ||
280 | * See dualboot-imx233.c in firmware/ for more explanation */ | ||
281 | HW_RTC_PERSISTENT1_CLR = 1 << 18; | ||
282 | } | ||
283 | |||
273 | int main(uint32_t arg, uint32_t *result_id) | 284 | int main(uint32_t arg, uint32_t *result_id) |
274 | { | 285 | { |
275 | if(arg == BOOT_ARG_CHARGE) | 286 | if(arg == BOOT_ARG_CHARGE) |
276 | do_charge(); | 287 | do_charge(); |
288 | /* tell rockbox that we can handle boot mode */ | ||
289 | imx233_dualboot_set_field(DUALBOOT_CAP_BOOT, 1); | ||
290 | /* if we were asked to boot in a special mode, do so */ | ||
291 | unsigned boot_mode = imx233_dualboot_get_field(DUALBOOT_BOOT); | ||
292 | /* clear boot mode to avoid any loop */ | ||
293 | imx233_dualboot_set_field(DUALBOOT_BOOT, IMX233_BOOT_NORMAL); | ||
294 | switch(boot_mode) | ||
295 | { | ||
296 | case IMX233_BOOT_UPDATER: | ||
297 | set_updater_bits(); | ||
298 | /* fallthrough */ | ||
299 | case IMX233_BOOT_OF: | ||
300 | /* continue booting */ | ||
301 | return BOOT_ROM_CONTINUE; | ||
302 | case IMX233_BOOT_NORMAL: | ||
303 | default: | ||
304 | break; | ||
305 | } | ||
306 | /* normal boot */ | ||
277 | switch(boot_decision(get_context())) | 307 | switch(boot_decision(get_context())) |
278 | { | 308 | { |
279 | case BOOT_ROCK: | 309 | case BOOT_ROCK: |