Skip to contentSkip to conversation

TI ARMv7: Don't use GD before crt0.S has set it

PATCH New Tom Rini 3 participants 7 messages Dec 19, 2014 – Jan 20, 2015 Arm (32-bit)

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/2 TI ARMv7: Don't use GD before crt0.S has set it

Prior to this change we set the gd pointer early so that we can store data in it. This becomes problematic for DM changes as well as being odd in general. Re-work the code paths so that we don't need to set the gd pointer so early and instead can rely upon the normal setting of it.

In order to do this we do need to move certain calls from s_init into spl_board_init(), mainly preloader_console_init and save_omap_boot_params.

Tested on: Beaglebone Black, AM43xx GP EVM, Beagleboard, Beagleboard xM, OMAP5 uEVM, DRA7xx EVM

---
 arch/arm/cpu/armv7/am33xx/board.c              |   11 -----------
 arch/arm/cpu/armv7/omap-common/boot-common.c   |   10 ++++++++++
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |   11 -----------
 arch/arm/cpu/armv7/omap3/board.c               |    9 +--------
 4 files changed, 11 insertions(+), 30 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +0 -11
index eaf09d1..81477aa 100644
@@ -285,14 +285,6 @@ void s_init(void)
 #ifdef CONFIG_NOR_BOOT
 	enable_norboot_pin_mux();
 #endif
-	/*
-	 * Save the boot parameters passed from romcode.
-	 * We cannot delay the saving further than this,
-	 * to prevent overwrites.
-	 */
-#ifdef CONFIG_SPL_BUILD
-	save_omap_boot_params();
-#endif
 	watchdog_disable();
 	set_uart_mux_conf();
 	setup_clocks_for_console();
@@ -301,9 +293,6 @@ void s_init(void)
 	gd->baudrate = CONFIG_BAUDRATE;
 	serial_init();
 	gd->have_console = 1;
-#elif defined(CONFIG_SPL_BUILD)
-	gd = &gdata;
-	preloader_console_init();
 #endif
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
 	/* Enable RTC32K clock */
arch/arm/cpu/armv7/omap-common/boot-common.c +10 -0
index cb18908..3ba62db 100644
@@ -104,6 +104,16 @@ u32 spl_boot_mode(void)
 
 void spl_board_init(void)
 {
+	/*
+	 * Save the boot parameters passed from romcode.
+	 * We cannot delay the saving further than this,
+	 * to prevent overwrites.
+	 */
+	save_omap_boot_params();
+
+	/* Prepare console output */
+	preloader_console_init();
+
 #ifdef CONFIG_SPL_NAND_SUPPORT
 	gpmc_init();
 #endif
arch/arm/cpu/armv7/omap-common/hwinit-common.c +0 -11
index dd52e93..cb35c19 100644
@@ -111,14 +111,6 @@ int arch_cpu_init(void)
  */
 void s_init(void)
 {
-	/*
-	 * Save the boot parameters passed from romcode.
-	 * We cannot delay the saving further than this,
-	 * to prevent overwrites.
-	 */
-#ifdef CONFIG_SPL_BUILD
-	save_omap_boot_params();
-#endif
 	init_omap_revision();
 	hw_data_init();
 
@@ -133,9 +125,6 @@ void s_init(void)
 	srcomp_enable();
 	setup_clocks_for_console();
 
-	gd = &gdata;
-
-	preloader_console_init();
 	do_io_settings();
 #endif
 	prcm_init();
arch/arm/cpu/armv7/omap3/board.c +1 -8
index 53a9e5d..90d6ae7 100644
@@ -119,6 +119,7 @@ int board_mmc_init(bd_t *bis)
 
 void spl_board_init(void)
 {
+	preloader_console_init();
 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
 	gpmc_init();
 #endif
@@ -264,14 +265,6 @@ void s_init(void)
 	ehci_clocks_enable();
 #endif
 
-#ifdef CONFIG_SPL_BUILD
-	gd = &gdata;
-
-	preloader_console_init();
-
-	timer_init();
-#endif
-
 	if (!in_sdram)
 		mem_init();
 }
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/2 TI ARMv7: Don't use GD before crt0.S has set it

Quoted 9 lines · Tom Rini

Prior to this change we set the gd pointer early so that we can store data in it. This becomes problematic for DM changes as well as being odd in general. Re-work the code paths so that we don't need to set the gd pointer so early and instead can rely upon the normal setting of it.

In order to do this we do need to move certain calls from s_init into spl_board_init(), mainly preloader_console_init and save_omap_boot_params.

Quoted 5 lines

Tested on: Beaglebone Black, AM43xx GP EVM, Beagleboard, Beagleboard xM, OMAP5 uEVM, DRA7xx EVM

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150120/a54655d0/attachment.pgp>
#2 lore raw

PATCH 1/2 TI ARMv7: Don't use GD before crt0.S has set it

In reply to Tom Rini

Hi Tom,

Quoted 5 lines · Tom Rini

Prior to this change we set the gd pointer early so that we can store data in it. This becomes problematic for DM changes as well as being odd in general. Re-work the code paths so that we don't need to set the gd pointer so early and instead can rely upon the normal setting of it.

Quoted 7 lines

In order to do this we do need to move certain calls from s_init into spl_board_init(), mainly preloader_console_init and save_omap_boot_params.

Tested on: Beaglebone Black, AM43xx GP EVM, Beagleboard, Beagleboard xM, OMAP5 uEVM, DRA7xx EVM

This seems like it's going in the right direction to me!

Tested on Beaglebone Black.

Quoted 120 lines
---
 arch/arm/cpu/armv7/am33xx/board.c              |   11 -----------
 arch/arm/cpu/armv7/omap-common/boot-common.c   |   10 ++++++++++
 arch/arm/cpu/armv7/omap-common/hwinit-common.c |   11 -----------
 arch/arm/cpu/armv7/omap3/board.c               |    9 +--------
 4 files changed, 11 insertions(+), 30 deletions(-)
arch/arm/cpu/armv7/am33xx/board.c +0 -11
index eaf09d1..81477aa 100644
@@ -285,14 +285,6 @@ void s_init(void)
 #ifdef CONFIG_NOR_BOOT
        enable_norboot_pin_mux();
 #endif
-       /*
-        * Save the boot parameters passed from romcode.
-        * We cannot delay the saving further than this,
-        * to prevent overwrites.
-        */
-#ifdef CONFIG_SPL_BUILD
-       save_omap_boot_params();
-#endif
        watchdog_disable();
        set_uart_mux_conf();
        setup_clocks_for_console();
@@ -301,9 +293,6 @@ void s_init(void)
        gd->baudrate = CONFIG_BAUDRATE;
        serial_init();
        gd->have_console = 1;
-#elif defined(CONFIG_SPL_BUILD)
-       gd = &gdata;
-       preloader_console_init();
 #endif
 #if defined(CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC)
        /* Enable RTC32K clock */
arch/arm/cpu/armv7/omap-common/boot-common.c +10 -0
index cb18908..3ba62db 100644
@@ -104,6 +104,16 @@ u32 spl_boot_mode(void)
 
 void spl_board_init(void)
 {
+       /*
+        * Save the boot parameters passed from romcode.
+        * We cannot delay the saving further than this,
+        * to prevent overwrites.
+        */
+       save_omap_boot_params();
+
+       /* Prepare console output */
+       preloader_console_init();
+
 #ifdef CONFIG_SPL_NAND_SUPPORT
        gpmc_init();
 #endif
arch/arm/cpu/armv7/omap-common/hwinit-common.c +0 -11
index dd52e93..cb35c19 100644
@@ -111,14 +111,6 @@ int arch_cpu_init(void)
  */
 void s_init(void)
 {
-       /*
-        * Save the boot parameters passed from romcode.
-        * We cannot delay the saving further than this,
-        * to prevent overwrites.
-        */
-#ifdef CONFIG_SPL_BUILD
-       save_omap_boot_params();
-#endif
        init_omap_revision();
        hw_data_init();
 
@@ -133,9 +125,6 @@ void s_init(void)
        srcomp_enable();
        setup_clocks_for_console();
 
-       gd = &gdata;
-
-       preloader_console_init();
        do_io_settings();
 #endif
        prcm_init();
arch/arm/cpu/armv7/omap3/board.c +1 -9
index 53a9e5d..90d6ae7 100644
@@ -119,6 +119,7 @@ int board_mmc_init(bd_t *bis)
 
 void spl_board_init(void)
 {
+       preloader_console_init();
 #if defined(CONFIG_SPL_NAND_SUPPORT) || defined(CONFIG_SPL_ONENAND_SUPPORT)
        gpmc_init();
 #endif
@@ -264,14 +265,6 @@ void s_init(void)
        ehci_clocks_enable();
 #endif
 
-#ifdef CONFIG_SPL_BUILD
-       gd = &gdata;
-
-       preloader_console_init();
-
-       timer_init();
-#endif
-
        if (!in_sdram)
                mem_init();
 }
--

1.7.9.5

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

author
#3 lore raw

PATCH 2/2 davinci: Do not duplicate setting of gd

In reply to Tom Rini

In f0c3a6c we stopped setting gd in board_init_f, but later had to revert to due problems on certain platforms. As davinci does not look to have these problems, we can drop the setting here and rely upon crt0.S to do it.

Cc Peter Howard <[email protected]>

---
Peter, I don't have my davinci board hooked up but since you were doing some changes recently is there a chance you can test this easily? Thanks!

---
 arch/arm/cpu/arm926ejs/davinci/spl.c |    1 -
 1 file changed, 1 deletion(-)
arch/arm/cpu/arm926ejs/davinci/spl.c +0 -1
index 59b304e..7b14420 100644
@@ -51,7 +51,6 @@ void board_init_f(ulong dummy)
 	memset(__bss_start, 0, __bss_end - __bss_start);
 
 	/* Finally, setup gd and move to the next step. */
-	gd = &gdata;
 	board_init_r(NULL, 0);
 }
 
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH 2/2 davinci: Do not duplicate setting of gd

Quoted 11 lines · Tom Rini

In f0c3a6c we stopped setting gd in board_init_f, but later had to revert to due problems on certain platforms. As davinci does not look to have these problems, we can drop the setting here and rely upon crt0.S to do it.

Cc Peter Howard <[email protected]>

---
Peter, I don't have my davinci board hooked up but since you were doing some changes recently is there a chance you can test this easily?

I can test on Monday - I only have access to my LCDK on the weekend, and I have to get round to try the convoluted setup process for flashing u-boot on it :-)

Quoted 17 lines

Thanks!

---
 arch/arm/cpu/arm926ejs/davinci/spl.c |    1 -
 1 file changed, 1 deletion(-)
arch/arm/cpu/arm926ejs/davinci/spl.c +0 -1
index 59b304e..7b14420 100644
@@ -51,7 +51,6 @@ void board_init_f(ulong dummy)
 	memset(__bss_start, 0, __bss_end - __bss_start);
 
 	/* Finally, setup gd and move to the next step. */
-	gd = &gdata;
 	board_init_r(NULL, 0);
 }
 
#5 lore raw

PATCH 2/2 davinci: Do not duplicate setting of gd

In reply to Tom Rini
Quoted 5 lines · Tom Rini

In f0c3a6c we stopped setting gd in board_init_f, but later had to revert to due problems on certain platforms. As davinci does not look to have these problems, we can drop the setting here and rely upon crt0.S to do it.

Quoted 7 lines
Cc Peter Howard <[email protected]>

---
Peter, I don't have my davinci board hooked up but since you were doing some changes recently is there a chance you can test this easily? Thanks!

Applied this patch (with and without 1/1 as well - given part 1 is ARMv7 it shouldn't have any bearing on davinci but wanted to be sure).

U-boot doesn't boot on the da850evm with this change. I tried both with my changes to the generic board, and on a fresh clone of u-boot.git. And on u-boot-ti.git. I haven't looked further, but I'm guessing there is early access to gd of the sort you patched out for v7.

Quoted 16 lines
---
 arch/arm/cpu/arm926ejs/davinci/spl.c |    1 -
 1 file changed, 1 deletion(-)
arch/arm/cpu/arm926ejs/davinci/spl.c +0 -1
index 59b304e..7b14420 100644
@@ -51,7 +51,6 @@ void board_init_f(ulong dummy)
 	memset(__bss_start, 0, __bss_end - __bss_start);
 
 	/* Finally, setup gd and move to the next step. */
-	gd = &gdata;
 	board_init_r(NULL, 0);
 }
 
Signature · 1 line
Peter Howard <[email protected]>
author
#6 lore raw

PATCH 2/2 davinci: Do not duplicate setting of gd

Quoted 14 lines · Peter Howard
Quoted 5 lines · Tom Rini

In f0c3a6c we stopped setting gd in board_init_f, but later had to revert to due problems on certain platforms. As davinci does not look to have these problems, we can drop the setting here and rely upon crt0.S to do it.

Quoted 7 lines
Cc Peter Howard <[email protected]>

---
Peter, I don't have my davinci board hooked up but since you were doing some changes recently is there a chance you can test this easily? Thanks!

Quoted 7 lines

Applied this patch (with and without 1/1 as well - given part 1 is ARMv7 it shouldn't have any bearing on davinci but wanted to be sure).

U-boot doesn't boot on the da850evm with this change. I tried both with my changes to the generic board, and on a fresh clone of u-boot.git. And on u-boot-ti.git. I haven't looked further, but I'm guessing there is early access to gd of the sort you patched out for v7.

Thanks for testing, I feared it wasn't quite as easy as it looked, I'll have a think about it and see if I can recall what else might be tickling gd that early over there.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20141221/bc48543b/attachment.pgp>