2008-06-05 05:26:53 cannot successfully use NAND flash fs on BF548 EZ-Kit
Norbert van Bolhuis (NETHERLANDS)
Message: 56726
On my BF548 EZ-Kit lite, I cannot properly use a NAND flash filesystem.
On startup the kernel shows:
.
.
BF5xx on-chip NAND FLash Controller Driver, Version 1.2 (c) 2007 Analog Devices, Inc.
bf5xx-nand bf5xx-nand.0: page_size=256, data_width=8, wr_dly=3, rd_dly=3
NAND device: Manufacturer ID: 0x20, Chip ID: 0xda (ST Micro NAND 256MiB 3,3V 8-bit)
Creating 2 MTD partitions on "NAND 256MiB 3,3V 8-bit":
0x00000000-0x00400000 : "Linux Kernel"
0x00400000-0x10000000 : "File System"
.
.
Most of the NAND parameters are configured in
"arch/blackfin/mach-bf548/boards/ezkit.c", obviously I've not modified
them (apart from the 2 partitions).
When I do the following (for jffs2):
eraseall /dev/mtd2
mount /dev/mtdblock2 /flashfs -t jffs2
and start manipulating files/directories under /flashfs
it hangs/stalls!
for yaffs2 I tried to do:
eraseall /dev/mtd2
mkyaffs -e /dev/mtd2
mount /dev/mtdblock2 /flashfs -t yaffs
but the mkyaffs command fails:
root:/> mkyaffs /dev/mtd2
argc 2 sh 0 optcnt 1
MEMSETOOBSEL: Inappropriate ioctl for device
therefore I just mount yaffs without successfully executing mkyaffs.
No matter whether I use jffs2 of yaffs (which auto selects to yaffs2)
my filesystem testscript (which is attached to this msg) hangs.
2 out of 3 it went wrong with jffs2, with yaffs2 it went wrong 2 out of 2
My BF548 EZ-Kit NAND chip has 3 bad blocks (which yaffs2/jffs2 should
properly cope with).
Am I doing something wrong in setting up my jffs2/yaffs NAND filesystem ?
or is this a (known) BF uClinux problem ?
testcf.sh
QuoteReplyEditDelete
2008-06-11 18:19:57 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Mike Frysinger (UNITED STATES)
Message: 57047
erasing and then mounting as jffs2 works fine for me ... i copied all of /bin to the jffs2 and was able to do things there. what you may be describing is that jffs2 has some initial delays while it syncs state on the filesystem. it doesnt hang the system though. you can telnet into the board and run programs to check.
as for the yaffs error, i see the same ... i'll have to fiddle with it.
QuoteReplyEditDelete
2008-06-11 18:53:31 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Mike Frysinger (UNITED STATES)
Message: 57049
`mkyaffs` is only for creating YAFFS filesystems ... it is not needed for YAFFS2. just do:
mount -t yaffs2 /dev/mtdblock0 /mnt
QuoteReplyEditDelete
2008-06-13 08:38:03 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Ernst van der Plas (NETHERLANDS)
Message: 57234
I am a collegue of Norbert. I tried the Nike's mount command. But on our board it does not work unless you specify:
mount /dev/mtdblock2 /flashfs -t yaffs
The system then responds by saying that yaffs2 is the default and that it wil use that. Which is fine by me.
Regarding the problem with the jffs2 / yaffs we had. I have done some more test and compiled the kernel wiht jffs2 debug set to 1. Erased the flash and tried to copy a root.tar file to it via tftp.
root:/> eraseall //dev/mtd2
Erasing 128 Kibyte @ 2c00000 -- 1 %nand_erase: attempt to erase a bad block at page 0x00006e40
Erasing 128 Kibyte @ 3320000 -- 4 % complete.
eraseall: //dev/mtd2: MTD Erase failure: Input/output error
Erasingnand_erase: attempt to erase a bad block at page 0x0000ae40
Erasing 128 Kibyte @ 52a0000 -- 0 % complenand_erase: attempt to erase a bad block at page 0x0000ae80
Erasing 128 Kibyte @ 5320000 -- 0 % complete.
eraseall: //dev/mtd2: MTD Erase failure: Input/output error
Erasing 128 Kibyte @ 5340000 -- 0 % complete.
eraseall: //dev/mtd2: MTD Erase failure: Input/output error
Erased 258048 Kibyte @ 0 -- 100% complete.
root:/> mount /dev/mtdblock2 /flashfs -t jffs2
JFFS2 version 2.2. (NAND) (SUMMARY)  2001-2006 Red Hat, Inc.
JFFS2: default compression mode: priority
JFFS2: Block at 0x03320000 is bad
JFFS2: Block at 0x05320000 is bad
JFFS2: Block at 0x05340000 is bad
root:/> cd /flashfs
root:/flashfs> tftp -l root.tar -r root.tar -g 10.10.4.168
jffs2: No clean, dirty _or_ erasable blocks to GC from! Where are they all?
jffs2: Couldn't find erase block to garbage collect!
At this point the system does not respond to commands related to the flash. Commands suchs as ls, cat, etc...
The last end of dmesg:
jffs2_thread_should_wake(): nr_free_blocks 1954, nr_erasing_blocks 0, dirty_size 0x3e72d0: no
increasing writtenlen by 512
jffs2_commit_write() returning 0
jffs2_prepare_write()
end prepare_write(). pg->flags 6d
jffs2_commit_write(): ino #2, page at 0x55f000, range 3584-4096, flags 6d
jffs2_write_inode_range(): Ino #2, ofs 0x55f000, len 0x1000
jffs2_reserve_space(): Requested 0xc4 bytes
jffs2_reserve_space(): alloc sem got
[JFFS2 DBG] (239) jffs2_do_reserve_space: minsize=196 , jeb->free=104276 ,summary->size=864 , sumsize=18
jffs2_do_reserve_space(): Giving 0x193b8 bytes at 0xf4868ac
calling deflate with avail_in 4084, avail_out 4084
deflate returned with avail_in 0, avail_out 1546, total_in 4084, total_out 2538
calling deflate with avail_in 12, avail_out 1546
deflate returned with avail_in 0, avail_out 1536, total_in 4096, total_out 2548
zlib compressed 4096 bytes into 2554
jffs2_write_super()
jffs2_thread_should_wake(): nr_free_blocks 1954, nr_erasing_blocks 0, dirty_size 0x3e72d0: no
jffs2_erase_pending_blocks completed
jffs2_flush_wbuf_gc() called for ino #0...
root:/>
I waited here for about 30 minutes but no change.
I can still ping/login the system but cannot do anything with the /flashfs directory or with the
/dev/mtd2 device. I also tftp'd the root.tar to the ramfs on / and then moved the root.tar to
the /flashfs (on jffs2). During the copy the system becomes not responsive. The tftp process
had a status "D" when running top.
The next snipped is from when I copied the root.tar to ramfs and then moved
it to the flash. The end result is the same after the 7'th copy.
root:/> mv root.tar /flashfs
root:/> cd /flashfs
root:/flashfs> ls
root.tar
root:/flashfs> cp root.tar root.tar1
root:/flashfs> cp root.tar root.tar2
root:/flashfs> cp root.tar root.tar3
root:/flashfs> cp root.tar root.tar4
root:/flashfs> cp root.tar root.tar5
root:/flashfs> cp root.tar root.tar6
root:/flashfs> cp root.tar root.tar7
Next I tried different ways to use the flash. All with the same result. For
example "ls" and "cat root.tar >> monkey". At a certain moment the command does
not return and all the commands that relate to the flash do not return.
Since yaffs and jffs had the same problem I tested the mtdblock2 driver.
root:/> dd if=/dev/mtdblock2 of=/aap count=50K
51200+0 records in
51200+0 records out
root:/> ls -l
-rw-r--r-- 1 root root 26214400 Jan 3 14:14 aap
drwxr-xr-x 2 root root 0 Jan 1 2007 bin
drwxr-xr-x 4 root root 0 Jan 3 14:14 dev
drwxr-xr-x 5 root root 0 Jan 1 2007 etc
drwxr-xr-x 2 root root 0 Jan 3 14:14 flashfs
drwxr-xr-x 3 root root 0 Jan 1 2007 home
-rwxr-xr-x 1 root root 2090 Jan 1 2007 init
drwxr-xr-x 3 root root 0 Jan 1 2007 lib
drwxr-xr-x 2 root root 0 Jan 1 2007 mnt
dr-xr-xr-x 33 root root 0 Jan 1 2007 proc
drwxr-xr-x 2 root root 0 Jan 1 2007 root
lrwxrwxrwx 1 root root 3 Jan 1 2007 sbin -> bin
drwxr-xr-x 10 root root 0 Jan 1 2007 sys
drwxrwxrwt 2 root root 0 Jan 1 2007 tmp
drwxr-xr-x 4 root root 0 Jan 1 2007 usr
drwxr-xr-x 6 root root 0 Jan 3 14:14 var
root:/> eraseall /dev/mtd2
Erasing 128 Kibyte @ 2c00nand_erase: attempt to erase a bad block at page
0x00006e40
Erasing 128 Kibyte @ 3320000 -- 4 % complete.
eraseall: /dev/mtd2: MTD Erase failure: Input/output error
Erasing 128 Kibyte @ 4860000 -- 12 % nand_erase: attempt to erase a bad block
at page 0x0000ae40
Erasing 128 Kibyte @ 52a00nand_erase: attempt to erase a bad block at page
0x0000ae80
Erasing 128 Kibyte @ 5320000 -- 0 % complete.
eraseall: /dev/mtd2: MTD Erase failure: Input/output error
Erasing 128 Kibyte @ 5340000 -- 0 % complete.
eraseall: /dev/mtd2: MTD Erase failure: Input/output error
Erased 258048 Kibyte @ 0 -- 100% complete.
root:/> dd if=/aap of=/dev/mtdblock2 count=50K
At this point the system does not respond anymore to flash related commands.
The out put of the top command:
Mem: 46736K used, 13728K free, 0K shrd, 6768K buff, 33184K cached
Load average: 1.94 1.01 0.40
PID USER STATUS VSZ PPID %CPU %MEM COMMAND
234 root R 876 233 0.3 1.4 top
1 root S 968 0 0.0 1.5 init
224 root S 968 1 0.0 1.5 sh
233 root S 968 232 0.0 1.5 sh
231 root D 872 224 0.0 1.4 dd
232 root S 508 227 0.0 0.8 telnetd
227 root S 484 224 0.0 0.7 inetd
163 root DW< 0 2 0.0 0.0 mtdblockd
50 root SW 0 2 0.0 0.0 pdflush
5 root SW< 0 2 0.0 0.0 khelper
36 root SW< 0 2 0.0 0.0 kblockd/0
4 root SW< 0 2 0.0 0.0 events/0
2 root SW< 0 0 0.0 0.0 kthreadd
52 root SW< 0 2 0.0 0.0 aio/0
53 root SW< 0 2 0.0 0.0 cifsoplockd
54 root SW< 0 2 0.0 0.0 cifsdnotifyd
3 root SWN 0 2 0.0 0.0 ksoftirqd/0
179 root SW< 0 2 0.0 0.0 bfin-spi.0
185 root SW< 0 2 0.0 0.0 bfin-spi.1
37 root SW< 0 2 0.0 0.0 ata/0
38 root SW< 0 2 0.0 0.0 ata_aux
It does not always go wrong. Sometimes it works fine:
root:/> dd if=/dev/mtdblock2 of=/aap count=10K
10240+0 records in
10240+0 records out
root:/> dd if=/dev/mtdblock2 of=/aap1 count=10K
10240+0 records in
10240+0 records out
root:/> dd if=/dev/mtdblock2 of=/aap2 count=10K
10240+0 records in
10240+0 records out
root:/> dd if=/dev/mtdblock2 of=/aap2 count=10K skip=10K
10240+0 records in
10240+0 records out
root:/> dd if=/dev/mtdblock2 of=/aap2 count=10K skip=50K
10240+0 records in
10240+0 records out
root:/> dd if=/aap of=/dev/mtdblock2 count=10K
10240+0 records in
10240+0 records out
root:/> dd if=/aap of=/dev/mtdblock2 count=10K seek=10K
10240+0 records in
10240+0 records out
root:/> dd if=/aap of=/dev/mtdblock2 count=10K seek=20K
10240+0 records in
10240+0 records out
root:/> dd if=/aap of=/dev/mtdblock2 count=10K seek=30K
10240+0 records in
10240+0 records out
root:/> dd if=/aap2 of=/dev/mtdblock2 count=50K seek=30K
10240+0 records in
10240+0 records out
root:/> dd if=/aap2 of=/dev/mtdblock2 count=50K
10240+0 records in
10240+0 records out
root:/> dd if=/aap2 of=/dev/mtdblock2 count=50K seek=50K
10240+0 records in
10240+0 records out
We have 2 bf548-EZkit boards. Both have the same problem. But one of them has it
about 20 times more than the other. Do you have any suggestions or thoughts
that may help us ?
QuoteReplyEditDelete
2008-06-13 10:43:21 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Bryan Wu (CHINA)
Message: 57239
I'd like to fire a bug for me to track this issue.
For me, I did not fully test JFFS2 on NAND of BF548-EZKIT, but YAFFS2 should be OK. I remember the mtd-util in svn maybe was out of date. I'll try to fix this issue, so please fire a bug for me.
And I noticed that mike update the mtd-util and yaffs-util in svn trunk, so Mike, did you make any progress with this issue?
-Bryan
QuoteReplyEditDelete
2008-06-13 15:06:27 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Mike Frysinger (UNITED STATES)
Message: 57258
i just tesed the new version of mtd-utils ... flash_eraseall and then mounting the jffs2 and copying a few megs onto it seemed to work on my ezkit
QuoteReplyEditDelete
2008-06-20 06:20:21 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Norbert van Bolhuis (NETHERLANDS)
Message: 57622
I doubt whether this problem has anything to do with mtd-utils.
mtd-utils contains powerfull *user-space* tools for MTD devices.
Our problem seems to be the mtdblock driver inside the uClinux kernel
which controlls the NAND chip on our BF548 EZ-Kit.
Even when using the mtdblock driver directly (before using any mtd-util tool),
our BF548 EZ-Kit hangs.
This explains why extensively using the JFFS2 and YAFFS2 filesystem (on
top of the mtdblock driver) results in the same problem.
If this problem cannot be reproduced on other BF548 EZ-Kits it's most likely
hardware (related).
My gut feeling is that there's some kind of race condition or deadlock somewhere
in the blackfin MTD/NAND block driver. Maybe it triggers only when the NAND chip
behaves "bad"/"slow".
QuoteReplyEditDelete
2008-06-26 11:00:04 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Norbert van Bolhuis (NETHERLANDS)
Message: 57923
It looks like CONFIG_DEB_DMA_URGENT makes a difference.
With this option enabled the problem cannot be reproduced (so far).
Mike, did you enable this option while doing your test ?
Anybody know what and more importantly *why* this option would
make any difference ?
QuoteReplyEditDelete
2008-06-26 14:19:12 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Mike Frysinger (UNITED STATES)
Message: 57934
i'm pretty sure i did not. i was using the default config (which has that option turned off).
i'm using a BF548-EZKIT with 0.1 silicon. are you ?
QuoteReplyEditDelete
2008-06-30 09:46:19 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Norbert van Bolhuis (NETHERLANDS)
Message: 58122
OK, thanks.
Yes we use rev 0.1 too ("ADSP-BF549 1276606.1 A-0.1" to be precise).
Is there a bug tracking this problem ?
QuoteReplyEditDelete
2008-06-30 10:02:52 Re: cannot successfully use NAND flash fs on BF548 EZ-Kit
Mike Frysinger (UNITED STATES)
Message: 58126
no one here is experiencing a problem so we havent filed a bug