* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names
@ 2009-01-19 13:13 gvv at horse.lst.loc
2009-01-19 13:05 ` Jean-Christophe PLAGNIOL-VILLARD
0 siblings, 1 reply; 6+ messages in thread
From: gvv at horse.lst.loc @ 2009-01-19 13:13 UTC (permalink / raw)
To: u-boot
When U-boot starting from NAND the pointers to chip names are set before relocation.
If the original memory block is overwritten after relocation that led to invalid
string data in the nand utility.
Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
---
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index b94a2bf..14925cd 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -10,6 +10,7 @@
#include <common.h>
+DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_NAND_LEGACY
/*
@@ -193,7 +194,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
if (nand_info[i].name)
printf("Device %d: %s, sector size %u KiB\n",
- i, nand_info[i].name,
+ i, nand_info[i].name + gd->reloc_off,
nand_info[i].erasesize >> 10);
}
return 0;
@@ -207,7 +208,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("\nno devices available\n");
else
printf("\nDevice %d: %s\n", nand_curr_device,
- nand_info[nand_curr_device].name);
+ nand_info[nand_curr_device].name + gd->reloc_off);
return 0;
}
dev = (int)simple_strtoul(argv[2], NULL, 10);
@@ -215,7 +216,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("No such device\n");
return 1;
}
- printf("Device %d: %s", dev, nand_info[dev].name);
+ printf("Device %d: %s", dev, nand_info[dev].name + gd->reloc_off);
puts("... is now current device\n");
nand_curr_device = dev;
@@ -993,8 +994,8 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (55);
printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
- dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
- offset);
+ dev, nand_dev_desc[dev].name + gd->reloc_off,
+ nand_dev_desc[dev].IO_ADDR, offset);
if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
SECTORSIZE, NULL, (u_char *)addr)) {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names
2009-01-19 13:13 [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names gvv at horse.lst.loc
@ 2009-01-19 13:05 ` Jean-Christophe PLAGNIOL-VILLARD
2009-01-19 13:36 ` [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers tostatic " Valeriy Glushkov
0 siblings, 1 reply; 6+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-01-19 13:05 UTC (permalink / raw)
To: u-boot
On 15:13 Mon 19 Jan , gvv at horse.lst.loc wrote:
> When U-boot starting from NAND the pointers to chip names are set before relocation.
> If the original memory block is overwritten after relocation that led to invalid
> string data in the nand utility.
what will happen when it does not start from nand but an other device??
btw please fix you mailer to show your real address in the From
Best Regards,
J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers tostatic relocated chip names
2009-01-19 13:05 ` Jean-Christophe PLAGNIOL-VILLARD
@ 2009-01-19 13:36 ` Valeriy Glushkov
0 siblings, 0 replies; 6+ messages in thread
From: Valeriy Glushkov @ 2009-01-19 13:36 UTC (permalink / raw)
To: u-boot
I have not tried it for non-NAND boot, but it should work for any type of
boot devices where gd->reloc_off is set properly.
The previous version still works for nay NOR boot, as the non-relocated
pointers to static strings are always point to the RO data in the NOR.
But for the NAND boot where we start directly from RAM, this happens,
because the initial non-relocated memory can be overwritten any time...
Best regards,
Valeriy Glushkov
P.S. Sorry for the invalid email address. Fixed.
----- Original Message -----
From: "Jean-Christophe PLAGNIOL-VILLARD" <plagnioj@jcrosoft.com>
To: "Valeriy Glushkov" <gvv@lstec.com>
Cc: <u-boot@lists.denx.de>
Sent: 19 ?????? 2009 ?. 15:05
Subject: Re: [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers
tostatic relocated chip names
> On 15:13 Mon 19 Jan , gvv at horse.lst.loc wrote:
>> When U-boot starting from NAND the pointers to chip names are set before
>> relocation.
>> If the original memory block is overwritten after relocation that led to
>> invalid
>> string data in the nand utility.
>
> what will happen when it does not start from nand but an other device??
>
> btw please fix you mailer to show your real address in the From
>
> Best Regards,
> J.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names
@ 2009-01-19 13:19 Valeriy Glushkov
2009-01-19 13:29 ` Wolfgang Denk
0 siblings, 1 reply; 6+ messages in thread
From: Valeriy Glushkov @ 2009-01-19 13:19 UTC (permalink / raw)
To: u-boot
When U-boot starting from NAND the pointers to chip names are set before relocation.
If the original memory block is overwritten after relocation that led to invalid
string data in the nand utility.
Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
---
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index b94a2bf..14925cd 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -10,6 +10,7 @@
#include <common.h>
+DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_NAND_LEGACY
/*
@@ -193,7 +194,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
if (nand_info[i].name)
printf("Device %d: %s, sector size %u KiB\n",
- i, nand_info[i].name,
+ i, nand_info[i].name + gd->reloc_off,
nand_info[i].erasesize >> 10);
}
return 0;
@@ -207,7 +208,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("\nno devices available\n");
else
printf("\nDevice %d: %s\n", nand_curr_device,
- nand_info[nand_curr_device].name);
+ nand_info[nand_curr_device].name + gd->reloc_off);
return 0;
}
dev = (int)simple_strtoul(argv[2], NULL, 10);
@@ -215,7 +216,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("No such device\n");
return 1;
}
- printf("Device %d: %s", dev, nand_info[dev].name);
+ printf("Device %d: %s", dev, nand_info[dev].name + gd->reloc_off);
puts("... is now current device\n");
nand_curr_device = dev;
@@ -993,8 +994,8 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (55);
printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
- dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
- offset);
+ dev, nand_dev_desc[dev].name + gd->reloc_off,
+ nand_dev_desc[dev].IO_ADDR, offset);
if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
SECTORSIZE, NULL, (u_char *)addr)) {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names
2009-01-19 13:19 [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static " Valeriy Glushkov
@ 2009-01-19 13:29 ` Wolfgang Denk
0 siblings, 0 replies; 6+ messages in thread
From: Wolfgang Denk @ 2009-01-19 13:29 UTC (permalink / raw)
To: u-boot
Dear Valeriy Glushkov,
In message <12323711841178-git-send-email-gvv@lstec.com> you wrote:
> When U-boot starting from NAND the pointers to chip names are set before relocation.
> If the original memory block is overwritten after relocation that led to invalid
> string data in the nand utility.
This means that the pointers need to be manually relocated.
> - i, nand_info[i].name,
> + i, nand_info[i].name + gd->reloc_off,
Such relocation shouldbe done exactly once, right after relocation.
Doing this everywhere where the pointers are references is error
prone, ugly and wastes memory.
Please change your patch to fix the pointers. Thanks.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"We all agree on the necessity of compromise. We just can't agree on
when it's necessary to compromise."
- Larry Wall in <1991Nov13.194420.28091@netlabs.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names
@ 2009-01-19 12:58 gvv at horse.lst.loc
0 siblings, 0 replies; 6+ messages in thread
From: gvv at horse.lst.loc @ 2009-01-19 12:58 UTC (permalink / raw)
To: u-boot
When U-boot starting from NAND the pointers to chip names are set before relocation.
If the original memory block is overwritten after relocation that led to invalid
string data in the nand utility.
Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
---
diff --git a/common/cmd_nand.c b/common/cmd_nand.c
index b94a2bf..14925cd 100644
--- a/common/cmd_nand.c
+++ b/common/cmd_nand.c
@@ -10,6 +10,7 @@
#include <common.h>
+DECLARE_GLOBAL_DATA_PTR;
#ifndef CONFIG_NAND_LEGACY
/*
@@ -193,7 +194,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
for (i = 0; i < CFG_MAX_NAND_DEVICE; i++) {
if (nand_info[i].name)
printf("Device %d: %s, sector size %u KiB\n",
- i, nand_info[i].name,
+ i, nand_info[i].name + gd->reloc_off,
nand_info[i].erasesize >> 10);
}
return 0;
@@ -207,7 +208,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("\nno devices available\n");
else
printf("\nDevice %d: %s\n", nand_curr_device,
- nand_info[nand_curr_device].name);
+ nand_info[nand_curr_device].name + gd->reloc_off);
return 0;
}
dev = (int)simple_strtoul(argv[2], NULL, 10);
@@ -215,7 +216,7 @@ int do_nand(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
puts("No such device\n");
return 1;
}
- printf("Device %d: %s", dev, nand_info[dev].name);
+ printf("Device %d: %s", dev, nand_info[dev].name + gd->reloc_off);
puts("... is now current device\n");
nand_curr_device = dev;
@@ -993,8 +994,8 @@ int do_nandboot (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
show_boot_progress (55);
printf ("\nLoading from device %d: %s at 0x%lx (offset 0x%lx)\n",
- dev, nand_dev_desc[dev].name, nand_dev_desc[dev].IO_ADDR,
- offset);
+ dev, nand_dev_desc[dev].name + gd->reloc_off,
+ nand_dev_desc[dev].IO_ADDR, offset);
if (nand_legacy_rw (nand_dev_desc + dev, NANDRW_READ, offset,
SECTORSIZE, NULL, (u_char *)addr)) {
--
1.5.2.5
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-01-19 13:36 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-19 13:13 [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static relocated chip names gvv at horse.lst.loc
2009-01-19 13:05 ` Jean-Christophe PLAGNIOL-VILLARD
2009-01-19 13:36 ` [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers tostatic " Valeriy Glushkov
-- strict thread matches above, loose matches on Subject: below --
2009-01-19 13:19 [U-Boot] [PATCH] NAND: cmd_nand.c: fix invalid pointers to static " Valeriy Glushkov
2009-01-19 13:29 ` Wolfgang Denk
2009-01-19 12:58 gvv at horse.lst.loc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox