From: Lars Michael <lh_post@yahoo.com>
To: linux-mtd@lists.infradead.org
Subject: U-Boot: using nand write to flash an ubi image, ubi part fails
Date: Wed, 1 Jun 2011 00:57:07 -0700 (PDT) [thread overview]
Message-ID: <891190.21758.qm@web30201.mail.mud.yahoo.com> (raw)
Hello,
Using mkfs.ubifs and ubinize I have created an image with 5 volumes. In Linux I could flash it using "ubiformat /dev/mtd1 -f /root/ubi.img" and attach it using "ubiattach /dev/ubi_ctrl -m 1". It worked.
In production I would prefer to write the image from U-Boot. So in U-Boot I used "nand erase" then "nand write" to flash the image. Then I want to attach by "ubi part" command - but this fails: "UBI error: ubi_init: UBI error: cannot initialize UBI, error -17"
Then I booted Linux (via nfs) and tried to re-format+attach, but now it fails. Format complains about eraseblock contents and missing erase counters:
ubiformat: warning!: 1099 of 2036 eraseblocks contain non-ubifs data
ubiformat: warning!: only 937 of 2036 eraseblocks have valid erase counter
The ubiattach now reports lots of:
...
UBI error: check_corruption: PEB 0 contains corrupted VID header, and the data does not contain all 0xFF, this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 4
...
I realize that the U-Boot 'nand erase' does not preserve the erase counters. So what would be the correct way to erase and write in U-Boot? And why is the ubiformat not able to correct the problems?
My kernel is 2.6.29 patched with 165 patched from the ubi back port tree.
U-Boot is 2009.08 with ubifs support, but I am not sure if there are relevant patches. The CPU is a v4 ColdFire and 256MB Micron NAND.
Any help is appreciated, thanks. Below are the detailed listing:
-> mtd
device nand0 <NAND>, # parts = 2
#: name size offset mask_flags
0: u-boot 0x00100000 0x00000000 0
1: ubi 0x0ff00000 0x00100000 0
active partition: nand0,0 - (u-boot) 0x00100000 @ 0x00000000
defaults:
mtdids : nand0=NAND
mtdparts: mtdparts=NAND:1m(u-boot),-(ubi)
-> nand erase ubi
NAND erase: device 0 offset 0x100000, size 0xff00000
Erasing at 0x100000 -- 0% complete.
<cut>
Erasing at 0xfd60000 -- 99% complete.
Skipping bad block at 0x0ff80000
Skipping bad block at 0x0ffa0000
Skipping bad block at 0x0ffc0000
Skipping bad block at 0x0ffe0000
OK
Using FEC0 device
TFTP from server 10.28.151.113; our IP address is 10.28.151.112
Filename '/twr5441x/ubi.img'.
Load address: 0x40010000
Loading: *\b#################################################################
#################################################################
<cut>
#################################################################
########################################################
done
Bytes transferred = 58064896 (3760000 hex)
-> md 40010000 100
40010000: 55424923 01000000 00000000 00000000 UBI#............
40010010: 00000800 00001000 27162ae3 00000000 ........'.*.....
40010020: 00000000 00000000 00000000 00000000 ................
40010030: 00000000 00000000 00000000 7d780a89 ............}x..
40010040: ffffffff ffffffff ffffffff ffffffff ................
<cut>
400113f0: 00000000 00000000 00000000 00000000 ................
-> nand write ${loadaddr} 100000 ${filesize}
NAND write: device 0 offset 0x100000, size 0x3760000
58064896 bytes written: OK
-> ubi part ubi
Creating 1 MTD partitions on "nand0":
0x000000100000-0x000010000000 : "mtd=1"
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 126976 bytes
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI warning: process_lvol: volume table copy #1 is corrupted
UBI: create volume table (copy #1)
UBI: volume table was restored
UBI: volume 5 ("datafs") re-sized from 133 to 1316 LEBs
UBI: attached mtd1 to ubi0
UBI: MTD device name: "mtd=1"
UBI: MTD device size: 255 MiB
UBI: number of good PEBs: 2036
UBI: number of bad PEBs: 4
UBI: max. allowed volumes: 128
UBI: wear-leveling threshold: 4096
UBI: number of internal volumes: 1
UBI: number of user volumes: 5
UBI: available PEBs: 0
UBI: total number of reserved PEBs: 2036
UBI: number of PEBs reserved for bad PEB handling: 20
UBI: max/mean erase counter: 5/0
UBI error: ubi_init: cannot attach mtd1
UBI: mtd1 is detached from ubi0
UBI error: ubi_init: UBI error: cannot initialize UBI, error -17
UBI init error -17
exit not allowed from main input shell.
------------------
[root@M54418TWR root]# ubiformat /dev/mtd1 -f /root/ubi.img
ubiformat: mtd1 (NAND), size 267386880 bytes (255.0 MiB), 131072 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 0 -- 0 % complete
...
libscan: scanning eraseblock 2039 -- 100 % complete
ubiformat: 303 eraseblocks have valid erase counter, mean value is 0
ubiformat: 643 eraseblocks are supposedly empty
ubiformat: bad eraseblocks: 2036, 2037, 2038, 2039
ubiformat: warning!: 1090 of 2036 eraseblocks contain non-ubifs data
ubiformat: continue? (yes/no) yes
ubiformat: warning!: only 303 of 2036 eraseblocks have valid erase counter
ubiformat: erase counter 0 will be used for all eraseblocks
ubiformat: note, arbitrary erase counter value may be specified using -e option
ubiformat: continue? (yes/no) yes
ubiformat: use erase counter 0 for all eraseblocks
ubiformat: flashing eraseblock 0 -- 0 % complete
...
ubiformat: flashing eraseblock 442 -- 100 % complete
ubiformat: formatting eraseblock 443 -- 0 % complete
...
ubiformat: formatting eraseblock 2039 -- 100 % complete
[root@M54418TWR root]# ubiattach /dev/ubi_ctrl -m 1
UBI: attaching mtd1 to ubi0
UBI: physical eraseblock size: 131072 bytes (128 KiB)
UBI: logical eraseblock size: 126976 bytes
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI error: check_corruption: PEB 0 contains corrupted VID header, and the data does not contain all 0xFF, this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 4
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 7
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 8
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 12
UBI error: check_corruption: PEB 16 contains corrupted VID header, and the data does not contain all 0xFF, this may be a non-UBI PEB or a severe VID header corruption which requires manual inspection
UBI warning: process_eb: valid VID header but corrupted EC header at PEB 22
...
Thanks,
- Lars
next reply other threads:[~2011-06-01 7:57 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-01 7:57 Lars Michael [this message]
2011-06-01 11:56 ` U-Boot: using nand write to flash an ubi image, ubi part fails Artem Bityutskiy
2011-06-01 11:56 ` [U-Boot] " Artem Bityutskiy
2011-06-01 13:41 ` Ben Gardiner
2011-06-01 13:41 ` [U-Boot] " Ben Gardiner
2011-07-18 9:29 ` Lars Michael
2011-07-18 9:29 ` [U-Boot] " Lars Michael
2011-09-29 2:11 ` Aaron Williams
2011-09-30 3:33 ` Lars Michael
2011-09-30 6:46 ` Aaron Williams
2011-10-01 19:01 ` Lars Michael
2011-09-29 2:43 ` Matthew L. Creech
2011-09-29 2:43 ` [U-Boot] " Matthew L. Creech
2011-09-30 3:44 ` Lars Michael
2011-09-30 3:44 ` [U-Boot] " Lars Michael
2011-10-03 20:36 ` Scott Wood
2011-10-03 20:36 ` Scott Wood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=891190.21758.qm@web30201.mail.mud.yahoo.com \
--to=lh_post@yahoo.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.