summaryrefslogtreecommitdiffstats
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
LD=ld
OC=objcopy
PREFIX?=arm-elf-eabi-
-REGS_PATH=../../../firmware/target/arm/imx233/regs
-CFLAGS=-mcpu=arm926ej-s -std=gnu99 -I. -I$(REGS_PATH) -nostdlib -ffreestanding -fomit-frame-pointer -O
+IMX233_PATH=../../../firmware/target/arm/imx233
+CFLAGS=-mcpu=arm926ej-s -std=gnu99 -I. -I$(IMX233_PATH) -nostdlib -ffreestanding -fomit-frame-pointer -O
# Edit the following variables when adding a new target.
# mkimxboot.c also needs to be edited to refer to these
# 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 @@
*
****************************************************************************/
-/** empty, used by register files */
+/** mostly empty, used by register files and dualboot */
+#define COMPILE_DUALBOOT_STUB
+
+/* obviously we have the dualboot stub! */
+#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 @@
* 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: