UBI and OneNAND
Hi,
Sorry for changing subject. My mail program has some problem.
Quoted 7 lines
Quoted 7 lines
I think the following commands just worked:
mkdir
/mnt/nvm
flash_eraseall/dev/mtd6
mount -t jffs2/dev/mtdblock6/mnt/nvm
Quoted 5 lines
Quoted 2 lines
I wonder whether this is the first attempt to run a kernel using jffs2 and ubi and mtd and onenand and mips? First or not, it seems to work.
Yes, it is. For both onenand and MIPS. That is good news. Thanks for testing!
Umm. I think 'John' just mounts jffs2 without UBI.
I also tried but I can't mount jffs2
It is my sequence.
# mkdir -p /mnt # insmod ubi.ko mtd=3
UBI: attached mtd3 to ubi0
UBI: MTD device name: "rootfs"
UBI: MTD device size: 16 MB
UBI: physical eraseblock size: 131072 bytes (128 KB)
UBI: logical eraseblock size: 126976 bytes
UBI: number of good PEBs: 127
UBI: number of bad PEBs: 1
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: max. allowed volumes: 124
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 0
UBI: available PEBs: 122
UBI: total number of reserved PEBs: 5
UBI: number of PEBs reserved for bad PEB handling: 1
# mount -t jffs2 /dev/mtdblock3 /mnt
/ # mount -t jffs2 /dev/mtdblock3 /tmpjffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000000: 0x4255 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000004: 0x0001 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000003c: 0xcedc id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000800: 0x4255 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000804: 0x0101 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00000808: 0xff7f id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x0000083c: 0x25b8 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x000010a8: 0x16f1 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001154: 0x16f1 id jffs2_scan_eraseblock(): Magic bitmask 0x1985 not found at 0x00001200: 0x16f1 id
...
Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodes empty_blocks 0, bad_blocks 1, c->nr_blocks 128
mount: Mounting /dev/mtdblock3 on /tmp failed: Input/output error
Is it right?
Of course. JFFS2 mount without UBI working well.
Thank you,
Kyungmin Park
Hi,
Quoted 9 lines · 박경민
Hi,
Sorry for changing subject. My mail program has some problem.
Quoted 5 lines
Quoted 5 lines
I think the following commands just worked:
mkdir
/mnt/nvm
flash_eraseall/dev/mtd6
mount -t jffs2/dev/mtdblock6/mnt/nvm
I think there is a missunderstanding here. UBI acts as volume management system. The MTD you connect to UBI cannot be mounted. Instead you create a UBI volume (with ubimkvol) which has an associated mtd which can be used to host a jffs2. This can be mounted than.
Quoted 1 line
Umm. I think 'John' just mounts jffs2 without UBI.
Yes, I agree.
Quoted 7 lines
I also tried but I can't mount jffs2
It is my sequence.
# mkdir -p /mnt # insmod ubi.ko mtd=3
mtd3 is connected with UBI. This mtd is not to be used as rootfs. Instead a UBI volume needs to be created to host the rootfs (see also ubi_jffs2_test.sh).
Example:
ubimkvol -d0 -n10 -tdynamic -NVOL10 -s 1310720
^ ^ ^ ^ ^
| | | | |
| | | | size here in bytes
| | | name of mtd & volume
| | JFFS2/UBI volumes need to be dynamic | Unique volume number
UBI device (you may have multiple, but for me only one made sense)
After this has been executed sucessfully, an mtd named VOL10 should appear.
Mount this with:
mount -t jffs2 mtd:VOL10 /mnt
Quoted 3 lines
UBI: attached mtd3 to ubi0
UBI: MTD device name: "rootfs"
The structure should probably similar like this:
ubimtd
|- rootfs dynamic UBI volume (JFFS2)
|- extra dynamic UBI volume (JFFS2)
|- kernel0 static UBI volume
|- kernel1 static UBI volumeQuoted 16 lines
UBI: MTD device size: 16 MB
UBI: physical eraseblock size: 131072 bytes (128 KB)
UBI: logical eraseblock size: 126976 bytes
UBI: number of good PEBs: 127
UBI: number of bad PEBs: 1
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: max. allowed volumes: 124
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 0
UBI: available PEBs: 122
UBI: total number of reserved PEBs: 5
UBI: number of PEBs reserved for bad PEB handling: 1
Quoted 2 lines
# mount -t jffs2 /dev/mtdblock3 /mnt
Please do not try to mount the mtd you defined to be used by UBI.
Quoted 1 line
From this mtd UBI will take the blocks to run the UBI volumes.
The wearleveling will be accross mtd3 in your case.
Quoted 7 lines
/ # mount -t jffs2
/dev/mtdblock3/tmpjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000000:0x4255idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000004:0x0001idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x0000003c:0xcedcidjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000800:0x4255idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000804:0x0101idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000808:0xff7fid
Quoted 8 lines
jffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x0000083c:0x25b8idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x000010a8:0x16f1idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00001154:0x16f1idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00001200:0x16f1id
...
Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodesempty_blocks0,bad_blocks1,c->nr_blocks128
mount: Mounting/dev/mtdblock3on /tmp failed: Input/output error
Frank
Quoted 14 lines · Frank Haverkamp <haver <at> vnet.ibm.com> writes:
Hi,
Quoted 9 lines · 박경민
Hi,
Sorry for changing subject. My mail program has some problem.
Quoted 5 lines
Quoted 5 lines
I think the following commands just worked:
mkdir
/mnt/nvm
flash_eraseall/dev/mtd6
mount -t jffs2/dev/mtdblock6/mnt/nvm
Quoted 8 lines
I think there is a missunderstanding here. UBI acts as volume management system. The MTD you connect to UBI cannot be mounted. Instead you create a UBI volume (with ubimkvol) which has an associated mtd which can be used to host a jffs2. This can be mounted than.
Quoted 1 line
Umm. I think 'John' just mounts jffs2 without UBI.
Yes, I agree.
My original explanation was incomplete. Here is a fuller version.
The MTD code is compiled into the kernel, rather than as a kernel module. The kernel command line includes:
ubi.mtd=4
At boot time, the following is reported to the console:
Using static partition definition
Creating 2 MTD partitions on "Arrow 1504 Flash":
0x00000000-0x00c00000 : "BootLoader" 0x00c00000-0x01000000 : "OldCFE"
OneNAND 16MB 2.65/3.3V 16-bit (0x05) Scanning device for bad blocks
Creating 4 MTD partitions on "Arrow-Onenand":
0x00000000-0x00100000 : "CFE" 0x00100000-0x00500000 : "Kernel" 0x00500000-0x00ff0000 : "rootfs" 0x00ff0000-0x01000000 : "CFE-NVM"
UBI: background thread "ubi_bgt0d" started, PID 14
UBI: mean erase counter: 1
UBI: attached mtd4 to ubi0
UBI: MTD device name: "rootfs"
UBI: MTD device size: 10 MB
UBI: physical eraseblock size: 65536 bytes (64 KB)
UBI: logical eraseblock size: 63488 bytes
UBI: number of good PEBs: 175
UBI: number of bad PEBs: 0
UBI: smallest flash I/O unit: 1024
UBI: VID header offset: 1024 (aligned 1024)
UBI: data offset: 2048
UBI: max. allowed volumes: 128
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 1
UBI: available PEBs: 49
UBI: total number of reserved PEBs: 126
UBI: number of PEBs reserved for bad PEB handling: 1
##
## Then with the busybox shell I can list the MTD partitions ##
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00c00000 00020000 "BootLoader" <<< Nor Flash
mtd1: 00400000 00020000 "OldCFE" <<< Nor Flash
mtd2: 00100000 00010000 "CFE" <<< OneNAND Flash
mtd3: 00400000 00010000 "Kernel" <<< OneNAND Flash
mtd4: 00af0000 00010000 "rootfs" <<< OneNAND Flash
mtd5: 00010000 00010000 "CFE-NVM" <<< OneNAND Flash
mtd6: 00753800 0000f800 "Kernel" <<< UBI Partition on mtd4:
##
## I ceate a new 2M byte UBI Volume ##
/ # ubimkvol -s 2000000 -N NVM -d 0
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00c00000 00020000 "BootLoader"
mtd1: 00400000 00020000 "OldCFE"
mtd2: 00100000 00010000 "CFE"
mtd3: 00400000 00010000 "Kernel"
mtd4: 00af0000 00010000 "rootfs"
mtd5: 00010000 00010000 "CFE-NVM"
mtd6: 00753800 0000f800 "Kernel"
mtd7: 001f0000 0000f800 "NVM" <<< New UBI Partition
##
## Look at existing devices
##
/ # ls -l /dev/mtdblock?
brw-r----- 1 0 0 31, 0 Jan 1 00:00 /dev/mtdblock0 brw-r----- 1 0 0 31, 1 Jan 1 00:00 /dev/mtdblock1 brw-r----- 1 0 0 31, 2 Jan 1 00:00 /dev/mtdblock2 brw-r----- 1 0 0 31, 3 Jan 1 00:00 /dev/mtdblock3
##
## Create a new device for my new partition ## (I do not have the udev tools installed) ##
/ # mknod /dev/mtdblock7 b 31 7
##
## Mount my new JFFS2/UBI partition
## (Note the erase size is further confirmation that I have a UBI partition) ##
/ # mkdir /mnt/nvm
/ # mount -t jffs2 /dev/mtdblock7 /mnt/nvm
JFFS2 write-buffering enabled buffer (1024) erasesize (63488)
##
## Copy a file to the JFFS2 Partition ##
/ # cp /my_module.ko /mnt/nvm
##
## Check it
##
/ # md5sum /my_module.ko /mnt/nvm/my_module.ko bbb66a91c259fe42290bfa2952b2265f /my_module.ko bbb66a91c259fe42290bfa2952b2265f /mnt/nvm/my_module.ko
##
## Unmount the jffs2 partition
##
/ # umount /mnt/nvm
##
## Check the file has gone away
##/mnt/nfs/ubi-tools # md5sum /my_module.ko /mnt/nvm/my_module.ko bbb66a91c259fe42290bfa2952b2265f /my_module.ko
##
## Power cycle, and let the box boot up again ##
Using static partition definition
Creating 2 MTD partitions on "Arrow 1504 Flash":
0x00000000-0x00c00000 : "BootLoader" 0x00c00000-0x01000000 : "OldCFE"
OneNAND 16MB 2.65/3.3V 16-bit (0x05) Scanning device for bad blocks
Creating 4 MTD partitions on "Arrow-Onenand":
0x00000000-0x00100000 : "CFE" 0x00100000-0x00500000 : "Kernel" 0x00500000-0x00ff0000 : "rootfs" 0x00ff0000-0x01000000 : "CFE-NVM"
UBI: background thread "ubi_bgt0d" started, PID 14
UBI: mean erase counter: 1
UBI: attached mtd4 to ubi0
UBI: MTD device name: "rootfs"
UBI: MTD device size: 10 MB
UBI: physical eraseblock size: 65536 bytes (64 KB)
UBI: logical eraseblock size: 63488 bytes
UBI: number of good PEBs: 175
UBI: number of bad PEBs: 0
UBI: smallest flash I/O unit: 1024
UBI: VID header offset: 1024 (aligned 1024)
UBI: data offset: 2048
UBI: max. allowed volumes: 128
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 2 <<< this time there is an extra partition
UBI: available PEBs: 17
UBI: total number of reserved PEBs: 158
UBI: number of PEBs reserved for bad PEB handling: 1
BusyBox v1.00 (2006.08.30-22:06+0000) Built-in shell (ash) Enter 'help' for a list of built-in commands.
/ # cat /proc/mtd
dev: size erasesize name
mtd0: 00c00000 00020000 "BootLoader" << Nor
mtd1: 00400000 00020000 "OldCFE" << Nor
mtd2: 00100000 00010000 "CFE" << OneNAND
mtd3: 00400000 00010000 "Kernel" << OneNAND
mtd4: 00af0000 00010000 "rootfs" << OneNAND
mtd5: 00010000 00010000 "CFE-NVM" << OneNAND
mtd6: 001f0000 0000f800 "NVM" << UBI on mtd4:
mtd7: 00753800 0000f800 "Kernel" << UBI on mtd4:
/ # mknod /dev/mtdblock6 b 31 6
/ # mount -t jffs2 /dev/mtdblock6 /mnt/nvm
JFFS2 write-buffering enabled buffer (1024) erasesize (63488)
##
## Check the file in the jffs2 partition
##
/ # md5sum /mnt/nvm/my_module.ko bbb66a91c259fe42290bfa2952b2265f /mnt/nvm/my_module.ko / # md5sum /my_module.ko bbb66a91c259fe42290bfa2952b2265f /my_module.ko
So I am convinced.
Of course, the credit belongs to all who wrote the code. Thanks,
John Smith
Hi, few notes:
Quoted 8 lines · John Smith
UBI: data offset: 2048
UBI: max. allowed volumes: 128
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 1
UBI: available PEBs: 49
UBI: total number of reserved PEBs: 126
UBI: number of PEBs reserved for bad PEB handling: 1
Hmm, only one PEB is reserved, may be it makes sense to reserve more - there is a corresponding option.
Quoted 6 lines
##
## Then with the busybox shell I can list the MTD partitions ##
Quoted 9 lines
/ # cat
/proc/mtd
dev: size erasesize name
mtd0:00c0000000020000 "BootLoader" <<< Nor Flash
mtd1: 00400000 00020000 "OldCFE" <<< Nor Flash
mtd2: 00100000 00010000 "CFE" <<< OneNAND Flash
mtd3: 00400000 00010000 "Kernel" <<< OneNAND Flash
mtd4:00af000000010000 "rootfs" <<< OneNAND Flash
mtd5: 00010000 00010000 "CFE-NVM" <<< OneNAND Flash
mtd6: 007538000000f800"Kernel" <<< UBI Partition on mtd4:
I would recommend you to use unique names for MTD partitions. You have two "kernel" partitions.
Quoted 8 lines
##
## Look at existing devices
##
/ # ls -l/dev/mtdblock?brw-r----- 1 0 0 31, 0 Jan 1 00:00 /dev/mtdblock0 brw-r----- 1 0 0 31, 1 Jan 1 00:00 /dev/mtdblock1 brw-r----- 1 0 0 31, 2 Jan 1 00:00 /dev/mtdblock2 brw-r----- 1 0 0 31, 3 Jan 1 00:00 /dev/mtdblock3
Yo do not need mtdblock devices to mount JFFS2 at all. JFFS2 anyway works with MTD devices directly and this is just an old way to mount JFFS2. /dev/mtdX are character devices and you cannot feed the mount utility by character devices, so this is why fake block devices were used. Nowadays there is device-less mount support and you may use:
mount mtd7 /mnt/nvm
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 11 lines · Artem Bityutskiy
Hi, few notes:
Quoted 8 lines · John Smith
UBI: data offset: 2048
UBI: max. allowed volumes: 128
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 1
UBI: available PEBs: 49
UBI: total number of reserved PEBs: 126
UBI: number of PEBs reserved for bad PEB handling: 1
Quoted 2 lines
Hmm, only one PEB is reserved, may be it makes sense to reserve more - there is a corresponding option.
It's the default. I think it's too low of a default. Others disagreed with me.
Telling every new UBI user "may be it makes sense to reserve more" will get old quick. Perhaps the default should be bumped to 5 or so?
josh
Quoted 5 lines · Josh Boyer
It's the default. I think it's too low of a default. Others disagreed with me.
Telling every new UBI user "may be it makes sense to reserve more" will get old quick. Perhaps the default should be bumped to 5 or so?
Actually with 128MiB flash the default ends up with something like 32EBs, which looks even too large, so I do not know...
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 9 lines · Artem Bityutskiy
Quoted 5 lines · Josh Boyer
It's the default. I think it's too low of a default. Others disagreed with me.
Telling every new UBI user "may be it makes sense to reserve more" will get old quick. Perhaps the default should be bumped to 5 or so?
Actually with 128MiB flash the default ends up with something like 32EBs, which looks even too large, so I do not know...
What are you talking about?
(128MiB/128KiB) * .01 = 10.24
So you'd end up with 10EB.
Perhaps we should change MTD_UBI_BEB_RESERVE to be an actual number of eraseblocks instead of a percent of the device. So MTD_UBI_BEB_RESERVE=1 would mean 1 EB, =10 would mean 10.
josh
Quoted 5 lines · Josh Boyer
What are you talking about?
(128MiB/128KiB) * .01 = 10.24
So you'd end up with 10EB.
Yeah, but somebody showed me UBI on 128 MiB flashes with 32 or 64 KiB eraseblocks. Probably EB size should be taken into account.
Quoted 3 lines
Perhaps we should change
MTD_UBI_BEB_RESERVEto be an actual number of eraseblocks instead of a percent of the device. So MTD_UBI_BEB_RESERVE=1 would mean 1 EB, =10 would mean 10.
My concern is a dumb user who may not realize what to enter there.
But may be you are right... If user does not set the number of reserved PEBs explicitly, we could use some percentage as a default value.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 35 lines · 박경민
Hi,
Sorry for changing subject. My mail program has some problem.
Quoted 7 lines
Quoted 7 lines
I think the following commands just worked:
mkdir
/mnt/nvm
flash_eraseall/dev/mtd6
mount -t jffs2/dev/mtdblock6/mnt/nvmQuoted 5 lines
Quoted 2 lines
I wonder whether this is the first attempt to run a kernel using jffs2 and ubi and mtd and onenand and mips? First or not, it seems to work.
Yes, it is. For both onenand and MIPS. That is good news. Thanks for testing!
Umm. I think 'John' just mounts jffs2 without UBI.
I also tried but I can't mount jffs2
It is my sequence.
# mkdir -p /mnt # insmod ubi.ko mtd=3UBI: attached mtd3 to ubi0
UBI: MTD device name: "rootfs"
UBI: MTD device size: 16 MB
UBI: physical eraseblock size: 131072 bytes (128 KB)
UBI: logical eraseblock size: 126976 bytes
UBI: number of good PEBs: 127
UBI: number of bad PEBs: 1
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
Quoted 9 lines
UBI: data offset: 4096
UBI: max. allowed volumes: 124
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 0
UBI: available PEBs: 122
UBI: total number of reserved PEBs: 5
UBI: number of PEBs reserved for bad PEB handling: 1
May I kindly ask you to do the following:
1. Enable "UBI debugging" option
2. Go to "UBI debugging messages --->" and enable:
a "User interface unit messages"
b "Messages from the gluebi sub-unit"
c "Volume management unit messages"
d "Eraseblock association unit messages"
Then try to mount JFFS2.
Then do:
# mount -t debugfs none /mnt/debugfs # cat /mnt/debugfs/ubi/log > log
and send me the log file.
Also see http://www.linux-mtd.infradead.org/faq/ubi.html#L_how_debug
which is a bit out-of-date but still may be helpful.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)
Quoted 23 lines · 박경민
It is my sequence.
# mkdir -p /mnt # insmod ubi.ko mtd=3UBI: attached mtd3 to ubi0
UBI: MTD device name: "rootfs"
UBI: MTD device size: 16 MB
UBI: physical eraseblock size: 131072 bytes (128 KB)
UBI: logical eraseblock size: 126976 bytes
UBI: number of good PEBs: 127
UBI: number of bad PEBs: 1
UBI: smallest flash I/O unit: 2048
UBI: VID header offset: 2048 (aligned 2048)
UBI: data offset: 4096
UBI: max. allowed volumes: 124
UBI: wear-levelling threshold: 4096
UBI: number of internal volumes: 2
UBI: number of user volumes: 0
UBI: available PEBs: 122
UBI: total number of reserved PEBs: 5
UBI: number of PEBs reserved for bad PEB handling: 1
Quoted 1 line
# mount -t jffs2 /dev/mtdblock3 /mnt
This is incorrect. MTD3 now belongs to UBI only. Do not try to do anything with it. You can only create UBI volumes now, and mount the _volumes_!
Quoted 16 lines
/ # mount -t jffs2
/dev/mtdblock3/tmpjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000000:0x4255idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000004:0x0001idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x0000003c:0xcedcidjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000800:0x4255idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000804:0x0101idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00000808:0xff7fidjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x0000083c:0x25b8idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x000010a8:0x16f1idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00001154:0x16f1idjffs2_scan_eraseblock(): Magic bitmask0x1985not found at0x00001200:0x16f1id
...
Cowardly refusing to erase blocks on filesystem with no valid JFFS2 nodesempty_blocks0,bad_blocks1,c->nr_blocks128
mount: Mounting/dev/mtdblock3on /tmp failed: Input/output error
Of course it is expected. UBI writes its headers to MTD3 and you try to feed it to JFFS2. Do not do this.
Signature · 2 lines
Best regards, Artem Bityutskiy (Битюцкий Артём)