[U-Boot-Users] AT91SAM9260-EK: Trying to load U-Boot env from NAND

Hello, this is my first post in this Forum and my English is not very good so I give my best to describe my problem.
I have a AT91SAM9260 eval kit board and until now there were not very much problem. But what stops me now is a really tough problem. I use the Bootstraploader for NAND boot which is compiled by Atmel in the Demo. I've compiled the U-Boot by my self and its starts without problem, but what get on my nerves is that I can't write the U-Boot env over .tcl file. To explain that, I load everything, just like it is done in the demo, with this batch- and .tcl-file. So, I've checked the checksum for the env's but everytime I uploaded it and trying to boot I get this:
U-Boot 1.1.5 (Nov 2 2006 - 10:20:33)
DRAM: 64 MB NAND: NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (<NULL> NAND 256MiB 3,3V 8-bit) 256 MiB DataFlash:AT45DB642 Nb pages: 8192 Page Size: 1056 Size= 8650752 bytes Logical address: 0xD0000000 Area 0: D0000000 to D0003FFF (RO) Area 1: D0004000 to D0007FFF Area 2: D0008000 to D0037FFF (RO) Area 3: D0038000 to D083FFFF *** Warning - bad CRC or NAND, using default environment
In: serial Out: serial Err: serial DM9161A PHY Detected End of Autonegociation U-Boot> U-Boot> U-Boot> printenv bootdelay=3 baudrate=115200 stdin=serial stdout=serial stderr=serial
Environment size: 69/131068 bytes U-Boot>
I checked the env (nand read to copy them in the RAM and md to hae a look at them) and they're still correct. Well, I could write the env every by hand that would work but if you have to do this 20 times a day and you have really much to write this wouldn't be very funny.
So I hope I haven't forget anything, but if there is any question I will try to answer.
Greets, Destrukto

Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam
--- Destrukto simon.bielmann@gmx.ch wrote:
Hello, this is my first post in this Forum and my English is not very good so I give my best to describe my problem.
I have a AT91SAM9260 eval kit board and until now there were not very much problem. But what stops me now is a really tough problem. I use the Bootstraploader for NAND boot which is compiled by Atmel in the Demo. I've compiled the U-Boot by my self and its starts without problem, but what get on my nerves is that I can't write the U-Boot env over .tcl file. To explain that, I load everything, just like it is done in the demo, with this batch- and .tcl-file. So, I've checked the checksum for the env's but everytime I uploaded it and trying to boot I get this:
U-Boot 1.1.5 (Nov 2 2006 - 10:20:33)
DRAM: 64 MB NAND: NAND device: Manufacturer ID: 0xec, Chip ID: 0xda (<NULL> NAND 256MiB 3,3V 8-bit) 256 MiB DataFlash:AT45DB642 Nb pages: 8192 Page Size: 1056 Size= 8650752 bytes Logical address: 0xD0000000 Area 0: D0000000 to D0003FFF (RO) Area 1: D0004000 to D0007FFF Area 2: D0008000 to D0037FFF (RO) Area 3: D0038000 to D083FFFF *** Warning - bad CRC or NAND, using default environment
In: serial Out: serial Err: serial DM9161A PHY Detected End of Autonegociation U-Boot> U-Boot> U-Boot> printenv bootdelay=3 baudrate=115200 stdin=serial stdout=serial stderr=serial
Environment size: 69/131068 bytes U-Boot>
I checked the env (nand read to copy them in the RAM and md to hae a look at them) and they're still correct. Well, I could write the env every by hand that would work but if you have to do this 20 times a day and you have really much to write this wouldn't be very funny.
So I hope I haven't forget anything, but if there is any question I will try to answer.
Greets, Destrukto
View this message in context:
http://www.nabble.com/AT91SAM9260-EK%3A-Trying-to-load-U-Boot-env-from-NAND-...
Sent from the Uboot - Users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4
U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/u-boot-users
Why delete messages? Unlimited storage is just a click away. Go to http://help.yahoo.com/l/in/yahoo/mail/yahoomail/tools/tools-08.html

At first thanks for your reply, but could you explain that in detail please.
Thanks Destrukto
Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam

please Debug the function which i mention earlier. If you don't get any clue, please copy the code of your Dataflash_Select() here
Thanks, Seetharam
Destrukto simon.bielmann@gmx.ch wrote: At first thanks for your reply, but could you explain that in detail please.
Thanks Destrukto
Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam

Yes! I get it work, the problem was, that it had a problem to accept the crc32-Checksum. So I just erased the sequence where this happens. Here the patchfile:
--- env_nand.c 2007-11-30 14:15:03.000000000 +0100 +++ env_nand.c 2007-11-30 14:16:17.000000000 +0100 @@ -247,13 +247,7 @@ void env_relocate_spec (void) crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); }
- if(!crc1_ok && !crc2_ok) - return use_default(); - else if(crc1_ok && !crc2_ok) - gd->env_valid = 1; - else if(!crc1_ok && crc2_ok) - gd->env_valid = 2; - else { + /* both ok - check serial */ if(tmp_env1->flags == 255 && tmp_env2->flags == 0) gd->env_valid = 2; @@ -266,8 +260,6 @@ void env_relocate_spec (void) else /* flags are equal - almost impossible */ gd->env_valid = 1;
- } - free(env_ptr); if(gd->env_valid == 1) { env_ptr = tmp_env1;
Maybe it isn't the best solution but it works ;) Thanks for you help!!
Destrukto
Dharmosoth Seetharam wrote:
please Debug the function which i mention earlier. If you don't get any clue, please copy the code of your Dataflash_Select() here
Thanks, Seetharam
Destrukto simon.bielmann@gmx.ch wrote: At first thanks for your reply, but could you explain that in detail please.
Thanks Destrukto
Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam -- View this message in context: http://www.nabble.com/AT91SAM9260-EK%3A-Trying-to-load-U-Boot-env-from-NAND-... Sent from the Uboot - Users mailing list archive at Nabble.com.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

I agree with your comment. !!!!
cool..
Thanks, Seetharam
Destrukto simon.bielmann@gmx.ch wrote: Yes! I get it work, the problem was, that it had a problem to accept the crc32-Checksum. So I just erased the sequence where this happens. Here the patchfile:
--- env_nand.c 2007-11-30 14:15:03.000000000 +0100 +++ env_nand.c 2007-11-30 14:16:17.000000000 +0100 @@ -247,13 +247,7 @@ void env_relocate_spec (void) crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); }
- if(!crc1_ok && !crc2_ok) - return use_default(); - else if(crc1_ok && !crc2_ok) - gd->env_valid = 1; - else if(!crc1_ok && crc2_ok) - gd->env_valid = 2; - else { + /* both ok - check serial */ if(tmp_env1->flags == 255 && tmp_env2->flags == 0) gd->env_valid = 2; @@ -266,8 +260,6 @@ void env_relocate_spec (void) else /* flags are equal - almost impossible */ gd->env_valid = 1;
- } - free(env_ptr); if(gd->env_valid == 1) { env_ptr = tmp_env1;
Maybe it isn't the best solution but it works ;) Thanks for you help!!
Destrukto
Dharmosoth Seetharam wrote:
please Debug the function which i mention earlier. If you don't get any clue, please copy the code of your Dataflash_Select() here
Thanks, Seetharam
Destrukto wrote: At first thanks for your reply, but could you explain that in detail please.
Thanks Destrukto
Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam -- View this message in context: http://www.nabble.com/AT91SAM9260-EK%3A-Trying-to-load-U-Boot-env-from-NAND-... Sent from the Uboot - Users mailing list archive at Nabble.com.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

Well now I had time to solve the problem once and for all. If I look back the solution was so simple. Because we use a .bat and .tcl file to copy all on the NAND-Flash we haven't set the active ENV-Block (one redundant and one in use). Now I simply ad the flag set in the .tcl file and it works:
################################################################################ # proc uboot_env: Convert u-boot variables in a string ready to be flashed # in the region reserved for environment variables ################################################################################ proc set_uboot_env {nameOfLstOfVar} { upvar $nameOfLstOfVar lstOfVar
# sector size is the size defined in u-boot CFG_ENV_SIZE set sectorSize [expr 0x20000 - 5] set flag 1 <- I added this
set strEnv [join $lstOfVar "\0"] while {[string length $strEnv] < $sectorSize} { append strEnv "\0" } set strCrc [binary format i [::vfs::crc $strEnv]] return "$strCrc$flag$strEnv" <- and the $flag }
Dharmosoth Seetharam wrote:
I agree with your comment. !!!!
cool..
Thanks, Seetharam
Destrukto simon.bielmann@gmx.ch wrote: Yes! I get it work, the problem was, that it had a problem to accept the crc32-Checksum. So I just erased the sequence where this happens. Here the patchfile:
--- env_nand.c 2007-11-30 14:15:03.000000000 +0100 +++ env_nand.c 2007-11-30 14:16:17.000000000 +0100 @@ -247,13 +247,7 @@ void env_relocate_spec (void) crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); }
- if(!crc1_ok && !crc2_ok)
- return use_default();
- else if(crc1_ok && !crc2_ok)
- gd->env_valid = 1;
- else if(!crc1_ok && crc2_ok)
- gd->env_valid = 2;
- else {
- /* both ok - check serial */ if(tmp_env1->flags == 255 && tmp_env2->flags == 0) gd->env_valid = 2;
@@ -266,8 +260,6 @@ void env_relocate_spec (void) else /* flags are equal - almost impossible */ gd->env_valid = 1;
- }
- free(env_ptr); if(gd->env_valid == 1) { env_ptr = tmp_env1;
Maybe it isn't the best solution but it works ;) Thanks for you help!!
Destrukto
Dharmosoth Seetharam wrote:
please Debug the function which i mention earlier. If you don't get any clue, please copy the code of your Dataflash_Select() here
Thanks, Seetharam
Destrukto wrote: At first thanks for your reply, but could you explain that in detail please.
Thanks Destrukto
Hi,
If I remember correctly, i got the same issue on AT91SAM9263ek.
you please debug the Dataflash_Select() ... there u many need to go into the if condition and do valid=1;
so, please check it once and modify the condition...
u may get the solution ..
Thanks, Seetharam -- View this message in context: http://www.nabble.com/AT91SAM9260-EK%3A-Trying-to-load-U-Boot-env-from-NAND-... Sent from the Uboot - Users mailing list archive at Nabble.com.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
5, 50, 500, 5000 - Store N number of mails in your inbox. Click here.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
-- View this message in context: http://www.nabble.com/AT91SAM9260-EK%3A-Trying-to-load-U-Boot-env-from-NAND-... Sent from the Uboot - Users mailing list archive at Nabble.com.
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users
Unlimited freedom, unlimited storage. Get it now
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

In message 14124814.post@talk.nabble.com you wrote:
Yes! I get it work, the problem was, that it had a problem to accept the crc32-Checksum. So I just erased the sequence where this happens. Here the patchfile:
--- env_nand.c 2007-11-30 14:15:03.000000000 +0100 +++ env_nand.c 2007-11-30 14:16:17.000000000 +0100 @@ -247,13 +247,7 @@ void env_relocate_spec (void) crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); }
- if(!crc1_ok && !crc2_ok)
return use_default();
- else if(crc1_ok && !crc2_ok)
gd->env_valid = 1;
- else if(!crc1_ok && crc2_ok)
gd->env_valid = 2;
- else {
- /* both ok - check serial */
You mean you completely castrated all logic that would verify if the environment is OK? Arrggghhhh...
Maybe it isn't the best solution but it works ;)
You THINK it works, but actually it's completely broken.
Don't do that!!!
Best regards,
Wolfgang Denk

Well, until now I haven't got any problem with this solution. So until I can't find any better solution I will use the system as long as it works.
wd wrote:
In message 14124814.post@talk.nabble.com you wrote:
Yes! I get it work, the problem was, that it had a problem to accept the crc32-Checksum. So I just erased the sequence where this happens. Here the patchfile:
--- env_nand.c 2007-11-30 14:15:03.000000000 +0100 +++ env_nand.c 2007-11-30 14:16:17.000000000 +0100 @@ -247,13 +247,7 @@ void env_relocate_spec (void) crc2_ok = (crc32(0, tmp_env2->data, ENV_SIZE) == tmp_env2->crc); }
- if(!crc1_ok && !crc2_ok)
return use_default();
- else if(crc1_ok && !crc2_ok)
gd->env_valid = 1;
- else if(!crc1_ok && crc2_ok)
gd->env_valid = 2;
- else {
- /* both ok - check serial */
You mean you completely castrated all logic that would verify if the environment is OK? Arrggghhhh...
Maybe it isn't the best solution but it works ;)
You THINK it works, but actually it's completely broken.
Don't do that!!!
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@denx.de "UNIX was not designed to stop you from doing stupid things, because that would also stop you from doing clever things." - Doug Gwyn
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello!
Destrukto wrote:
Well, until now I haven't got any problem with this solution.
You probably don't have a problem but your customers will get them. I wish you some luck when your product goes to mass production if you neither have found out why your environment storage has problems nor if you don't have any error recovery.
With best regards Andreas Schweigstill
PS.: If you need a consultant which does some forensics on your failed products and is able to find a quick and clean(!) solution don't hesitate to contact me. ;-)
- -- Dipl.-Phys. Andreas Schweigstill Schweigstill IT | Embedded Systems Schauenburgerstraße 116, D-24118 Kiel, Germany Phone: (+49) 431 5606-435, Fax: (+49) 431 5606-436 Mobile: (+49) 171 6921973, Web: http://www.schweigstill.de/

Well now I had time to solve the problem once and for all. If I look back the solution was so simple. Because we use a .bat and .tcl file to copy all on the NAND-Flash we haven't set the active ENV-Block (one redundant and one in use). Now I simply ad the flag set in the .tcl file and it works:
################################################################################ # proc uboot_env: Convert u-boot variables in a string ready to be flashed # in the region reserved for environment variables ################################################################################ proc set_uboot_env {nameOfLstOfVar} { upvar $nameOfLstOfVar lstOfVar
# sector size is the size defined in u-boot CFG_ENV_SIZE set sectorSize [expr 0x20000 - 5] set flag 1 <- I added this
set strEnv [join $lstOfVar "\0"] while {[string length $strEnv] < $sectorSize} { append strEnv "\0" } set strCrc [binary format i [::vfs::crc $strEnv]] return "$strCrc$flag$strEnv" <- and the $flag }
Andreas Schweigstill wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
Hello!
Destrukto wrote:
Well, until now I haven't got any problem with this solution.
You probably don't have a problem but your customers will get them. I wish you some luck when your product goes to mass production if you neither have found out why your environment storage has problems nor if you don't have any error recovery.
With best regards Andreas Schweigstill
PS.: If you need a consultant which does some forensics on your failed products and is able to find a quick and clean(!) solution don't hesitate to contact me. ;-)
Dipl.-Phys. Andreas Schweigstill Schweigstill IT | Embedded Systems Schauenburgerstraße 116, D-24118 Kiel, Germany Phone: (+49) 431 5606-435, Fax: (+49) 431 5606-436 Mobile: (+49) 171 6921973, Web: http://www.schweigstill.de/ -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
iD8DBQFHVSEeYQhaO218O9ERAjfUAKCMo7uHtcz+AIgBAxTIKRYbfSPYrgCfd9SP hAvwji2NgRSHHv7NfFL/LQQ= =owny -----END PGP SIGNATURE-----
SF.Net email is sponsored by: The Future of Linux Business White Paper from Novell. From the desktop to the data center, Linux is going mainstream. Let it simplify your IT future. http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 _______________________________________________ U-Boot-Users mailing list U-Boot-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/u-boot-users

In message 14146625.post@talk.nabble.com you wrote:
Well, until now I haven't got any problem with this solution. So until I can't find any better solution I will use the system as long as it works.
Then all I can do is wishing you an early and complete crash, otherwise you will never fix the real problem until it really hurts.
Best regards,
Wolfgang Denk
participants (4)
-
Andreas Schweigstill
-
Destrukto
-
Dharmosoth Seetharam
-
Wolfgang Denk