summaryrefslogtreecommitdiff
path: root/rbutil/mkimxboot/dualboot
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2016-09-26 21:22:21 +0100
committerGerrit Rockbox <gerrit@rockbox.org>2016-12-12 12:03:08 +0100
commita983859291e29e2cfe26df8e00814b546d865b5c (patch)
tree7ba94ae05153124a52bc546d46aecb91715578b3 /rbutil/mkimxboot/dualboot
parent5c50efc9cec9b0b2f0af216c4e9bf82dc3046d04 (diff)
downloadrockbox-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')
-rw-r--r--rbutil/mkimxboot/dualboot/Makefile4
-rw-r--r--rbutil/mkimxboot/dualboot/config.h6
-rw-r--r--rbutil/mkimxboot/dualboot/dualboot.c40
3 files changed, 42 insertions, 8 deletions
diff --git a/rbutil/mkimxboot/dualboot/Makefile b/rbutil/mkimxboot/dualboot/Makefile
index 7abd381b2d..b80233226a 100644
--- a/rbutil/mkimxboot/dualboot/Makefile
+++ b/rbutil/mkimxboot/dualboot/Makefile
@@ -2,8 +2,8 @@ CC=gcc
2LD=ld 2LD=ld
3OC=objcopy 3OC=objcopy
4PREFIX?=arm-elf-eabi- 4PREFIX?=arm-elf-eabi-
5REGS_PATH=../../../firmware/target/arm/imx233/regs 5IMX233_PATH=../../../firmware/target/arm/imx233
6CFLAGS=-mcpu=arm926ej-s -std=gnu99 -I. -I$(REGS_PATH) -nostdlib -ffreestanding -fomit-frame-pointer -O 6CFLAGS=-mcpu=arm926ej-s -std=gnu99 -I. -I$(IMX233_PATH) -nostdlib -ffreestanding -fomit-frame-pointer -O
7# Edit the following variables when adding a new target. 7# Edit the following variables when adding a new target.
8# mkimxboot.c also needs to be edited to refer to these 8# mkimxboot.c also needs to be edited to refer to these
9# To add a new target x you need to: 9# To add a new target x you need to:
diff --git a/rbutil/mkimxboot/dualboot/config.h b/rbutil/mkimxboot/dualboot/config.h
index ff59cee710..e9ea8d4a35 100644
--- a/rbutil/mkimxboot/dualboot/config.h
+++ b/rbutil/mkimxboot/dualboot/config.h
@@ -19,4 +19,8 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22/** empty, used by register files */ 22/** mostly empty, used by register files and dualboot */
23#define COMPILE_DUALBOOT_STUB
24
25/* obviously we have the dualboot stub! */
26#define HAVE_DUALBOOT_STUB
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
35typedef unsigned long uint32_t; 35typedef 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
38enum context_t 42enum context_t
39{ 43{
@@ -270,10 +274,36 @@ static inline void do_charge(void)
270 } 274 }
271} 275}
272 276
277static 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
273int main(uint32_t arg, uint32_t *result_id) 284int 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: