Skip to contentSkip to conversation

Binary Nandwrite/read to Flash

DISCUSSION Manuel Sahm 3 participants 8 messages Mar 13, 2008 – Mar 14, 2008 1 message not in the archive Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

Hello,

is it possible to write directly to nandflash, or to store a file in nand flash ?

Thank you

Signature · 3 lines
Best regards 

Manuel Sahm	
#1 lore raw
Quoted 3 lines · Manuel Sahm

Hello,

is it possible to write directly to nandflash, or to store a file in nand flash ?

Yes, use the mtdtools applications nandwrite and nanddump in order to skip bad blocks during read and write. You'll need the pad option to nandwrite in order to fill out to an even multiple of the page size.

If you're writing a file, it really is raw byte by byte, with no indication of file size, access times etc, so to the extent you need that info you'll have to store it explicitly.

/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 7 lines · Manuel Sahm

Thank you,

could you tell me the exact call:

I have a NAND-Flash with PAGESSIZE = 0x800 and ERASEBLOCKSIZE=0x20000

I want to write a file maybe called "test.txt" at adress 0x02000000 of the NAND flash.

Something like

nandwrite -s 0x02000000 -p /dev/mtd0 test.txt

(mtd0 depending on which device your nandflash is)

(Note: you don't have to specify the padding size, nandwrite figures it out by querying mtd).

Quoted 1 line

And read it back to a file "test2.txt" afterwards.

Something like

nanddump -o -b -s 0x02000000 -l <filesize> -f test2.txt /dev/mtd0

where <filesize> is the size of your file.

/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30

#4 lore raw
Quoted 21 lines · Ricard Wanderlof
Quoted 7 lines · Manuel Sahm

Thank you,

could you tell me the exact call:

I have a NAND-Flash with PAGESSIZE = 0x800 and ERASEBLOCKSIZE=0x20000

I want to write a file maybe called "test.txt" at adress 0x02000000 of the NAND flash.

Something like

nandwrite -s 0x02000000 -p /dev/mtd0 test.txt

(mtd0 depending on which device your nandflash is)

(Note: you don't have to specify the padding size, nandwrite figures it out by querying mtd).

Quoted 1 line

And read it back to a file "test2.txt" afterwards.

Quoted 11 lines

Something like

nanddump -o -b -s 0x02000000 -l <filesize> -f test2.txt /dev/mtd0

where <filesize> is the size of your file.

/Ricard

Signature · 3 lines
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

Thank you very much....

Is it possible to write/read to the NAND flash "directly" without an partition ?(/dev/mtdX) ?

Best regards

Manuel Sahm

#5 lore raw
Quoted 3 lines · Manuel Sahm

Thank you very much....

Is it possible to write/read to the NAND flash "directly" without an partition ?(/dev/mtdX) ?

No, but you can set up a /dev/mtdX device to span the whole device, even if you then have additional /dev/mtdX devices which refer to partitions.

/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30

#6 lore raw
Quoted 15 lines · Ricard Wanderlof
Quoted 3 lines · Manuel Sahm

Thank you very much....

Is it possible to write/read to the NAND flash "directly" without an partition ?(/dev/mtdX) ?

No, but you can set up a /dev/mtdX device to span the whole device, even if you then have additional /dev/mtdX devices which refer to partitions.

/Ricard

Signature · 3 lines
Ricard Wolf Wanderlöf                           ricardw(at)axis.com
Axis Communications AB, Lund, Sweden            www.axis.com
Phone +46 46 272 2016                           Fax +46 46 13 61 30

Thank you,

it´s very dangerous, because if I use the wrong address I´ll kill my system :-)

Is ther a possibility to make the /dev/mtdX read only (write protected) ?

Thank you

Best regards

Manuel Sahm

#7 lore raw
Quoted 7 lines · Manuel Sahm
Quoted 4 lines
Quoted 1 line

Is it possible to write/read to the NAND flash "directly" without an partition ?(/dev/mtdX) ?

No, but you can set up a /dev/mtdX device to span the whole device, even if you then have additional /dev/mtdX devices which refer to partitions.

it´s very dangerous, because if I use the wrong address I´ll kill my system :-)

Is ther a possibility to make the /dev/mtdX read only (write protected) ?

Yes, in the driver that registers the flash with mtd you can specify that the partition should be read only. However, as far as I know [someone please correct me if I'm wrong] this can then not be changed while the system is running, so it's not possible to write or erase the partition without rebooting.

/Ricard
--
Ricard Wolf Wanderlöf ricardw(at)axis.com
Axis Communications AB, Lund, Sweden www.axis.com
Phone +46 46 272 2016 Fax +46 46 13 61 30

#8 lore raw
In reply to Ricard Wanderlof
Quoted 10 lines · Ricard Wanderlof
Quoted 3 lines · Manuel Sahm

Hello,

is it possible to write directly to nandflash, or to store a file in nand flash ?

Yes, use the mtdtools applications nandwrite and nanddump in order to skip bad blocks during read and write. You'll need the pad option to nandwrite in order to fill out to an even multiple of the page size.

If you're writing a file, it really is raw byte by byte, with no indication of file size, access times etc, so to the extent you need that info you'll have to store it explicitly.

And if bits flip appear you've got a problem : you need to rewrite the file.

Matthieu