Skip to contentSkip to conversation

Problem in writing downloaded image to NAND device

U-Boot-Users Dharmosoth Seetharam 3 participants 9 messages Nov 27, 2007 – Nov 29, 2007

lore
Share & tools
lore
#0 lore raw

Hi all,

I have a problem in writing to NAND device.

U-Boot 1.2.0 (Nov 27 2007 - 13:18:12)
Board - atmel

cpu   - arm926ejs
fs    - cramfs
Os    - Linux, ARM based OS

64MB SDRAM and 256 MB NAND device.

What i am trying to achieve is:
To copy the downloaded kernel image and fs image to NAND device.

What I have done is:
1) Downloaded the kernel image and fs image
using tftp download command at U-Boot.

*) tftp 0x22200000 kernel.img

## Checking Image at 22200000 ...

   Image Name:   Linux 2.6.22
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1872572 Bytes =  1.8 MB

Load Address: 20008000
Entry Point: 20008000
Verifying Checksum ... OK
U-Boot>

kernel image is downloaded to SDRAM.

Now want to write this kernel image to NAND device. U-Boot> nand device
Device 0: NAND 256MiB 3,3V 8-bit

U-Boot> nand write 0x22200000 0x0 0x200000
NAND write: device 0 offset 0x0, size 0x200000
2097152 bytes written: OK

U-Boot> nboot 0x22200000 0
Loading from NAND 256MiB 3,3V 8-bit, offset 0x0
Magic Number : 0x0 , required : 0x27051956
Image Name:
Image Type: Invalid CPU Invalid OS Invalid Image
(uncompressed)
Data Size: 0 Bytes = 0 kB
Load Address: 00000000
Entry Point: 00000000
U-Boot>

I have looked @ the code for NAND write

nand_write() --> nand_write_ecc() --> nand_write_page() --> nand_write_buf() --> writeb()

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

As per the above for loop every character (ie.
buf[i])
going to written @ the address this->IO_ADDR_W (??).

But, What we need is, start address and len to
write into the NAND device.

Can you please look at this and help me in this
regard.

My main goal here is to write to NAND device.

I wrote my own function to write to NAND device, but somehow they are getting modified once the command finishes the execution.

I have testes all these values in the memory using md command.

<< md memory-addess >>

Please suggest me if i am doing wrong !!

Thanks,
Seetharam

Bollywood, fun, friendship, sports and more. You name it, we have it on http://in.promos.yahoo.com/groups

#1 lore raw
Quoted 3 lines · Dharmosoth Seetharam

I have a problem in writing to NAND device.

U-Boot 1.2.0 (Nov 27 2007 - 13:18:12)

Please try to upgrade to a recent version of U-Boot. 1.3.0 was released just a few days ago. Generally it is always recommended to use the most recent U-Boot version.

Quoted 28 lines

Board - atmel

cpu   - arm926ejs
fs    - cramfs
Os    - Linux, ARM based OS

64MB SDRAM and 256 MB NAND device.

What i am trying to achieve is:
To copy the downloaded kernel image and fs image to NAND device.

What I have done is:

   1) Downloaded the kernel image and fs image
      using tftp download command at U-Boot.

     *) tftp 0x22200000 kernel.img

   ## Checking Image at 22200000 ...
   Image Name:   Linux 2.6.22
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1872572 Bytes =  1.8 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   U-Boot>

kernel image is downloaded to SDRAM.

Quoted 7 lines

Now want to write this kernel image to NAND device. U-Boot> nand device
Device 0: NAND 256MiB 3,3V 8-bit

U-Boot> nand write 0x22200000 0x0 0x200000
NAND write: device 0 offset 0x0, size 0x200000
2097152 bytes written: OK

Just try to read the image back into SDRAM and compare it to the original version:

=> nand read 22400000 0 200000
=> cmp.b 22200000 22400000 200000

Does this match? But again it is not worth the effort to debug such a problem in this older U-Boot version. Please upgrade. A lot changes in the NAND driver too.

Quoted 33 lines

U-Boot> nboot 0x22200000 0
Loading from NAND 256MiB 3,3V 8-bit, offset 0x0
Magic Number : 0x0 , required : 0x27051956
Image Name:
Image Type: Invalid CPU Invalid OS Invalid Image
(uncompressed)
Data Size: 0 Bytes = 0 kB
Load Address: 00000000
Entry Point: 00000000
U-Boot>

I have looked @ the code for NAND write

nand_write() --> nand_write_ecc() --> nand_write_page() --> nand_write_buf() --> writeb()

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

As per the above for loop every character (ie.
buf[i])
going to written @ the address this->IO_ADDR_W (??).

But, What we need is, start address and len to
write into the NAND device.

Quoted 8 lines

Can you please look at this and help me in this
regard.

My main goal here is to write to NAND device.

I wrote my own function to write to NAND device, but somehow they are getting modified once the command finishes the execution.

Don't write "own functions". Use the existing ones and fix them if necessary.

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 at denx.de
=====================================================================

#2 lore raw

Hi,

I have downloaded the file u-boot-1.3.0-rc1.tar.bz2 from the following link. ftp://ftp.denx.de/pub/u-boot/

But, U_BOOT_VERSION is having 1.2.0 only.

Is it wrong ?? OR any other U-boot 1.3 is there ?
Please point me if i am wrong.

Thanks,
Seetharam

Quoted 106 lines · --- Stefan Roese
Quoted 3 lines · Dharmosoth Seetharam

I have a problem in writing to NAND device.

U-Boot 1.2.0 (Nov 27 2007 - 13:18:12)

Please try to upgrade to a recent version of U-Boot. 1.3.0 was released just a
few days ago. Generally it is always recommended to use the most recent
U-Boot version.

Quoted 15 lines

Board - atmel

cpu   - arm926ejs
fs    - cramfs
Os    - Linux, ARM based OS

64MB SDRAM and 256 MB NAND device.

What i am trying to achieve is:
To copy the downloaded kernel image and fs image to NAND device.

What I have done is:
1) Downloaded the kernel image and fs image
using tftp download command at U-Boot.

Quoted 5 lines

*) tftp 0x22200000 kernel.img

   ## Checking Image at 22200000 ...
   Image Name:   Linux 2.6.22
   Image Type:   ARM Linux Kernel Image

(uncompressed)

Quoted 9 lines
   Data Size:    1872572 Bytes =  1.8 MB
   Load Address: 20008000
   Entry Point:  20008000
   Verifying Checksum ... OK
   U-Boot>

kernel image is downloaded to SDRAM.

Now want to write this kernel image to NAND

device.

Quoted 6 lines

U-Boot> nand device
Device 0: NAND 256MiB 3,3V 8-bit

U-Boot> nand write 0x22200000 0x0 0x200000
NAND write: device 0 offset 0x0, size 0x200000
2097152 bytes written: OK

Just try to read the image back into SDRAM and compare it to the original
version:

=> nand read 22400000 0 200000
=> cmp.b 22200000 22400000 200000

Does this match? But again it is not worth the effort to debug such a problem
in this older U-Boot version. Please upgrade. A lot changes in the NAND
driver too.

Quoted 5 lines

U-Boot> nboot 0x22200000 0
Loading from NAND 256MiB 3,3V 8-bit, offset 0x0
Magic Number : 0x0 , required : 0x27051956
Image Name:
Image Type: Invalid CPU Invalid OS Invalid

Image

Quoted 11 lines

(uncompressed)
Data Size: 0 Bytes = 0 kB
Load Address: 00000000
Entry Point: 00000000
U-Boot>

I have looked @ the code for NAND write

nand_write() --> nand_write_ecc() -->
nand_write_page() --> nand_write_buf() -->

writeb()

Quoted 6 lines

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);
Quoted 6 lines

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

As per the above for loop every character (ie.
buf[i])
going to written @ the address this->IO_ADDR_W

(??).

Quoted 11 lines

But, What we need is, start address and len to
write into the NAND device.

Can you please look at this and help me in this
regard.

My main goal here is to write to NAND device.

I wrote my own function to write to NAND device,

but

Quoted 10 lines
Quoted 2 lines

somehow they are getting modified once the command finishes the execution.

Don't write "own functions". Use the existing ones and fix them if necessary.

Best regards,
Stefan

=====================================================================

Quoted 7 lines

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 at denx.de

=====================================================================

Quoted 1 line

Save all your chat conversations. Find them online at http://in.messenger.yahoo.com/webmessengerpromo.php

#3 lore raw
Quoted 8 lines · Dharmosoth Seetharam

I have downloaded the file u-boot-1.3.0-rc1.tar.bz2 from the following link. ftp://ftp.denx.de/pub/u-boot/

But, U_BOOT_VERSION is having 1.2.0 only.

Is it wrong ?? OR any other U-boot 1.3 is there ?
Please point me if i am wrong.

You should use git to download he latest version. But it's also possible to download a snapshort via the gitweb interface:

http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=snapshot;h=9a337ddc154a10a26f117fd147b009abcdeba75a;sf=tgz

This should give you rev. 1.3.0.

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 at denx.de
=====================================================================

#4 lore raw
In reply to Dharmosoth Seetharam
Quoted 4 lines · In message <[email protected]> you wrote:

I have downloaded the file u-boot-1.3.0-rc1.tar.bz2 from the following link. ftp://ftp.denx.de/pub/u-boot/

Why didn't you use one of the more recent versions like

Quoted 1 line

But, U_BOOT_VERSION is having 1.2.0 only.

Oops? Make sure to unpack, configure and build the downloaded tarball, please.

Quoted 2 lines

Is it wrong ?? OR any other U-boot 1.3 is there ?
Please point me if i am wrong.

A short look at the FTP server shows:

-rw-rw-r--      6866983   Sep  8 01:09   u-boot-1.3.0-rc1.tar.bz2
-rw-r--r--      6876009   Sep 20 00:07   u-boot-1.3.0-rc2.tar.bz2
-rw-rw-r--      8783437   Oct 14 00:13   u-boot-1.3.0-rc3.tar.gz
-rw-rw-r--      6896029   Nov 19 22:25   u-boot-1.3.0-rc4.tar.bz2
-rw-rw-r--      6898443   Nov 19 22:26   u-boot-1.3.0.tar.bz2

So indeed it seems there are never versions available.

Best regards,

Wolfgang Denk

Signature · 5 lines
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
"There are things that are so serious that you can  only  joke  about
them"                                                    - Heisenberg
#5 lore raw

Hi,

Thank you for quick suggestion.

I have one doubt in NAND write/read PATH.

Quoted 11 lines
Quoted 11 lines

nand_write() --> nand_write_ecc() -->
nand_write_page() --> nand_write_buf() -->

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

How can be "n" (where n=len) characters are going to written this->IO_ADDR_W.

As per the above fro loop, I am getting confuse that is - for each character from buf ( ie. buf[i]) the dest. address will be the same. So, there will be a overwriting to the same dest. address in NAND.

Is there any logic behind this stmt ??

Please suggest me the right way to understand the NAND write PATH from U-Boot code.

Thanks,
Seetharam

Quoted 34 lines · --- Wolfgang Denk

In message
<[email protected]> you

Quoted 2 lines · wrote:

I have downloaded the file

u-boot-1.3.0-rc1.tar.bz2

Quoted 2 lines

from the following link.
ftp://ftp.denx.de/pub/u-boot/

Why didn't you use one of the more recent versions like

Quoted 1 line

But, U_BOOT_VERSION is having 1.2.0 only.

Oops? Make sure to unpack, configure and build the downloaded tarball,
please.

Quoted 2 lines

Is it wrong ?? OR any other U-boot 1.3 is there ?
Please point me if i am wrong.

A short look at the FTP server shows:

-rw-rw-r-- 6866983 Sep 8 01:09
u-boot-1.3.0-rc1.tar.bz2
-rw-r--r-- 6876009 Sep 20 00:07
u-boot-1.3.0-rc2.tar.bz2
-rw-rw-r-- 8783437 Oct 14 00:13
u-boot-1.3.0-rc3.tar.gz
-rw-rw-r-- 6896029 Nov 19 22:25
u-boot-1.3.0-rc4.tar.bz2
-rw-rw-r-- 6898443 Nov 19 22:26
u-boot-1.3.0.tar.bz2

Quoted 21 lines

So indeed it seems there are never versions
available.

Best regards,

Wolfgang Denk

Signature · 10 lines
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
"There are things that are so serious that you can 
only  joke  about
them"                                               
    - Heisenberg

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

#6 lore raw
Quoted 18 lines · Dharmosoth Seetharam

I have one doubt in NAND write/read PATH.

Quoted 11 lines
Quoted 11 lines

nand_write() --> nand_write_ecc() -->
nand_write_page() --> nand_write_buf() -->

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

How can be "n" (where n=len) characters are going to written this->IO_ADDR_W.

Quoted 6 lines

As per the above fro loop, I am getting confuse that is - for each character from buf ( ie. buf[i]) the dest. address will be the same. So, there will be a overwriting to the same dest. address in NAND.

Is there any logic behind this stmt ??

Yes. This is the way is supposed to work. NAND FLASH chips don't have a "flat address" model like NOR chips do. They don't have address signals at all. You have to write the address using the data signals before writing the data itself. This is done in conjunction with some control signals. So the data signals are in reality multiplexed address/data pins.

Quoted 2 lines

Please suggest me the right way to understand the NAND write PATH from U-Boot code.

I suggest you take a look at a NAND chip data sheet to understand how NAND chips are used.

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 at denx.de
=====================================================================

#7 lore raw

Hi,

I have gone thorugh the nand write code in u-boot. But, i didn't get any problem in that.

Does it work for you guys (ie.writing to NAND device) ?? Or Problem with my NAND device itself ??

NAND devie : Samsung, 256 MB.

Any one tried the following command ???

Quoted 2 lines
Quoted 2 lines

nand write 0x22200000 0x0 0x800 (???)
md 0x22200000 (??)

Thanks,
Seetharam

Quoted 43 lines · --- Stefan Roese
Quoted 14 lines · Dharmosoth Seetharam

I have one doubt in NAND write/read PATH.

Quoted 11 lines
Quoted 11 lines

nand_write() --> nand_write_ecc() -->
nand_write_page() --> nand_write_buf() -->

in nand_write_buf() :

 for (i=0; i<len; i++) {
      writeb(buf[i], this->IO_ADDR_W);

<< writeb is defined as
(*(volatile unsigned char *)(a) = (v)) >>

Quoted 6 lines

How can be "n" (where n=len) characters are going to written this->IO_ADDR_W.

As per the above fro loop, I am getting confuse that is - for each character from buf ( ie.

buf[i])

Quoted 1 line

the dest. address will be the same. So, there will

be

Quoted 3 lines

a overwriting to the same dest. address in NAND.

Is there any logic behind this stmt ??

Yes. This is the way is supposed to work. NAND FLASH chips don't have a "flat
address" model like NOR chips do. They don't have address signals at all. You
have to write the address using the data signals before writing the data
itself. This is done in conjunction with some control signals. So the data
signals are in reality multiplexed address/data pins.

Quoted 2 lines

Please suggest me the right way to understand the NAND write PATH from U-Boot code.

Quoted 8 lines

I suggest you take a look at a NAND chip data sheet to understand how NAND
chips are used.

Best regards,
Stefan

=====================================================================

Quoted 7 lines

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 at denx.de

=====================================================================

Quoted 1 line

Download prohibited? No problem. CHAT from any browser, without download. Go to http://in.messenger.yahoo.com/webmessengerpromo.php/

#8 lore raw
Quoted 5 lines · Dharmosoth Seetharam

I have gone thorugh the nand write code in u-boot. But, i didn't get any problem in that.

Does it work for you guys (ie.writing to NAND device) ?? Or Problem with my NAND device itself ??

Yes, it works fine on multiple boards with multiple NAND devices.

Quoted 1 line

NAND devie : Samsung, 256 MB.

Such a device is supported. So there must be a problem in your board specific code and/or your NAND driver itself.

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 at denx.de
=====================================================================