Patchwork [U-Boot,3/3] ppc4xx: fix PMC440 painit command

login
register
mail settings
Submitter Matthias Fuchs
Date Oct. 13, 2011, 1:12 p.m.
Message ID <13185115443174-git-send-email-matthias.fuchs@esd.eu>
Download mbox | patch
Permalink /patch/119494/
State Superseded
Delegated to: Stefan Roese
Headers show

Comments

Matthias Fuchs - Oct. 13, 2011, 1:12 p.m.
From: Matthias Fuchs <matthias.fuchs@esd.eu>

This patch fixes the PMC440 BSP command painit. The implementation was
broken since the step to the new environment handling.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd.eu>
---
 board/esd/pmc440/cmd_pmc440.c |   17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)
Stefan Roese - Nov. 22, 2011, 7:33 a.m.
Hi Matthias,

On Thursday 13 October 2011 15:12:24 matthias.fuchs@esd.eu wrote:
> From: Matthias Fuchs <matthias.fuchs@esd.eu>
> 
> This patch fixes the PMC440 BSP command painit. The implementation was
> broken since the step to the new environment handling.

After applying this patch to the latest U-Boot version I get the following 
error:

[stefan@kubuntu u-boot-ppc4xx (master)]$ ./MAKEALL PMC440 
Configuring for PMC440 board...
cmd_pmc440.c: In function 'do_painit':
cmd_pmc440.c:394: error: too few arguments to function 'hexport_r'
make[1]: *** [cmd_pmc440.o] Error 1

Seems that the hexport_r() API has changed. Could you please take a look and 
resubmit.

Thanks.
 
Best regards,
Stefan

--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office@denx.de

Patch

diff --git a/board/esd/pmc440/cmd_pmc440.c b/board/esd/pmc440/cmd_pmc440.c
index 200d7ee..3bcf2b0 100644
--- a/board/esd/pmc440/cmd_pmc440.c
+++ b/board/esd/pmc440/cmd_pmc440.c
@@ -342,7 +342,8 @@  U_BOOT_CMD(
 
 #if defined(CONFIG_PRAM)
 #include <environment.h>
-extern env_t *env_ptr;
+#include <search.h>
+#include <errno.h>
 
 int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
@@ -351,6 +352,10 @@  int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	u32 param;
 	ulong *lptr;
 
+	env_t *envp;
+	char *res;
+	int len;
+
 	v = getenv("pram");
 	if (v)
 		pram = simple_strtoul(v, NULL, 10);
@@ -384,7 +389,15 @@  int do_painit(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* env is first (4k aligned) */
 	nextbase -= ((CONFIG_ENV_SIZE + 4096 - 1) & ~(4096 - 1));
-	memcpy((void*)nextbase, env_ptr, CONFIG_ENV_SIZE);
+	envp = (env_t *)nextbase;
+	res = (char *)envp->data;
+	len = hexport_r(&env_htab, '\0', &res, ENV_SIZE);
+        if (len < 0) {
+                error("Cannot export environment: errno = %d\n", errno);
+                return 1;
+        }
+	envp->crc = crc32(0, envp->data, ENV_SIZE);
+
 	*(--lptr) = CONFIG_ENV_SIZE;     /* size */
 	*(--lptr) = base - nextbase;  /* offset | type=0 */