Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 14 posts ] 
Author Message
 Post subject: Filesystem on NAND flash
PostPosted: Mon Sep 03, 2007 4:06 pm 
Offline

Joined: Wed Feb 28, 2007 3:51 pm
Posts: 26
Location: Sweden
Hi!

I am working on an AT91SAM9261-ek board I am using u-boot as bootloader and a kernel 2.6.20. I would like to put my filesystem on the NAND flash as it now I am using the nfs to mount the filesystem.

Any ideas how to do this? Or any good links that I can us would be much appreciated.

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 04, 2007 4:32 pm 
Offline

Joined: Thu Aug 09, 2007 10:48 am
Posts: 106
Location: Artec Design LLC, Tallinn, Estonia
I wrote some paragraphs about that here:
http://www.at91.com/phpbb/viewtopic.php?t=3551

Build your kernel with all needed drivers compiled into the kernel (not modules). Boot the kernel. Create filesystem to your NAND partition(jffs2?). Mount it. Copy(extract tarball) files to it.
If you make a NAND image on host, you lose the bad block handling. Writing the filesystem on the running device marks all bad blocks, that may there be already present (NAND may have a small number of bad blocks even if it is completely new).


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 10:35 am 
Offline

Joined: Wed Feb 28, 2007 3:51 pm
Posts: 26
Location: Sweden
Thanks for your response.
I have a questions:
How do I get the filesystem on the NAND flash?
Right now I am using NTFS or an USB device and I have found in cat /proc/partitions

31 0 256 mtdblock0
31 1 261888 mtdblock1

Is it then for me to mount the mtdblock1 device and run mkfs.jffs2 to format and then
create my file system?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 17, 2007 10:41 pm 
Offline

Joined: Mon Apr 16, 2007 6:34 pm
Posts: 41
Location: Fargo, ND, USA
Code:
flash_eraseall /dev/mtd0
mount -t jffs2 /dev/mtdblock0 /mnt


Optionally, write an image to the NAND after erasing:

Code:
mkfs.jffs2 -e 0x20000 -s 0x800 -r /root/filesystem -o image.jffs2
nandwrite /dev/mtd0 image.jffs2


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 9:19 am 
Offline

Joined: Wed Feb 28, 2007 3:51 pm
Posts: 26
Location: Sweden
Thanks jpkotta.

Two questions:

1)Will the nand flash image be loaded in to RAM when the system is booted or will I be able to read/write from/to the nand flash?

2)Where can I get the source for the mkfs.jffs2 and for nandwrite? I will have to crosscompile the source for my board right?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 4:28 pm 
Offline

Joined: Thu Aug 09, 2007 10:48 am
Posts: 106
Location: Artec Design LLC, Tallinn, Estonia
1) No, the filesystem is accessed directly from flash. JFFS2 has full r/w support, so you can write there, too. But use it reasonably, ie not put swapfile there!
2) One option is to get the source package (or even binary) of your favorite distribution. For example, Debian has ARM platform, too.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Sep 19, 2007 5:56 pm 
Offline

Joined: Mon Apr 16, 2007 6:34 pm
Posts: 41
Location: Fargo, ND, USA
I got the flash utils from buildroot. I think the project is based at http://www.linux-mtd.infradead.org/index.html, as mtd-utils.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 20, 2007 9:01 am 
Offline

Joined: Wed Feb 28, 2007 3:51 pm
Posts: 26
Location: Sweden
thanks.

One last question if I put the file system on the NAND flash, where should I put the kernel? Once again thanks for your help.


Top
 Profile  
 
 Post subject: ECC error
PostPosted: Thu Sep 27, 2007 3:41 am 
Offline

Joined: Tue Sep 11, 2007 4:59 am
Posts: 7
I'm using AT91SAM9261, nand02gw3b2c (from ST), and Linux-2.6.21.1. My u-boot and kernel are in NOR flash.

1). If I flash_eraseall the flash, mount it as jffs2, and extract my file system to the flash, I got this:

# tar xvf ../usb/rootfs.tar
./
./home/
./home/default/
./bin/
./bin/iprule
./bin/delgroup
./bin/egrep
./bin/ln
./bin/linmtd->read(0x44 bytes from 0xffc07a0) returned ECC error
uxNode CRC fc1d6418 != calculated CRC f9aaadea for node at 0ffc07a0
32
./bin/cp
./bin/ip
./bin/df
./bin/mktemp
./bin/chgrp
./bin/nano
mtd->read(0x44 bytes from 0xffc73a0) returned ECC error
Node CRC 545612e7 != calculated CRC ee526d6b for node at 0ffc73a0
./bin/netstat
./bin/mv
./bin/more
mtd->read(0x44 bytes from 0xffc7fe0) returned ECC error
Node CRC 862c89e3 != calculated CRC 1e308a16 for node at 0ffc7fe0
./bin/lsmod
mtd->read(0x44 bytes from 0xffc80cc) returned ECC error
Node CRC 60ef4789 != calculated CRC b6dd49fd for node at 0ffc80cc
......
......

If I try to use nand as my rootfs, kernel prints a lot of ECC and Magic bitmask errors and fails to mount it.

2). If I flash_eraseall the flash and nandwrite my jffs2 filesystem image to the flash, then boot, I got this:

......

NAND device: Manufacturer ID: 0x20, Chip ID: 0xda (ST Micro NAND 256MiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 473 at 0x03b20000
Bad eraseblock 728 at 0x05b00000
Bad eraseblock 743 at 0x05ce0000
Bad eraseblock 813 at 0x065a0000
Bad eraseblock 1001 at 0x07d20000
Bad eraseblock 1730 at 0x0d840000
Creating 1 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x10000000 : "nand"

......

mtd->read(0x400 bytes from 0x0) returned ECC error
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x8585 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0x2be0 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000008: 0xe600 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000000c: 0x017d instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000010: 0x0100 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000014: 0x0200 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000018: 0x8700 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000001c: 0x0346 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000020: 0xba00 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000024: 0xffd2 instead
Further such events for this erase block will not be printed
mtd->read(0x1fc08 bytes from 0x3f8) returned ECC error
mtd->read(0x400 bytes from 0x20000) returned ECC error
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00020000: 0x8585 instead
jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00020004: 0x7fe0 instead

......

Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes
empty_blocks 0, bad_blocks 6, c->nr_blocks 2048
VFS: Cannot open root device "mtdblock4" or unknown-block(31,4)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,4)

Any ideas on these problems?

Thanks in advance.

_________________
ZJH


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 27, 2007 3:52 am 
Offline

Joined: Tue Sep 11, 2007 4:59 am
Posts: 7
Since you are using the ek board, I think you can store your kernel in either NAND flash or DataFlash.

_________________
ZJH


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 27, 2007 8:57 pm 
Offline

Joined: Thu Aug 09, 2007 10:48 am
Posts: 106
Location: Artec Design LLC, Tallinn, Estonia
Just a wild guess, but is your NAND interface working on correct speed? Maybe you should try lower clock speeds to check.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 01, 2007 4:24 pm 
Offline

Joined: Mon Apr 16, 2007 6:34 pm
Posts: 41
Location: Fargo, ND, USA
I've seen those types of errors too. I need to use SAM-BA and erase the whole NAND to make it work again. The flash_eraseall utility doesn't fix it.

Also, I store my kernel and rootfs in DataFlash, and treat it as read only (except for firmware updates). They are loaded into RAM at boot. NAND is only used for state that must be saved across boots. This scheme works very well for my project, but I understand it is a bit limiting. It's nice to know that your system is exactly the same each time you boot.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 05, 2007 9:35 am 
Offline

Joined: Thu Aug 09, 2007 10:48 am
Posts: 106
Location: Artec Design LLC, Tallinn, Estonia
Our devices in Artec use similar approach, but on single flash chip. We have one partition, that is always mounted read-only (although it is still JFFS2); on another partition we write r/w information. This provides some more protection to guarantee, that parts of fs can not be changed that do not need to be changed.
Can't help with the NAND errors as we use here solutions with a single NOR chip.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 08, 2007 10:25 am 
Offline

Joined: Tue Sep 11, 2007 4:59 am
Posts: 7
The errors in my previous post happened at CPU speed of 240MHz. After changing to 200MHz, I encounter the same errors. I've not tried still lower speeds.

_________________
ZJH


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 14 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 21 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: