Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
On Mon, 9 Feb 2015 15:23:17 -0700 Simon Glass s...@chromium.org wrote: Hi Siarhei, On 7 February 2015 at 20:48, Siarhei Siamashka siarhei.siamas...@gmail.com wrote: On Sat, 7 Feb 2015 10:47:30 -0700 Simon Glass s...@chromium.org wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL Thanks for working on these patches. It looks like we are finally getting really close to resolving the sunxi FEL boot problem. Some comments are below. arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) Maybe we can just update the 'save_boot_params' function to save the important configuration registers and then undo this configuration in 'return_to_fel'? This allows us to avoid the sunxi specific ifdefs in the core ARM code. In this particular case, restoring VBAR and CPSR is important because the BROM code uses an IRQ handler for FEL (presumably USB related). And we want to ensure that this IRQ handler works properly again after resuming the FEL code. We could indeed. It would avoid the #ifdef but my understanding is that you might be able to avoid having to 'return' to the BROM through another means. In any case we could perhaps leave that change until the next release? I just previously thought that the FEL tool could store the return address somewhere in beginning of SRAM in the eGON header extension. In this case, restoring the 'lr' and 'sp' registers would be unnecessary and the use of the 'save_boot_params' function could be dropped. But if we still need to save/restore VBAR and the other control registers, then this idea about not saving 'lr' and 'sp' does not really improve anything. [...] u32 spl_boot_device(void) { + /* + * Have we been asked to return to the FEL portion of the boot ROM? + * TODO: We need a more robust test here, or bracket this with + * #ifdef CONFIG_SPL_FEL. + */ + if (fel_stash.lr = 0x fel_stash.lr 0x4000) + return BOOT_DEVICE_BOARD; return BOOT_DEVICE_MMC1; It is probably better to do it this way: #ifdef CONFIG_SPL_FEL return BOOT_DEVICE_BOARD; #else if (memcmp((void *)4, eGON.BT0, 8) == 0) return BOOT_DEVICE_MMC1; else return BOOT_DEVICE_BOARD; #endif The memcmp (or equivalent code) ensures that it is compatible with https://github.com/ssvb/sunxi-tools/commit/aa7e1880986e5c9a825b08aed9dc5621b821805f Then the new 'fel spl u-boot-sunxi-with-spl.bin' command for loading and executing the SPL works fine without CONFIG_SPL_FEL defined (because the SD card specific eGON.BT0 signature is replaced with the eGON.FEL signature by the 'fel' tool in the device memory before transferring control to the SPL code). Needless to say that the SPL built this way still works when written to the SD card. And if CONFIG_SPL_FEL is defined, then the FEL support still works in a legacy way (via 'fel write 0x2000 u-boot-spl.bin; fel exe 0x2000'). We would only need to drop the legacy way in u-boot v2015.07 if the new one proves to be problem free by that time :-) So you mean that we can drop CONFIG_SPL_FEL? Yes, we can already do this. But in order to play safe, the CONFIG_SPL_FEL option could be still kept for
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Hi Siarhei, On 10 February 2015 at 20:05, Siarhei Siamashka siarhei.siamas...@gmail.com wrote: On Mon, 9 Feb 2015 15:23:17 -0700 Simon Glass s...@chromium.org wrote: Hi Siarhei, On 7 February 2015 at 20:48, Siarhei Siamashka siarhei.siamas...@gmail.com wrote: On Sat, 7 Feb 2015 10:47:30 -0700 Simon Glass s...@chromium.org wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL Thanks for working on these patches. It looks like we are finally getting really close to resolving the sunxi FEL boot problem. Some comments are below. arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) Maybe we can just update the 'save_boot_params' function to save the important configuration registers and then undo this configuration in 'return_to_fel'? This allows us to avoid the sunxi specific ifdefs in the core ARM code. In this particular case, restoring VBAR and CPSR is important because the BROM code uses an IRQ handler for FEL (presumably USB related). And we want to ensure that this IRQ handler works properly again after resuming the FEL code. We could indeed. It would avoid the #ifdef but my understanding is that you might be able to avoid having to 'return' to the BROM through another means. In any case we could perhaps leave that change until the next release? I just previously thought that the FEL tool could store the return address somewhere in beginning of SRAM in the eGON header extension. In this case, restoring the 'lr' and 'sp' registers would be unnecessary and the use of the 'save_boot_params' function could be dropped. But if we still need to save/restore VBAR and the other control registers, then this idea about not saving 'lr' and 'sp' does not really improve anything. OK I see see. [...] u32 spl_boot_device(void) { + /* + * Have we been asked to return to the FEL portion of the boot ROM? + * TODO: We need a more robust test here, or bracket this with + * #ifdef CONFIG_SPL_FEL. + */ + if (fel_stash.lr = 0x fel_stash.lr 0x4000) + return BOOT_DEVICE_BOARD; return BOOT_DEVICE_MMC1; It is probably better to do it this way: #ifdef CONFIG_SPL_FEL return BOOT_DEVICE_BOARD; #else if (memcmp((void *)4, eGON.BT0, 8) == 0) return BOOT_DEVICE_MMC1; else return BOOT_DEVICE_BOARD; #endif The memcmp (or equivalent code) ensures that it is compatible with https://github.com/ssvb/sunxi-tools/commit/aa7e1880986e5c9a825b08aed9dc5621b821805f Then the new 'fel spl u-boot-sunxi-with-spl.bin' command for loading and executing the SPL works fine without CONFIG_SPL_FEL defined (because the SD card specific eGON.BT0 signature is replaced with the eGON.FEL signature by the 'fel' tool in the device memory before transferring control to the SPL code). Needless to say that the SPL built this way still works when written to the SD card. And if CONFIG_SPL_FEL is defined, then the FEL support still works in a legacy way (via 'fel write 0x2000 u-boot-spl.bin; fel exe 0x2000'). We would only need to drop the legacy way in u-boot v2015.07 if the new one proves to be problem free by that time :-) So you mean that we can drop
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Hi Siarhei, On 7 February 2015 at 20:48, Siarhei Siamashka siarhei.siamas...@gmail.com wrote: On Sat, 7 Feb 2015 10:47:30 -0700 Simon Glass s...@chromium.org wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL Thanks for working on these patches. It looks like we are finally getting really close to resolving the sunxi FEL boot problem. Some comments are below. arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) Maybe we can just update the 'save_boot_params' function to save the important configuration registers and then undo this configuration in 'return_to_fel'? This allows us to avoid the sunxi specific ifdefs in the core ARM code. In this particular case, restoring VBAR and CPSR is important because the BROM code uses an IRQ handler for FEL (presumably USB related). And we want to ensure that this IRQ handler works properly again after resuming the FEL code. We could indeed. It would avoid the #ifdef but my understanding is that you might be able to avoid having to 'return' to the BROM through another means. In any case we could perhaps leave that change until the next release? /* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */ mrc p15, 0, r0, c1, c0, 0 @ Read CP15 SCTLR Register bic r0, #CR_V @ V = 0 @@ -67,7 +68,9 @@ save_boot_params_ret: /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT +#ifndef CONFIG_SPL_FEL Same here. bl cpu_init_cp15 +#endif bl cpu_init_crit #endif diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile index 48db744..c1b975a 100644 --- a/arch/arm/cpu/armv7/sunxi/Makefile +++ b/arch/arm/cpu/armv7/sunxi/Makefile @@ -38,7 +38,5 @@ obj-$(CONFIG_MACH_SUN5I)+= dram_sun4i.o obj-$(CONFIG_MACH_SUN6I) += dram_sun6i.o obj-$(CONFIG_MACH_SUN7I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN8I) += dram_sun8i.o -ifdef CONFIG_SPL_FEL -obj-y+= start.o -endif +obj-y+= fel_utils.o endif diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 6e28bcd..b7492ac 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -27,6 +27,13 @@ #include linux/compiler.h +struct fel_stash { + uint32_t sp; + uint32_t lr; +}; struct fel_stash { uint32_t sp; uint32_t lr; uint32_t cpsr; uint32_t sctlr; uint32_t vbar; uint32_t cr; }; +struct fel_stash fel_stash __attribute__((section(.data))); + static int gpio_init(void) { #if CONFIG_CONS_INDEX == 1 defined(CONFIG_UART0_PORT_F) @@ -65,6 +72,12 @@ static int gpio_init(void) return 0; } +void spl_board_load_image(void) +{ + debug(Returning to FEL sp=%x, lr=%x\n, fel_stash.sp, fel_stash.lr); + return_to_fel(fel_stash.sp, fel_stash.lr); +} + void s_init(void) { #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I @@ -95,6 +108,14 @@ void s_init(void) */ u32 spl_boot_device(void) { + /* + * Have we been asked to return to the FEL portion of the boot ROM? + * TODO: We need a more robust test here, or bracket this with + * #ifdef CONFIG_SPL_FEL. + */ + if (fel_stash.lr = 0x fel_stash.lr
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Hi, On 02/07/2015 06:47 PM, Simon Glass wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. About the #ifdefs, I would really like to see us move to having 1 unified loader for sunxi, which means getting rid of them. Even though we do use a label to return from save_boot_params, save_boot_params could still use r0 to return stuff, like you did in your previous patch-set, or we could add a global variable to start.S which lives in .data and gets initialized with 0, and save_boot_params could optionally save some skip flags there. Note this dropping of #ifdefs can wait till after v2015.04, for now this patch-set should get fel mode working as before which is the goal for v2015.04. Regards, Hans This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) /* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */ mrc p15, 0, r0, c1, c0, 0 @ Read CP15 SCTLR Register bic r0, #CR_V @ V = 0 @@ -67,7 +68,9 @@ save_boot_params_ret: /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT +#ifndef CONFIG_SPL_FEL bl cpu_init_cp15 +#endif bl cpu_init_crit #endif diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile index 48db744..c1b975a 100644 --- a/arch/arm/cpu/armv7/sunxi/Makefile +++ b/arch/arm/cpu/armv7/sunxi/Makefile @@ -38,7 +38,5 @@ obj-$(CONFIG_MACH_SUN5I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN6I) += dram_sun6i.o obj-$(CONFIG_MACH_SUN7I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN8I) += dram_sun8i.o -ifdef CONFIG_SPL_FEL -obj-y += start.o -endif +obj-y += fel_utils.o endif diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 6e28bcd..b7492ac 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -27,6 +27,13 @@ #include linux/compiler.h +struct fel_stash { + uint32_t sp; + uint32_t lr; +}; + +struct fel_stash fel_stash __attribute__((section(.data))); + static int gpio_init(void) { #if CONFIG_CONS_INDEX == 1 defined(CONFIG_UART0_PORT_F) @@ -65,6 +72,12 @@ static int gpio_init(void) return 0; } +void spl_board_load_image(void) +{ + debug(Returning to FEL sp=%x, lr=%x\n, fel_stash.sp, fel_stash.lr); + return_to_fel(fel_stash.sp, fel_stash.lr); +} + void s_init(void) { #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I @@ -95,6 +108,14 @@ void s_init(void) */ u32 spl_boot_device(void) { + /* +* Have we been asked to return to the FEL portion of the boot ROM? +* TODO: We need a more robust test here, or bracket this with +* #ifdef CONFIG_SPL_FEL. +*/ + if (fel_stash.lr = 0x fel_stash.lr 0x4000) + return BOOT_DEVICE_BOARD; + return BOOT_DEVICE_MMC1; } diff --git a/arch/arm/cpu/armv7/sunxi/config.mk b/arch/arm/cpu/armv7/sunxi/config.mk index 00f5ffc..76ffec9 100644 --- a/arch/arm/cpu/armv7/sunxi/config.mk +++ b/arch/arm/cpu/armv7/sunxi/config.mk @@ -1,8 +1,6 @@ # Build a combined spl + u-boot image ifdef CONFIG_SPL ifndef CONFIG_SPL_BUILD -ifndef CONFIG_SPL_FEL ALL-y += u-boot-sunxi-with-spl.bin endif endif -endif diff --git a/arch/arm/cpu/armv7/sunxi/fel_utils.S b/arch/arm/cpu/armv7/sunxi/fel_utils.S new file
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Hi Hans, On 7 February 2015 at 10:59, Hans de Goede hdego...@redhat.com wrote: Hi, On 02/07/2015 06:47 PM, Simon Glass wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. About the #ifdefs, I would really like to see us move to having 1 unified loader for sunxi, which means getting rid of them. Even though we do use a label to return from save_boot_params, save_boot_params could still use r0 to return stuff, like you did in your previous patch-set, or we could add a global variable to start.S which lives in .data and gets initialized with 0, and save_boot_params could optionally save some skip flags there. Note this dropping of #ifdefs can wait till after v2015.04, for now this patch-set should get fel mode working as before which is the goal for v2015.04. OK. It's just as easy for me to do this now, but Albert was not keen on doing this at run-time. So if you can remove the #ifdefs by calling back into the BROM that would probably be better. For now I think Albert prefers the #ifdefs. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- [snip] Regards, Simon ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
[U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) /* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */ mrc p15, 0, r0, c1, c0, 0 @ Read CP15 SCTLR Register bic r0, #CR_V @ V = 0 @@ -67,7 +68,9 @@ save_boot_params_ret: /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT +#ifndef CONFIG_SPL_FEL bl cpu_init_cp15 +#endif bl cpu_init_crit #endif diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile index 48db744..c1b975a 100644 --- a/arch/arm/cpu/armv7/sunxi/Makefile +++ b/arch/arm/cpu/armv7/sunxi/Makefile @@ -38,7 +38,5 @@ obj-$(CONFIG_MACH_SUN5I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN6I) += dram_sun6i.o obj-$(CONFIG_MACH_SUN7I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN8I) += dram_sun8i.o -ifdef CONFIG_SPL_FEL -obj-y += start.o -endif +obj-y += fel_utils.o endif diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 6e28bcd..b7492ac 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -27,6 +27,13 @@ #include linux/compiler.h +struct fel_stash { + uint32_t sp; + uint32_t lr; +}; + +struct fel_stash fel_stash __attribute__((section(.data))); + static int gpio_init(void) { #if CONFIG_CONS_INDEX == 1 defined(CONFIG_UART0_PORT_F) @@ -65,6 +72,12 @@ static int gpio_init(void) return 0; } +void spl_board_load_image(void) +{ + debug(Returning to FEL sp=%x, lr=%x\n, fel_stash.sp, fel_stash.lr); + return_to_fel(fel_stash.sp, fel_stash.lr); +} + void s_init(void) { #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I @@ -95,6 +108,14 @@ void s_init(void) */ u32 spl_boot_device(void) { + /* +* Have we been asked to return to the FEL portion of the boot ROM? +* TODO: We need a more robust test here, or bracket this with +* #ifdef CONFIG_SPL_FEL. +*/ + if (fel_stash.lr = 0x fel_stash.lr 0x4000) + return BOOT_DEVICE_BOARD; + return BOOT_DEVICE_MMC1; } diff --git a/arch/arm/cpu/armv7/sunxi/config.mk b/arch/arm/cpu/armv7/sunxi/config.mk index 00f5ffc..76ffec9 100644 --- a/arch/arm/cpu/armv7/sunxi/config.mk +++ b/arch/arm/cpu/armv7/sunxi/config.mk @@ -1,8 +1,6 @@ # Build a combined spl + u-boot image ifdef CONFIG_SPL ifndef CONFIG_SPL_BUILD -ifndef CONFIG_SPL_FEL ALL-y += u-boot-sunxi-with-spl.bin endif endif -endif diff --git a/arch/arm/cpu/armv7/sunxi/fel_utils.S b/arch/arm/cpu/armv7/sunxi/fel_utils.S new file mode 100644 index 000..0c1de52 --- /dev/null +++ b/arch/arm/cpu/armv7/sunxi/fel_utils.S @@ -0,0 +1,25 @@ +/* + * Utility functions for FEL mode. + * + * Copyright (c) 2015 Google, Inc + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include asm-offsets.h +#include config.h +#include asm/system.h +#include linux/linkage.h + +ENTRY(save_boot_params) + ldr r0, =fel_stash + str sp, [r0, #0] + str lr, [r0, #4] + b save_boot_params_ret +ENDPROC(save_boot_params) + +ENTRY(return_to_fel) + mov sp, r0 + mov lr, r1 + bx lr +ENDPROC(return_to_fel) diff --git a/arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
On Sat, 7 Feb 2015 10:47:30 -0700 Simon Glass s...@chromium.org wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. This series is available at u-boot-dm, branch sunxi-working. Signed-off-by: Simon Glass s...@chromium.org --- Changes in v2: - Adjust for new save_boot_params() API - Drop patch to change r0 to r2 in start.S - Add #ifdefs to start.S to deal with FEL - Use 'Fast Early Loader' as the full name for FEL Thanks for working on these patches. It looks like we are finally getting really close to resolving the sunxi FEL boot problem. Some comments are below. arch/arm/cpu/armv7/start.S | 5 +- arch/arm/cpu/armv7/sunxi/Makefile | 4 +- arch/arm/cpu/armv7/sunxi/board.c| 21 arch/arm/cpu/armv7/sunxi/config.mk | 2 - arch/arm/cpu/armv7/sunxi/fel_utils.S| 25 + arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds | 82 - arch/arm/include/asm/arch-sunxi/sys_proto.h | 10 board/sunxi/Kconfig | 10 include/configs/sunxi-common.h | 6 +-- scripts/Makefile.spl| 2 - 10 files changed, 73 insertions(+), 94 deletions(-) create mode 100644 arch/arm/cpu/armv7/sunxi/fel_utils.S delete mode 100644 arch/arm/cpu/armv7/sunxi/u-boot-spl-fel.lds diff --git a/arch/arm/cpu/armv7/start.S b/arch/arm/cpu/armv7/start.S index 9b49ece..098a83a 100644 --- a/arch/arm/cpu/armv7/start.S +++ b/arch/arm/cpu/armv7/start.S @@ -54,7 +54,8 @@ save_boot_params_ret: * (OMAP4 spl TEXT_BASE is not 32 byte aligned. * Continue to use ROM code vector only in OMAP4 spl) */ -#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) +#if !(defined(CONFIG_OMAP44XX) defined(CONFIG_SPL_BUILD)) \ + !defined(CONFIG_SPL_FEL) Maybe we can just update the 'save_boot_params' function to save the important configuration registers and then undo this configuration in 'return_to_fel'? This allows us to avoid the sunxi specific ifdefs in the core ARM code. In this particular case, restoring VBAR and CPSR is important because the BROM code uses an IRQ handler for FEL (presumably USB related). And we want to ensure that this IRQ handler works properly again after resuming the FEL code. /* Set V=0 in CP15 SCTLR register - for VBAR to point to vector */ mrc p15, 0, r0, c1, c0, 0 @ Read CP15 SCTLR Register bic r0, #CR_V @ V = 0 @@ -67,7 +68,9 @@ save_boot_params_ret: /* the mask ROM code should have PLL and others stable */ #ifndef CONFIG_SKIP_LOWLEVEL_INIT +#ifndef CONFIG_SPL_FEL Same here. bl cpu_init_cp15 +#endif bl cpu_init_crit #endif diff --git a/arch/arm/cpu/armv7/sunxi/Makefile b/arch/arm/cpu/armv7/sunxi/Makefile index 48db744..c1b975a 100644 --- a/arch/arm/cpu/armv7/sunxi/Makefile +++ b/arch/arm/cpu/armv7/sunxi/Makefile @@ -38,7 +38,5 @@ obj-$(CONFIG_MACH_SUN5I)+= dram_sun4i.o obj-$(CONFIG_MACH_SUN6I) += dram_sun6i.o obj-$(CONFIG_MACH_SUN7I) += dram_sun4i.o obj-$(CONFIG_MACH_SUN8I) += dram_sun8i.o -ifdef CONFIG_SPL_FEL -obj-y+= start.o -endif +obj-y+= fel_utils.o endif diff --git a/arch/arm/cpu/armv7/sunxi/board.c b/arch/arm/cpu/armv7/sunxi/board.c index 6e28bcd..b7492ac 100644 --- a/arch/arm/cpu/armv7/sunxi/board.c +++ b/arch/arm/cpu/armv7/sunxi/board.c @@ -27,6 +27,13 @@ #include linux/compiler.h +struct fel_stash { + uint32_t sp; + uint32_t lr; +}; struct fel_stash { uint32_t sp; uint32_t lr; uint32_t cpsr; uint32_t sctlr; uint32_t vbar; uint32_t cr; }; +struct fel_stash fel_stash __attribute__((section(.data))); + static int gpio_init(void) { #if CONFIG_CONS_INDEX == 1 defined(CONFIG_UART0_PORT_F) @@ -65,6 +72,12 @@ static int gpio_init(void) return 0; } +void spl_board_load_image(void) +{ + debug(Returning to FEL sp=%x, lr=%x\n, fel_stash.sp, fel_stash.lr); + return_to_fel(fel_stash.sp, fel_stash.lr); +} + void s_init(void) { #if defined CONFIG_MACH_SUN6I || defined CONFIG_MACH_SUN8I @@ -95,6 +108,14 @@ void s_init(void) */ u32 spl_boot_device(void) { + /* + * Have we been asked to return to the FEL portion of the boot ROM? + * TODO: We need a more robust test here, or bracket this with + * #ifdef CONFIG_SPL_FEL. + */ + if (fel_stash.lr = 0x fel_stash.lr 0x4000) + return BOOT_DEVICE_BOARD; return BOOT_DEVICE_MMC1; It is probably better to do it this way: #ifdef CONFIG_SPL_FEL return BOOT_DEVICE_BOARD; #else if (memcmp((void *)4, eGON.BT0, 8) == 0) return BOOT_DEVICE_MMC1; else return
Re: [U-Boot] [PATCH v2 3/3] sunxi: Normalise FEL support
Hi, On 02/07/2015 07:02 PM, Simon Glass wrote: Hi Hans, On 7 February 2015 at 10:59, Hans de Goede hdego...@redhat.com wrote: Hi, On 02/07/2015 06:47 PM, Simon Glass wrote: Make sunxi's FEL code fit with the normal U-Boot boot sequence instead of creating its own. There are some #ifdefs required in start.S. Future work will hopefully remove these. About the #ifdefs, I would really like to see us move to having 1 unified loader for sunxi, which means getting rid of them. Even though we do use a label to return from save_boot_params, save_boot_params could still use r0 to return stuff, like you did in your previous patch-set, or we could add a global variable to start.S which lives in .data and gets initialized with 0, and save_boot_params could optionally save some skip flags there. Note this dropping of #ifdefs can wait till after v2015.04, for now this patch-set should get fel mode working as before which is the goal for v2015.04. OK. It's just as easy for me to do this now, but Albert was not keen on doing this at run-time. So if you can remove the #ifdefs by calling back into the BROM that would probably be better. Calling back into the BROm, rather then returning into it means that usb needs to get re-initialized and the usb-host will see a usb disconnect / reconnect, which is not really pretty, so I would like to avoid that, and instead use something like your proposed runtime checking with flags For now I think Albert prefers the #ifdefs. #ifdefs are fine for v2015.04, but for v2015.07 I really believe we need something runtime so that we can move to one unified loader for sunxi. Albert can you give us some guidance on how we can best implement runtime checks like the ones which Simon did with flags stored in r0 in his initial patch-set ? Regards, Hans ___ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot