public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v1] ppc: Fix ppc4xx CONFIG_SYS_GENERIC_BOARD
@ 2014-11-03  9:56 dirk.eibach at gdsys.cc
  2014-11-05  9:24 ` Stefan Roese
  0 siblings, 1 reply; 2+ messages in thread
From: dirk.eibach at gdsys.cc @ 2014-11-03  9:56 UTC (permalink / raw)
  To: u-boot

From: Dirk Eibach <dirk.eibach@gdsys.cc>

I realized that with v2014.10 u-boot is not starting up on
ppc4xx boards with CONFIG_SYS_GENERIC_BOARD set.

I bisected it down to this:
d54d7eb support blackfin board initialization in generic board_f

With
d29437a ppc: Make ppc4xx ready for CONFIG_SYS_GENERIC_BOARD
I set gd to a defined value for ppc4xx in cpu_init_f().
I did not realize that the gd struct has also to be memset()
to zero at this point.

But at least commit d54d7eb assumes it is:
@@ -516,11 +528,13 @@ static int reserve_malloc(void)
 /* (permanently) allocate a Board Info struct */
 static int reserve_board(void)
 {
-	gd->start_addr_sp -= sizeof(bd_t);
-	gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
-	memset(gd->bd, '\0', sizeof(bd_t));
-	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
-			sizeof(bd_t), gd->start_addr_sp);
+	if (!gd->bd) {
+		gd->start_addr_sp -= sizeof(bd_t);
+		gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
+		memset(gd->bd, '\0', sizeof(bd_t));
+		debug("Reserving %zu Bytes for Board Info at: %08lx\n",
+		      sizeof(bd_t), gd->start_addr_sp);
+	}
 	return 0;
 }
 #endif

This might also be an issue on other architectures, so maintainers should
check.

Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
---

 arch/powerpc/cpu/ppc4xx/cpu_init.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/cpu/ppc4xx/cpu_init.c b/arch/powerpc/cpu/ppc4xx/cpu_init.c
index 2256123..e5a0e21 100644
--- a/arch/powerpc/cpu/ppc4xx/cpu_init.c
+++ b/arch/powerpc/cpu/ppc4xx/cpu_init.c
@@ -451,6 +451,9 @@ cpu_init_f (void)
 #endif /* CONFIG_440SP/SPE || CONFIG_460EX/GT || CONFIG_405EX */
 
 	gd = (gd_t *)(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET);
+
+	/* Clear initial global data */
+	memset((void *)gd, 0, sizeof(gd_t));
 }
 
 /*
-- 
1.8.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH v1] ppc: Fix ppc4xx CONFIG_SYS_GENERIC_BOARD
  2014-11-03  9:56 [U-Boot] [PATCH v1] ppc: Fix ppc4xx CONFIG_SYS_GENERIC_BOARD dirk.eibach at gdsys.cc
@ 2014-11-05  9:24 ` Stefan Roese
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Roese @ 2014-11-05  9:24 UTC (permalink / raw)
  To: u-boot

On 03.11.2014 10:56, dirk.eibach at gdsys.cc wrote:
> From: Dirk Eibach <dirk.eibach@gdsys.cc>
>
> I realized that with v2014.10 u-boot is not starting up on
> ppc4xx boards with CONFIG_SYS_GENERIC_BOARD set.
>
> I bisected it down to this:
> d54d7eb support blackfin board initialization in generic board_f
>
> With
> d29437a ppc: Make ppc4xx ready for CONFIG_SYS_GENERIC_BOARD
> I set gd to a defined value for ppc4xx in cpu_init_f().
> I did not realize that the gd struct has also to be memset()
> to zero at this point.
>
> But at least commit d54d7eb assumes it is:
> @@ -516,11 +528,13 @@ static int reserve_malloc(void)
>   /* (permanently) allocate a Board Info struct */
>   static int reserve_board(void)
>   {
> -	gd->start_addr_sp -= sizeof(bd_t);
> -	gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
> -	memset(gd->bd, '\0', sizeof(bd_t));
> -	debug("Reserving %zu Bytes for Board Info at: %08lx\n",
> -			sizeof(bd_t), gd->start_addr_sp);
> +	if (!gd->bd) {
> +		gd->start_addr_sp -= sizeof(bd_t);
> +		gd->bd = (bd_t *)map_sysmem(gd->start_addr_sp, sizeof(bd_t));
> +		memset(gd->bd, '\0', sizeof(bd_t));
> +		debug("Reserving %zu Bytes for Board Info at: %08lx\n",
> +		      sizeof(bd_t), gd->start_addr_sp);
> +	}
>   	return 0;
>   }
>   #endif
>
> This might also be an issue on other architectures, so maintainers should
> check.

Thanks Dirk for fixing this on ppc4xx. Applied to u-boot-ppc4xx/master.

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-11-05  9:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03  9:56 [U-Boot] [PATCH v1] ppc: Fix ppc4xx CONFIG_SYS_GENERIC_BOARD dirk.eibach at gdsys.cc
2014-11-05  9:24 ` Stefan Roese

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox