This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

unable to attach ubi image

Hi,
We are trying to boot from Nand device for Am335x evmboard. We are using Micron MT29F4G08ABADAWP Nand, 512MiB.
While booting from Nand we are getting kernel panic error.
We have followed the below mentioned steps.
1.Created a ubifs.img using the following command
mkfs.ubifs -v -r /home/sachin/sdk6/targetNFS/ -m 2048 -e 126976 -c 4030 -o ubifs.img
o/p we got was:
mkfs.ubifs
root:         /sdk6/targetNFS/
min_io_size:  2048
leb_size:     126976
max_leb_cnt:  4030
output:       ubifs.img
jrn_size:     8388608
reserved:     0
compr:        lzo
keyhash:      r5
fanout:       8
orph_lebs:    1
super lebs:   1
master lebs:  2
log_lebs:     5
lpt_lebs:     2
orph_lebs:    1
main_lebs:    2723
gc lebs:      1
index lebs:   33
leb_cnt:      2734
UUID:         6B5E0208-BD1D-4F6E-9AA8-FD5CF37C7B85
Success!
2. Edited the ubi.ini file as shown below:
[rootfs-volume]
mode=ubi
image=ubifs.img
vol_id=0
vol_size=350MiB
vol_type=dynamic
vol_name=rootfs
vol_flags=autoresize
3.Created a ubi.img using the following command
ubinize -v -o ubi -m 2048 -p 128KiB -s 2048 ubi.ini
   o/p:
ubinize: LEB size:                  126976
ubinize: PEB size:                  131072
ubinize: min. I/O size:             2048
ubinize: sub-page size:             2048
ubinize: VID offset:                2048
ubinize: data offset:               4096
ubinize: UBI image sequence number: 968051357
ubinize: loaded the ini-file "ubi.ini"
ubinize: count of sections: 1
ubinize: parsing section "rootfs-volume"
ubinize: mode=ubi, keep parsing
ubinize: volume type: dynamic
ubinize: volume ID: 0
ubinize: volume size: 367001600 bytes
ubinize: volume name: rootfs
ubinize: volume alignment: 1
ubinize: autoresize flags found
ubinize: adding volume 0
ubinize: writing volume 0
ubinize: image file: ubifs.img
ubinize: writing layout volume
ubinize: done
4. After this we used ubiformat -y /dev/mtd7 -f ubi on the custom board 
   o/p:
ubiformat: mtd7 (nand), size 529006592 bytes (504.5 MiB), 4036 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 4035 -- 100 % complete  
ubiformat: 4036 eraseblocks have valid erase counter, mean value is 1
ubiformat: flashing eraseblock 2735 -- 100 % complete  
ubiformat: formatting eraseblock 4035 -- 100 % complete 
5. After this we have given ubiattach /dev/ubi_ctrl -m 7 -O 2048 and we got segmentation fault as shown below:
[  379.078186] UBI: attaching mtd7 to ubi0
[  379.082244] UBI: physical eraseblock size:   131072 bytes (128 KiB)
[  379.088836] UBI: logical eraseblock size:    126976 bytes
[  379.094482] UBI: smallest flash I/O unit:    2048
[  379.099395] UBI: VID header offset:          2048 (aligned 2048)
[  379.105651] UBI: data offset:                4096
[  382.791137] UBI: max. sequence number:       0
[  382.841979] UBI: volume 0 ("rootfs") re-sized from 2891 to 4030 LEBs
[  382.853027] UBI: attached mtd7 to ubi0
[  382.856964] UBI: MTD device name:            "File System"
[  382.862701] UBI: MTD device size:            504 MiB
[  382.867858] UBI: number of good PEBs:        4036
[  382.872772] UBI: number of bad PEBs:         0
[  382.877410] UBI: number of corrupted PEBs:   0
[  382.882049] UBI: max. allowed volumes:       128
[  382.886871] UBI: wear-leveling threshold:    4096
[  382.891754] UBI: number of internal volumes: 1
[  382.896392] UBI: number of user volumes:     1
[  382.901031] UBI: available PEBs:             0
[  382.905670] UBI: total number of reserved PEBs: 4036
[  382.910827] UBI: number of PEBs reserved for bad PEB handling: 2
[  382.917114] UBI: max/mean erase counter: 4/2
[  382.921539] UBI: image sequence number:  745468806
[  382.927124] UBI: background thread "ubi_bgt0d" started, PID 1632
[  382.967681] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[  382.976196] pgd = df500000
[  382.979034] [00000000] *pgd=9f418831, *pte=00000000, *ppte=00000000
[  382.985595] Internal error: Oops: 17 [#1]
[  382.989776] Modules linked in:
[  382.992950] CPU: 0    Not tainted  (3.2.0 #55)
[  382.997589] PC is at ubi_leb_read+0x10/0x124
[  383.002044] LR is at gluebi_read+0xa4/0xe0
[  383.006317] pc : [<c0261bb8>]    lr : [<c026ba74>]    psr: 20000013
[  383.006317] sp : df543bd0  ip : df543c08  fp : df543c04
[  383.018280] r10: 00000000  r9 : 00000000  r8 : 00000044
[  383.023742] r7 : dd8b7c00  r6 : df543c64  r5 : 00000044  r4 : 00000044
[  383.030548] r3 : 00000000  r2 : df543c64  r1 : 00000000  r0 : 00000000
[  383.037353] Flags: nzCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[  383.044769] Control: 10c5387d  Table: 9f500019  DAC: 00000015
[  383.050781] Process ubiattach (pid: 1631, stack limit = 0xdf5422f0)
[  383.057312] Stack: (0xdf543bd0 to 0xdf544000)
[  383.061828] 3bc0:                                     c04c4f9c c00803b8 df543bfc 000000d0
[  383.070373] 3be0: 000000d0 00000044 00000044 df543c64 dd8b7c00 00000044 df543c3c df543c08
[  383.078887] 3c00: c026ba74 c0261bb4 00000044 00000000 df543c3c 00000000 00000000 dd8b7c00
[  383.087432] 3c20: df543c64 df543c60 00000044 dd95cf00 df543cd4 df543c40 c023d17c c026b9dc
[  383.095947] 3c40: 00000044 df543c60 df543c64 c020ae54 c06fe8a0 c06fe388 00100000 00000000
[  383.104492] 3c60: df53ab08 df53aa00 c0741668 df53aa00 c06fe388 00000000 00000000 05a00011
[  383.113006] 3c80: df5213b0 00000000 df543cac df543c98 c020c50c c020bfb0 df30f400 df53aa00
[  383.121551] 3ca0: df543cd4 df543cb0 c020c5a4 c06fe8a0 dd8b7c00 c06fe820 c06fe388 00000000
[  383.130065] 3cc0: df5213b0 00000000 df543cf4 df543cd8 c023c194 c023d09c c023c154 c06fe828
[  383.138610] 3ce0: c06fe6bc dd8b7c00 df543d24 df543cf8 c023602c c023c160 c05f2c5c 00000008
[  383.147125] 3d00: c0701984 00000008 00000000 00000000 00000000 dd8b7c00 df543d4c df543d28
[  383.155670] 3d20: c02361ec c0235eb8 00000007 c008ca84 c0701984 c070196c df543de8 dd8b7c00
[  383.164184] 3d40: df543d7c df543d50 c026bedc c0236144 00000000 df543d60 c00085b4 c0014f30
[  383.172729] 3d60: ffffffff 00000000 00000000 df543de8 df543da4 df543d80 c005c17c c026bb5c
[  383.181243] 3d80: ffffffff c070195c ffffffff df543de8 00000000 00000000 df543dcc df543da8
[  383.189788] 3da0: c005c478 c005c13c 00000000 00000000 00000000 df521184 00000000 df521000
[  383.198303] 3dc0: df543de4 df543dd0 c005c4b0 c005c434 00000000 00000035 df543e74 df543de8
[  383.206848] 3de0: c025ec18 c005c49c 00000000 0001f000 00001000 00000800 00000800 00000000
[  383.215362] 3e00: 0f800000 c06df1f0 00000000 00000000 00000fbe df521484 1e802000 00000000
[  383.223907] 3e20: c00398b0 00000003 00000000 00000000 00000001 0001f000 00000006 dd8f01ac
[  383.232421] 3e40: 0f800001 c0039820 00000001 00000000 df24a000 00000000 df521000 df521040
[  383.240966] 3e60: 00000080 df521484 df543eb4 df543e78 c025fa60 c025eb7c df543e8c df521184
[  383.249481] 3e80: df543ea4 0f800000 df24a000 40186f40 beaa3b74 df24a000 df41e4c0 df745558
[  383.257995] 3ea0: df542000 beaa3b74 df543eec df543eb8 c025fe78 c025f004 ffffffff 00000007
[  383.266540] 3ec0: 00000800 00000000 00000000 00000000 00000041 de969098 beaa3b74 40186f40
[  383.275054] 3ee0: df543f74 df543ef0 c00b5aa0 c025fdb4 de87ff18 df745558 00000101 00000004
[  383.283599] 3f00: 00000000 00000000 00000000 df41e4c8 00000001 00000020 00000000 00000000
[  383.292114] 3f20: 00000000 00000000 c00bde90 df41e4c0 df601000 df41e4c8 c06b02d4 df41e4c0
[  383.300659] 3f40: df601000 df41e4c8 df543f94 00000000 beaa3b74 40186f40 df41e4c0 00000003
[  383.309173] 3f60: df542000 00000000 df543fa4 df543f78 c00b5f9c c00b5a28 beaa3ed8 00000000
[  383.317718] 3f80: c0014228 00000003 beaa3b74 beaa3ed8 00000036 c0014228 00000000 df543fa8
[  383.326232] 3fa0: c0014080 c00b5f34 00000003 beaa3b74 00000003 40186f40 beaa3b74 00000000
[  383.334777] 3fc0: 00000003 beaa3b74 beaa3ed8 00000036 00015260 00000000 44ad7000 00000000
[  383.343292] 3fe0: 44baa1b0 beaa3b4c 00009ba4 44baa1bc 80000010 00000003 00000000 00000000
[  383.351806] Backtrace: 
[  383.354370] [<c0261ba8>] (ubi_leb_read+0x0/0x124) from [<c026ba74>] (gluebi_read+0xa4/0xe0)
[  383.363098]  r8:00000044 r7:dd8b7c00 r6:df543c64 r5:00000044 r4:00000044
[  383.370117] [<c026b9d0>] (gluebi_read+0x0/0xe0) from [<c023d17c>] (ftl_add_mtd+0xec/0x654)
[  383.378753] [<c023d090>] (ftl_add_mtd+0x0/0x654) from [<c023c194>] (blktrans_notify_add+0x40/0x58)
[  383.388092] [<c023c154>] (blktrans_notify_add+0x0/0x58) from [<c023602c>] (add_mtd_device+0x180/0x28c)
[  383.397796]  r6:dd8b7c00 r5:c06fe6bc r4:c06fe828 r3:c023c154
[  383.403717] [<c0235eac>] (add_mtd_device+0x0/0x28c) from [<c02361ec>] (mtd_device_parse_register+0xb4/0xc4)
[  383.413848]  r7:dd8b7c00 r6:00000000 r5:00000000 r4:00000000
[  383.419799] [<c0236138>] (mtd_device_parse_register+0x0/0xc4) from [<c026bedc>] (gluebi_notify+0x38c/0x500)
[  383.429931]  r7:dd8b7c00 r6:df543de8 r5:c070196c r4:c0701984
[  383.435882] [<c026bb50>] (gluebi_notify+0x0/0x500) from [<c005c17c>] (notifier_call_chain+0x4c/0x8c)
[  383.445404]  r7:df543de8 r6:00000000 r5:00000000 r4:ffffffff
[  383.451324] [<c005c130>] (notifier_call_chain+0x0/0x8c) from [<c005c478>] (__blocking_notifier_call_chain+0x50/0x68)
[  383.462280]  r8:00000000 r7:00000000 r6:df543de8 r5:ffffffff r4:c070195c
[  383.469116] r3:ffffffff
[  383.471832] [<c005c428>] (__blocking_notifier_call_chain+0x0/0x68) from [<c005c4b0>] (blocking_notifier_call_chain+0x20/0x28)
[  383.483612]  r7:df521000 r6:00000000 r5:df521184 r4:00000000
[  383.489562] [<c005c490>] (blocking_notifier_call_chain+0x0/0x28) from [<c025ec18>] (ubi_notify_all+0xa8/0xc4)
[  383.499877] [<c025eb70>] (ubi_notify_all+0x0/0xc4) from [<c025fa60>] (ubi_attach_mtd_dev+0xa68/0xc50)
[  383.509521] [<c025eff8>] (ubi_attach_mtd_dev+0x0/0xc50) from [<c025fe78>] (ctrl_cdev_ioctl+0xd0/0x170)
[  383.519226] [<c025fda8>] (ctrl_cdev_ioctl+0x0/0x170) from [<c00b5aa0>] (do_vfs_ioctl+0x84/0x50c)
[  383.528381]  r6:40186f40 r5:beaa3b74 r4:de969098
[  383.533203] [<c00b5a1c>] (do_vfs_ioctl+0x0/0x50c) from [<c00b5f9c>] (sys_ioctl+0x74/0x84)
[  383.541748] [<c00b5f28>] (sys_ioctl+0x0/0x84) from [<c0014080>] (ret_fast_syscall+0x0/0x30)
[  383.550445]  r8:c0014228 r7:00000036 r6:beaa3ed8 r5:beaa3b74 r4:00000003
[  383.557464] Code: e1a0c00d e92dd9f0 e24cb004 e24dd014 (e5904000) 
[  383.563842] ---[ end trace 5d55ebc680dabeae ]---
[  383.603240] SR 1: curr=1050000, delta_v=-6076, calc=1043924, act=1050000, gain=1f
[  383.695983] UBI: scrubbed PEB 2593 (LEB 0:2591), data moved to PEB 4033
Segmentation fault
Please help us on how to resolve the above issue.
Regards,
Ajith
  • Hi,

    Which version of the SDK are you using?

    Try to flash the mtd partitions from U-Boot as I have explained here: http://e2e.ti.com/support/arm/sitara_arm/f/791/p/268305/949397.aspx#949397

    There are also explanations about the needed calculations. Verify that yours are correct.

    Best regards,
    Miroslav

  • Hi, 

    I am using linux version 3.2.0 

    Regards, 

    Ajith

  • Hi,
    I have tried followings commands from u-boot 
    MLO
    ====
    mmc rescan
    fatload mmc 0 0x82000000 MLO
    nand erase 0x0 0x20000
    nand write 0x82000000 0x0 0x20000
    nand erase 0x20000 0x20000
    nand write 0x82000000 0x20000 0x20000
    nand erase 0x40000 0x20000
    nand write 0x82000000 0x40000 0x20000
    nand erase 0x60000 0x20000
    nand write 0x82000000 0x60000 0x20000
    u-boot:
    ======
    mmc rescan
    fatload mmc 0 0x82000000 u-boot.img
    nand erase 0x80000 0x001e0000
    nand write 0x82000000 0x80000 0x001e0000
    uImage:
    =======
    fatload mmc 0 0x82000000 uImage
    nand erase 0x00280000 0x500000
    nand write 0x82000000 0x00280000 0x500000
    but my ubi.img is stored in the rootfs (mmc1), please teach me how to access ubi.img from the u-boot to flash in to NAND.
    mmc0 has three images uImage,u-boot.img,MLO. mmc1 has the file system and ubi.img is in /root/
    Regards,
    Ajith

  • The U-Boot from the SDK you are using has the following command:

    ext2load- load binary file from a Ext2 filesystem

    Type "help ext2load" for more information.

    Best regards,
    Miroslav

  • There is no enough space available to store ubi.img in mmc0. My ubi.img file is 342 MB.i also tried using

    fatload mmc 1 0x820000000  ubi.img ,but it is not coming out of that command. 

    Please suggest me in this regard. 

    Regards, 

    Ajith

  • Did you try using the command I suggested?

    Best regards,
    Miroslav

  • Hi, There is no space to load ubi.img in the mmc0. ubi.img is stored in mmc1(rootfs partition of SD card). From u-boot terminal I tried ext2load mmc 0:1 0x82000000 /ubi.img O/p: Failed to mount ext2 filesystem... ** Unrecognized filesystem type ** Please teach me how to attach and mount ubi.img. Regards,

    Ajith

  • How is your rootfs partition formatted? Is it ext2 or ext3 or ext4? If it is ext4, the ext2load command won't work. To work around this issue, either format the partition as ext2 or enable ext4 support in U-Boot. Read more about it here: http://lxr.missinglinkelectronics.com/#uboot/doc/README.ext4

    Best regards,
    Miroslav

  • Hi,
    We are trying to mount UBIFS, but we are getting an error while trying to mount.
    We have followed the below mentioned steps while creating the ubi image.
    I)
    mkfs.ubifs -r /home/sdk6/targetNFS/ -m 2048 -e 126976 -c 2768 -o ubifs.img
    II) ubi.ini file contents are as shown
    [rootfs]
    mode=ubi
    image=ubifs.img
    vol_id=0
    vol_size=336MiB
    vol_type=dynamic
    vol_name=rootfs
    vol_alignment=1
    vol_flags=autoresize
    III)
    ubinize -o ubi.img -m 2048 -p 128KiB -O 2048 -s 2048 ubi.ini
    On the target board we have executed the following steps as shown:
    A)
    root@am335x-evm:/# flash_erase /dev/mtd7 0 0 
    Erasing 128 Kibyte @ 1f860000 -- 100 % complete 
    B)
    root@am335x-evm:/# ubiformat /dev/mtd7 -f ubi.img 
    ubiformat: mtd7 (nand), size 529006592 bytes (504.5 MiB), 4036 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
    libscan: scanning eraseblock 4035 -- 100 % complete  
    ubiformat: 4036 eraseblocks are supposedly empty
    ubiformat: flashing eraseblock 1856 -- 100 % complete  
    ubiformat: formatting eraseblock 4035 -- 100 % complete  
    C)
    root@am335x-evm:/# ubiattach /dev/ubi_ctrl -m 7
    [  232.754302] UBI: attaching mtd7 to ubi0
    [  232.758331] UBI: physical eraseblock size:   131072 bytes (128 KiB)
    [  232.764923] UBI: logical eraseblock size:    126976 bytes
    [  232.770538] UBI: smallest flash I/O unit:    2048
    [  232.775451] UBI: VID header offset:          2048 (aligned 2048)
    [  232.781707] UBI: data offset:                4096
    [  236.464965] UBI: max. sequence number:       0
    [  236.500152] UBI: volume 0 ("rootfs") re-sized from 2775 to 4030 LEBs
    [  236.511016] UBI: attached mtd7 to ubi0
    [  236.514984] UBI: MTD device name:            "File System"
    [  236.520690] UBI: MTD device size:            504 MiB
    [  236.525878] UBI: number of good PEBs:        4036
    [  236.530792] UBI: number of bad PEBs:         0
    [  236.535430] UBI: number of corrupted PEBs:   0
    [  236.540039] UBI: max. allowed volumes:       128
    [  236.544860] UBI: wear-leveling threshold:    4096
    [  236.549774] UBI: number of internal volumes: 1
    [  236.554412] UBI: number of user volumes:     1
    [  236.559020] UBI: available PEBs:             0
    [  236.563659] UBI: total number of reserved PEBs: 4036
    [  236.568847] UBI: number of PEBs reserved for bad PEB handling: 2
    [  236.575103] UBI: max/mean erase counter: 0/0
    [  236.579559] UBI: image sequence number:  80240327
    [  236.584838] UBI: background thread "ubi_bgt0d" started, PID 1630
    UBI device number 0, total 4036 LEBs (512475136 bytes, 488.7 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
    D)
    root@am335x-evm:/# mount -t ubifs ubi0:rootfs /media/nand
    [  268.489288] UBIFS error (pid 1632): ubifs_check_node: bad CRC: calculated 0x164e9781, read 0xb2f81807
    [  268.498992] UBIFS error (pid 1632): ubifs_check_node: bad node at LEB 0:0
    [  268.506317] Backtrace: 
    [  268.508911] [<c001775c>] (dump_backtrace+0x0/0x10c) from [<c04c2f30>] (dump_stack+0x18/0x1c)
    [  268.517700]  r6:df7f2000 r5:00000000 r4:df702000 r3:c06dd78c
    [  268.523651] [<c04c2f18>] (dump_stack+0x0/0x1c) from [<c014a59c>] (ubifs_check_node+0x1c4/0x2dc)
    [  268.532745] [<c014a3d8>] (ubifs_check_node+0x0/0x2dc) from [<c014ba94>] (ubifs_read_node+0xe0/0x2a8)
    [  268.542266] [<c014b9b4>] (ubifs_read_node+0x0/0x2a8) from [<c014831c>] (ubifs_read_sb_node+0x5c/0x80)
    [  268.551879] [<c01482c0>] (ubifs_read_sb_node+0x0/0x80) from [<c0148f80>] (ubifs_read_superblock+0xbe8/0x1574)
    [  268.562225]  r5:df7f2000 r4:00000000
    [  268.565979] [<c0148398>] (ubifs_read_superblock+0x0/0x1574) from [<c01471b4>] (ubifs_mount+0x740/0x166c)
    [  268.575866] [<c0146a74>] (ubifs_mount+0x0/0x166c) from [<c00a98fc>] (mount_fs+0x4c/0x18c)
    [  268.584411] [<c00a98b0>] (mount_fs+0x0/0x18c) from [<c00bee78>] (vfs_kern_mount+0x54/0x94)
    [  268.593048] [<c00bee24>] (vfs_kern_mount+0x0/0x94) from [<c00bf7d8>] (do_kern_mount+0x3c/0xd8)
    [  268.602020]  r8:dd853b00 r7:00008000 r6:dd8533c0 r5:c06ec110 r4:00000000
    [  268.608856] r3:00000000
    [  268.611602] [<c00bf79c>] (do_kern_mount+0x0/0xd8) from [<c00c0f18>] (do_mount+0x2f0/0x6ec)
    [  268.620239]  r8:dd853b00 r7:dd8533c0 r6:00000000 r5:00000000 r4:00008000
    [  268.627044] r3:00000000
    [  268.629791] [<c00c0c28>] (do_mount+0x0/0x6ec) from [<c00c15f0>] (sys_mount+0x8c/0xcc)
    [  268.638000] [<c00c1564>] (sys_mount+0x0/0xcc) from [<c0014080>] (ret_fast_syscall+0x0/0x30)
    [  268.646697]  r7:00000015 r6:4021e830 r5:beb9dbe8 r4:00000000
    [  268.652618] UBIFS error (pid 1632): ubifs_read_node: expected node type 6
    mount: mounting ubi0:rootfs on /media/nand failed: Structure needs cleaning
    Please help me on how to resolve the above error.
    Regards,
    Ajith