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.

Am335x with 16 bit nand and UBIFS file system

I am having an issue in booting the beagle board with UBIFS file system. I am able to boot xloader, u-boot and kernel from flash while mounting the UBIFS kernel hangs.


I am using beagle board with nand cape which uses MT29F4G16ABAD nand flash. its 512MiB with 16 bit interface.I have made changes in u-boot and kernel for pin mux and xloader,u-boot and kernel boots from flash.
only changes in kernel is pin mux .Do i need to make any other changes in kernel ?
below is the command used for creating the UBIFS

mkfs.ubifs -r ubifs_filesystem -F -o /tftpboot/ubifs.img -m 2048 -e 126976 -c 3993
ubinize -o /tftpboot/ubi.img -m 2048 -p 128KiB ubinize.cfg

Now ubi.img is created

-rw-r--r-- 1 root root 36950016 Nov 4 09:06 ubifs.img
-rw-rw-r-- 1 skottary skottary 38404096 Nov 4 09:07 ubi.img

from u-boot i am flashing the image to mtd7
tftp 0x82000000 ubi.img
nand erase 0x780000 0xF880000
nand write 0x82000000 0x780000 0x24a0000

After reset system hangs while mounting the file system

Below is the extract from nand data sheet.Do i need to take minimum io size as 1024  for 16 bit interface while creating ubi.img ?

• Organization
– Page size x8: 2112 bytes (2048 + 64 bytes)
– Page size x16: 1056 words (1024 + 32 words)
– Block size: 64 pages (128K + 4K bytes)
– Plane size: 2 planes x 2048 blocks per plane
– Device size: 4Gb: 4096 blocks; 8Gb: 8192 blocks
16Gb: 16,384 blocks

[ 1.030853] omap-gpmc omap-gpmc: GPMC revision 6.0
[ 1.035888] Registering NAND on CS0
[ 1.041564] registered am33xx_sr device
[ 1.047821] mtdoops: mtd device (mtddev=name/number) must be supplied
[ 1.055114] omap2-nand driver initializing
[ 1.059722] ONFI flash detected
[ 1.063293] NAND device: Manufacturer ID: 0x2c, Chip ID: 0xcc (Micron NAND 512MiB 3,3V 16-bit)
[ 1.072509] Creating 8 MTD partitions on "omap2-nand.0":
[ 1.078063] 0x000000000000-0x000000020000 : "SPL"
[ 1.084411] 0x000000020000-0x000000040000 : "SPL.backup1"
[ 1.091400] 0x000000040000-0x000000060000 : "SPL.backup2"
[ 1.098297] 0x000000060000-0x000000080000 : "SPL.backup3"
[ 1.105255] 0x000000080000-0x000000260000 : "U-Boot"
[ 1.112457] 0x000000260000-0x000000280000 : "U-Boot Env"
[ 1.119201] 0x000000280000-0x000000780000 : "Kernel"
[ 1.127685] 0x000000780000-0x000020000000 : "File System"
[ 1.343597] OneNAND driver initializing
[ 1.348327] UBI: attaching mtd7 to ubi0
[ 1.352386] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.358917] UBI: logical eraseblock size: 126976 bytes
[ 1.364562] UBI: smallest flash I/O unit: 2048
[ 1.369445] UBI: VID header offset: 2048 (aligned 2048)
[ 1.375732] UBI: data offset: 4096
[ 3.372528] UBI: max. sequence number: 0
[ 3.377197] UBI error: ubi_read_volume_table: the layout volume was not found
[ 3.385803] UBI error: ubi_init: cannot attach mtd7
.......................

[ 3.878967] Detected MACID=0:18:31:8b:39:6e
[ 3.884826] cpsw: Detected MACID = 00:18:31:8b:39:6f
[ 3.891357] omap_rtc am33xx-rtc: setting system clock to 2000-01-01 04:23:22 UTC (946700602)
[ 3.900726] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 3.908111] Please append a correct "root=" boot option; here are the available partitions:
[ 3.916900] 1f00 128 mtdblock0 (driver?)
[ 3.922210] 1f01 128 mtdblock1 (driver?)
[ 3.927490] 1f02 128 mtdblock2 (driver?)
[ 3.932800] 1f03 128 mtdblock3 (driver?)
[ 3.938079] 1f04 1920 mtdblock4 (driver?)
[ 3.943389] 1f05 128 mtdblock5 (driver?)
[ 3.948669] 1f06 5120 mtdblock6 (driver?)
[ 3.953979] 1f07 516608 mtdblock7 (driver?)
[ 3.959259] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 3.967895] Backtrace:
[ 3.970489] [<c0017dbc>] (dump_backtrace+0x0/0x10c) from [<c03c92d4>] (dump_stack+0x18/0x1c)
[ 3.979339] r6:00008000 r5:c04849b0 r4:c05afa08 r3:c056f998
[ 3.985321] [<c03c92bc>] (dump_stack+0x0/0x1c) from [<c03c9510>] (panic+0x64/0x194)
[ 3.993377] [<c03c94ac>] (panic+0x0/0x194) from [<c0511c88>] (mount_block_root+0x174/0x228)
[ 4.002136] r3:00000004 r2:00000000 r1:cf01df68 r0:c04849b0
[ 4.008087] r7:c053ead8
[ 4.010742] [<c0511b14>] (mount_block_root+0x0/0x228) from [<c0511fa4>] (prepare_namespace+0x94/0x1c0)
[ 4.020507] [<c0511f10>] (prepare_namespace+0x0/0x1c0) from [<c05118fc>] (kernel_init+0xf4/0x120)
[ 4.029815] r5:c054ada4 r4:c054ada4
[ 4.033630] [<c0511808>] (kernel_init+0x0/0x120) from [<c00447a4>] (do_exit+0x0/0x65c)
[ 4.041931] r5:c0511808 r4:00000000


below is the u-boot env for nand boot

========================================================================================================================
U-Boot# print
arch=arm
baudrate=115200
board=am335x
board_name=A335BONE
board_rev=00A6
bootargs=console=ttyO0,115200n8 noinitrd ip=off mem=512M rootwait=1 rw ubi.mtd=7,2048 rootfstype=ubifs root=ubi0:rootfs
bootargs_defaults=setenv bootargs console=${console} ${optargs}
bootcmd=mmc dev ${mmcdev}; if mmc rescan; then echo SD/MMC found on device ${mmcdev};if run loadbootenv; then echo Loaded environment from ${bootenv};run importbootenv;fi;if test -n $uenvcmd; then echo Ru;
bootdelay=1
bootenv=uEnv.txt
bootfile=uImage
console=ttyO0,115200n8
cpu=armv7
dfu_alt_info_emmc=rawemmc mmc 0 3751936
dfu_alt_info_mmc=boot part 0 1;rootfs part 0 2;MLO fat 0 1;MLO.raw mmc 100 100;u-boot.img.raw mmc 300 3C0;u-boot.img fat 0 1;uEnv.txt fat 0 1
dfu_alt_info_nand=SPL part 0 1;SPL.backup1 part 0 2;SPL.backup2 part 0 3;SPL.backup3 part 0 4;u-boot part 0 5;kernel part 0 7;rootfs part 0 8
ethact=cpsw
ethaddr=00:18:31:8b:39:6e
fdt_high=0xffffffff
fdtaddr=0x80F80000
findfdt=if test $board_name = A335BONE; then setenv fdtfile am335x-bone.dtb; fi; if test $board_name = A33515BB; then setenv fdtfile am335x-evm.dtb; fi; if test $board_name = A335X_SK; then setenv fdtfilei
importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
ip_method=none
kloadaddr=0x80007fc0
loadaddr=0x80200000
loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
loadramdisk=fatload mmc ${mmcdev} ${rdaddr} ramdisk.gz
loaduimage=ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}
loaduimagefat=fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}
mmcargs=run bootargs_defaults;setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} ip=${ip_method}
mmcboot=echo Booting from mmc ...; run mmcargs; bootm ${kloadaddr}
mmcdev=0
mmcroot=/dev/mmcblk0p2 ro
mmcrootfstype=ext3 rootwait
mtdids=nand0=omap2-nand.0
mtdparts=mtdparts=omap2-nand.0:128k(SPL),128k(SPL.backup1),128k(SPL.backup2),128k(SPL.backup3),1920k(u-boot),128k(u-boot-env),5m(kernel),-(rootfs)
nand_erasesize=20000
nand_oobsize=40
nand_writesize=800
nandargs=setenv bootargs console=${console} ${optargs} root=${nandroot} rootfstype=${nandrootfstype}
nandboot=echo Booting from nand ...; run nandargs; nand read ${loadaddr} ${nandsrcaddr} ${nandimgsize}; bootm ${loadaddr}
nandimgsize=0x500000
nandroot=ubi0:rootfs rw ubi.mtd=7,2048
nandrootfstype=ubifs rootwait=1
nandsrcaddr=0x280000
netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
netboot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${loadaddr} ${bootfile}; run netargs; bootm ${loadaddr}
nfsopts=nolock
ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
ramboot=echo Booting from ramdisk ...; run ramargs; bootm ${loadaddr}
ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=${rdaddr},64M
ramrootfstype=ext2
rdaddr=0x81000000
rootpath=/export/rootfs
soc=am33xx
spiargs=setenv bootargs console=${console} ${optargs} root=${spiroot} rootfstype=${spirootfstype}
spiboot=echo Booting from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; bootm ${loadaddr}
spibusno=0
spiimgsize=0x362000
spiroot=/dev/mtdblock4 rw
spirootfstype=jffs2
spisrcaddr=0xe0000
static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
stderr=serial
stdin=serial
stdout=serial
usbnet_devaddr=00:18:31:8b:39:6e
vendor=ti
ver=U-Boot 2013.01.01-svn8676 (Oct 31 2013 - 14:30:44)

Environment size: 3785/131068 bytes

====================================================================================

Can somebody tell me what is the issue did i miss any step ?

After going through the few threads.

http://e2e.ti.com/support/arm/sitara_arm/f/791/p/268305/941327.aspx#941327

http://e2e.ti.com/support/arm/sitara_arm/f/791/t/244832.aspx

Applied below patch and leads to more crash

skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ svn diff drivers/mtd/nand/nand_base.c
Index: drivers/mtd/nand/nand_base.c
===================================================================
--- drivers/mtd/nand/nand_base.c (revision 8680)
+++ drivers/mtd/nand/nand_base.c (working copy)
@@ -3448,6 +3448,7 @@
break;
}
}
+// mtd->subpage_sft = 0;
chip->subpagesize = mtd->writesize >> mtd->subpage_sft;

/* Initialize state */
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ vi drivers/mtd/nand/nand_base.c
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ vi drivers/mtd/nand/nand_base.c
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ svn diff drivers/mtd/nand/nand_base.c
Index: drivers/mtd/nand/nand_base.c
===================================================================
--- drivers/mtd/nand/nand_base.c (revision 8680)
+++ drivers/mtd/nand/nand_base.c (working copy)
@@ -3448,6 +3448,7 @@
break;
}
}
+ mtd->subpage_sft = 0;
chip->subpagesize = mtd->writesize >> mtd->subpage_sft;

/* Initialize state */
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ svn diff arch/arm/mach-omap2/gpmc.c
Index: arch/arm/mach-omap2/gpmc.c
===================================================================
--- arch/arm/mach-omap2/gpmc.c (revision 8680)
+++ arch/arm/mach-omap2/gpmc.c (working copy)
@@ -931,7 +931,8 @@
bch_mod = 0;
bch_wrapmode = 0x09;
} else if (ecc_type == OMAP_ECC_BCH8_CODE_HW) {
- eccsize1 = 0x2; eccsize0 = 0x1A;
+ // eccsize1 = 0x2; eccsize0 = 0x1A;
+ eccsize1 = 0x10; eccsize0 = 0x00;
bch_mod = 1;
bch_wrapmode = 0x01;
} else
@@ -945,7 +946,8 @@
bch_mod = 0;
bch_wrapmode = 0x06;
} else if (ecc_type == OMAP_ECC_BCH8_CODE_HW) {
- eccsize1 = 0x00; eccsize0 = 0x00;
+ // eccsize1 = 0x00; eccsize0 = 0x00;
+ eccsize1 = 0x10; eccsize0 = 0x00;
bch_mod = 1;
bch_wrapmode = 0x01;
} else
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ vi drivers/mtd/nand/omap2.c
skottary@ubuntu:~/work/ibflex/board-support/linux-3.2.0-psp04.06.00.11$ svn diff drivers/mtd/nand/omap2.c
Index: drivers/mtd/nand/omap2.c
===================================================================
--- drivers/mtd/nand/omap2.c (revision 8680)
+++ drivers/mtd/nand/omap2.c (working copy)
@@ -910,6 +910,9 @@
eccsize = BCH8_ECC_OOB_BYTES;

for (i = 0; i < blockCnt; i++) {
+ if (memcmp(read_ecc, calc_ecc, 13) == 0) {
+ continue;
+ }
eccflag = 0;
/* check if area is flashed */
for (j = 0; (j < eccsize) && (eccflag == 0); j++)
@@ -1216,7 +1219,7 @@
} else if (pdata->ecc_opt == OMAP_ECC_BCH8_CODE_HW) {
info->nand.ecc.bytes = OMAP_BCH8_ECC_SECT_BYTES;
info->nand.ecc.size = 512;
- info->nand.ecc.read_page = omap_read_page_bch;
+ //info->nand.ecc.read_page = omap_read_page_bch;
} else {
info->nand.ecc.bytes = 3;
info->nand.ecc.size = 512;

------------------------

[ 1.030792] omap-gpmc omap-gpmc: GPMC revision 6.0
[ 1.035827] Registering NAND on CS0
[ 1.041717] registered am33xx_sr device
[ 1.047760] mtdoops: mtd device (mtddev=name/number) must be supplied
[ 1.055084] omap2-nand driver initializing
[ 1.059661] ONFI flash detected
[ 1.063232] NAND device: Manufacturer ID: 0x2c, Chip ID: 0xcc (Micron NAND 512MiB 3,3V 16-bit)
[ 1.072418] Creating 8 MTD partitions on "omap2-nand.0":
[ 1.077972] 0x000000000000-0x000000020000 : "SPL"
[ 1.084350] 0x000000020000-0x000000040000 : "SPL.backup1"
[ 1.091369] 0x000000040000-0x000000060000 : "SPL.backup2"
[ 1.098297] 0x000000060000-0x000000080000 : "SPL.backup3"
[ 1.105255] 0x000000080000-0x000000260000 : "U-Boot"
[ 1.112396] 0x000000260000-0x000000280000 : "U-Boot Env"
[ 1.119171] 0x000000280000-0x000000780000 : "Kernel"
[ 1.127624] 0x000000780000-0x000020000000 : "File System"
[ 1.343566] OneNAND driver initializing
[ 1.348297] UBI: attaching mtd7 to ubi0
[ 1.352355] UBI: physical eraseblock size: 131072 bytes (128 KiB)
[ 1.358886] UBI: logical eraseblock size: 126976 bytes
[ 1.364532] UBI: smallest flash I/O unit: 2048
[ 1.369415] UBI: VID header offset: 2048 (aligned 2048)
[ 1.375701] UBI: data offset: 4096
[ 2.124450] UBI error: process_eb: bad image sequence number 1917864831 in PEB 1988, expected 1419785363
[ 2.134429] slab error in kmem_cache_destroy(): cache `ubi_scan_leb_slab': Can't free all objects
[ 2.143768] Backtrace:
[ 2.146362] [<c0017dbc>] (dump_backtrace+0x0/0x10c) from [<c03c92d4>] (dump_stack+0x18/0x1c)
[ 2.155242] r6:000007c4 r5:00000000 r4:cf1840c0 r3:c056f998
[ 2.161224] [<c03c92bc>] (dump_stack+0x0/0x1c) from [<c00a6048>] (kmem_cache_destroy+0xac/0xfc)
[ 2.170379] [<c00a5f9c>] (kmem_cache_destroy+0x0/0xfc) from [<c0270abc>] (ubi_scan+0x180/0x960)
[ 2.179534] r4:ffffffea r3:cf2b1000
[ 2.183319] [<c027093c>] (ubi_scan+0x0/0x960) from [<c0269590>] (ubi_attach_mtd_dev+0x440/0xa70)
[ 2.192565] [<c0269150>] (ubi_attach_mtd_dev+0x0/0xa70) from [<c0531f64>] (ubi_init+0x1dc/0x2dc)
[ 2.201812] [<c0531d88>] (ubi_init+0x0/0x2dc) from [<c000876c>] (do_one_initcall+0x128/0x1a8)
[ 2.210754] [<c0008644>] (do_one_initcall+0x0/0x1a8) from [<c051188c>] (kernel_init+0x84/0x120)
[ 2.219940] [<c0511808>] (kernel_init+0x0/0x120) from [<c00447a4>] (do_exit+0x0/0x65c)
[ 2.228240] r5:c0511808 r4:00000000
[ 2.232635] UBI error: ubi_init: cannot attach mtd7
[ 2.238647] CAN device driver interface
[ 2.242675] CAN bus driver for Bosch D_CAN controller 1.0
[ 2.291351] davinci_mdio davinci_mdio.0: davinci mdio revision 1.6
[ 2.297821] davinci_mdio davinci_mdio.0: detected phy mask fffffffe
[ 2.305084] davinci_mdio.0: probed
[ 2.308624] davinci_mdio davinci_mdio.0: phy[0]: device 0:00, driver SMSC LAN8710/LAN8720
[ 2.317535] usbcore: registered new interface driver cdc_ether
[ 2.323791] usbcore: registered new interface driver cdc_eem
[ 2.329864] usbcore: registered new interface driver dm9601
[ 2.335723] cdc_ncm: 04-Aug-2011
[ 2.339263] usbcore: registered new interface driver cdc_ncm
[ 2.345184] Initializing USB Mass Storage driver...
[ 2.350494] usbcore: registered new interface driver usb-storage
[ 2.356750] USB Mass Storage support registered.
[ 2.362060] mousedev: PS/2 mouse device common for all mice
[ 2.369232] omap_rtc am33xx-rtc: rtc core: registered am33xx-rtc as rtc0
[ 2.376281] am33xx-rtc: already running
[ 2.380462] i2c /dev entries driver
[ 2.442352] OMAP Watchdog Timer Rev 0x01: initial timeout 60 sec
[ 2.525085] cpuidle: using governor ladder
[ 2.530059] cpuidle: using governor menu
[ 2.536895] omap4_aes_mod_init: loading AM33X AES driver
[ 2.542633] omap4-aes omap4-aes: AM33X AES hw accel rev: 3.02
[ 2.549316] omap4_aes_probe: probe() done
[ 2.553863] omap4_sham_mod_init: loading AM33X SHA/MD5 driver
[ 2.560028] omap4-sham omap4-sham: AM33X SHA/MD5 hw accel rev: 4.03
[ 2.573394] omap4_sham_probe: probe() done
[ 2.581024] usbcore: registered new interface driver usbhid
[ 2.586883] usbhid: USB HID core driver
[ 2.591186] oprofile: hardware counters not available
[ 2.596496] oprofile: using timer interrupt.
[ 2.600982] nf_conntrack version 0.5.0 (3966 buckets, 15864 max)
[ 2.607910] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 2.613647] TCP cubic registered
[ 2.617004] NET: Registered protocol family 17
[ 2.621795] Bridge firewalling registered
[ 2.626007] can: controller area network core (rev 20090105 abi 8)
[ 2.632568] NET: Registered protocol family 29
[ 2.637237] can: raw protocol (rev 20090105)
[ 2.641693] can: broadcast manager protocol (rev 20090105 t)
[ 2.647674] Registering the dns_resolver key type
[ 2.652648] VFP support v0.3: implementor 41 architecture 3 part 30 variant c rev 3
[ 2.660644] ThumbEE CPU extension supported.
[ 2.665191] mux: Failed to setup hwmod io irq -22
[ 2.670959] Power Management for AM33XX family
[ 2.675872] Trying to load am335x-pm-firmware.bin (60 secs timeout)
[ 2.682556] Copied the M3 firmware to UMEM
[ 2.686920] Cortex M3 Firmware Version = 0x181
[ 2.691772] smartreflex smartreflex: am33xx_sr_probe: Zero NValue read from EFUSE
[ 2.699584] smartreflex: probe of smartreflex failed with error -22
[ 2.706756] sr_init: platform driver register failed
[ 2.716247] clock: disabling unused clocks to save power
[ 2.738983] Detected MACID=0:18:31:8b:39:6e
[ 2.744812] cpsw: Detected MACID = 00:18:31:8b:39:6f
[ 2.751312] omap_rtc am33xx-rtc: setting system clock to 2000-01-01 05:05:01 UTC (946703101)
[ 2.760711] VFS: Cannot open root device "ubi0:rootfs" or unknown-block(0,0)
[ 2.768096] Please append a correct "root=" boot option; here are the available partitions:
[ 2.776885] 1f00 128 mtdblock0 (driver?)
[ 2.782196] 1f01 128 mtdblock1 (driver?)
[ 2.787475] 1f02 128 mtdblock2 (driver?)
[ 2.792785] 1f03 128 mtdblock3 (driver?)
[ 2.798065] 1f04 1920 mtdblock4 (driver?)
[ 2.803375] 1f05 128 mtdblock5 (driver?)
[ 2.808654] 1f06 5120 mtdblock6 (driver?)
[ 2.813964] 1f07 516608 mtdblock7 (driver?)
[ 2.819244] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.827880] Backtrace:
[ 2.830474] [<c0017dbc>] (dump_backtrace+0x0/0x10c) from [<c03c92d4>] (dump_stack+0x18/0x1c)
[ 2.839324] r6:00008000 r5:c04849b0 r4:c05afa08 r3:c056f998
[ 2.845306] [<c03c92bc>] (dump_stack+0x0/0x1c) from [<c03c9510>] (panic+0x64/0x194)
[ 2.853363] [<c03c94ac>] (panic+0x0/0x194) from [<c0511c88>] (mount_block_root+0x174/0x228)
[ 2.862121] r3:00000004 r2:00000000 r1:cf01df68 r0:c04849b0
[ 2.868072] r7:c053ead8
[ 2.870727] [<c0511b14>] (mount_block_root+0x0/0x228) from [<c0511fa4>] (prepare_namespace+0x94/0x1c0)
[ 2.880493] [<c0511f10>] (prepare_namespace+0x0/0x1c0) from [<c05118fc>] (kernel_init+0xf4/0x120)
[ 2.889801] r5:c054ada4 r4:c054ada4
[ 2.893615] [<c0511808>] (kernel_init+0x0/0x120) from [<c00447a4>] (do_exit+0x0/0x65c)
[ 2.901916] r5:c0511808 r4:00000000

  • Hi Sunil,

    Would you please share the contents of your ubinize.cfg file?

    Also can you please clarify the size you wish to use for your root file system? Judging by the number of LEBs you have provided to the mkfs.ubifs command (3993), I guess you are trying to use the whole NAND flash (or most of it) for the root file system. This may cause trouble if a big enough error is accumulated during the calculations of that size.

    Please try to use 10% smaller file system, just to clarify if this is indeed the problem.

    One more thing - did you reserve at least 1% of PEBs for bad block handling as shown in the link suggested by Biser?

    Best regards,
    Miroslav

  • Hi Miroslav

    Yes,i was trying to use remaining flash for UBIFS.

    1.So later i tried as suggested by you in one of the below thread filesystem size of 61MB (As my file system size is 38MB)

    2.Also tried executing mkfs.ubifs and ubinize with sudo

    Both the experiment  did not solve the issue.

    http://e2e.ti.com/support/arm/sitara_arm/f/791/p/268305/941327.aspx#941327

    Below is the ubinize.cfg

    [ubifs]

    mode=ubi
    image=ubifs.img
    vol_id=0
    vol_size=483MiB   
    vol_type=dynamic
    vol_name=rootfs
    vol_flags=autoresize

    Do i need to make specific changes for 16 bit ?

    Below is the extract from nand data sheet. Do i need to take minimum io size as 1024  for 16 bit interface while creating ubi.img ?

    • Organization
    – Page size x8: 2112 bytes (2048 + 64 bytes)
    – Page size x16: 1056 words (1024 + 32 words)
    – Block size: 64 pages (128K + 4K bytes)
    – Plane size: 2 planes x 2048 blocks per plane
    – Device size: 4Gb: 4096 blocks; 8Gb: 8192 blocks
    16Gb: 16,384 blocks

  • Hi Biser

    Yes i have read the link and based on that i have created ubi.img

    Also i have tried the section tried attaching the partition and mount giving the same result   "Mounting UBIFS image as a regular NAND partition" this was giving the same errors. 

  • Hi,

    SUNIL KOTTARY said:

    Do i need to make specific changes for 16 bit ?

    Below is the extract from nand data sheet. Do i need to take minimum io size as 1024  for 16 bit interface while creating ubi.img ?

    No, you don't have to change the min I/O size, since it is always the same in KB, regardless of whether you are using 8-bit or 16-bit interface.

    Have you tried erasing the whole NAND flash, then writing the MLO, U-Boot, kernel and the smaller UBIFS?

    Another suggestion: Is it possible to boot from an SD card and then flash the NAND from user space using mtd-utils?

    Best regards,
    Miroslav

  • ok I will try erasing  the whole chip and re-flash the image and try to flash from  userspace using mtd utils

  • Hi Miroslav

    Thank you for the suggestion. After erasing the chip and re-flashing the images ( MLO, U-boot.img ,uImage and ubi.img) system is up without any issue.

    But issue remains if i re-flash the only ubi.img ?.Do i need to use ubiformat command to re-flash the image ?

  • Hi,

    I'm not exactly sure why this is happening when you are only erasing part of the NAND flash and I'm not really familiar with the U-Boot's "nand write" command implementation, so I can't comment on it, but it is suggested to flash UBIFS using ubiformat: http://www.linux-mtd.infradead.org/faq/ubifs.html#L_why_ubiformat

    I also found this comment, which describes the same case as yours, but there isn't a meaningful explanation to why this is happening.

    Best regards,
    Miroslav

  • HI Miroslav

    Figured out the issue .The issue some how copying and pasting to minicom has some issue.I had below command in notepad  and I use to change the ubi.mtd to 8 or 9 and paste to u-boot command prompt.Some how u-boot does not like it some times ubi.mtd=   (empty) this was the culprit for for not mounting the file system.

    setenv mtdparts mtdparts=omap2-nand.0:128k(SPL),128k(SPL.backup1),128k(SPL.backup2),128k(SPL.backup3),1920k(u-boot),128k(u-boot-env),5m(kernel1),5m(kernel2),80m(rootfs1),-(rootfs2)

    mtdparts
    setenv nandsrcaddr 0x780000
    setenv nandroot ubi0:rootfs rw ubi.mtd=8,2048
    run nandboot

  • Hi Sunil,

    I am working on beaglebone black custom board with Android JB4.2(kernel version 3.2). Board has been interfaced with 16 bit MT29F4G16ABADAWP for rootfs purpose. Board also has SPI NOR for MLO, uboot.img and uImage .

    SPI NOR is working as expected. I could able to bring the board uboot and loaded uImage to RAM.

    I am facing issues NAND.

    I am creating the rootfs as follows.

    1. sudo tar -xjvf out/target/product/am335xevm/rootfs.tar.bz2 -C android_rootfs/
    2. sudo mkfs.ubifs -m 2048 -e 126976 -c 1960 -r android_rootfs/ system_ubifs.img
    3. ubinize -o rootfs-var-som-am33.ubi.img -m 2048 -p 128KiB -s 2048 -O 2048 ubinize.cfg

    When I load the image to NAND from u boot prompt using nand write I am getting errors like skipping bad blocks....


     I attached the  "nand bad" command output with this note.

    Here is the printenv output.

    ASHOK# printenv
    arch=arm
    baudrate=115200
    board=ae_am335x
    board_name=ae_am335x
    bootargs_defaults=setenv bootargs console=${console} androidboot.console=ttyO0 ${optargs}
    bootcmd=run spiboot;
    bootdelay=1
    bootenv=uEnv.txt
    bootfile=uImage
    console=ttyO0,115200n8
    cpu=armv7
    fdt_high=0xffffffff
    fdtaddr=0x80F80000
    findfdt=setenv fdtfile var-am335x.dtb
    importbootenv=echo Importing environment from mmc ...; env import -t $loadaddr $filesize
    ip_method=none
    kloadaddr=0x80007fc0
    loadaddr=0x80200000
    loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}
    loadramdisk=fatload mmc ${mmcdev} ${rdaddr} ramdisk.gz
    loaduimage=ext2load mmc ${mmcdev}:2 ${kloadaddr} /boot/${bootfile}
    loaduimagefat=fatload mmc ${mmcdev} ${kloadaddr} ${bootfile}
    mmcargs=run bootargs_defaults;setenv bootargs ${bootargs} root=${mmcroot} rootfstype=${mmcrootfstype} ip=${ip_method}
    mmcboot=echo Booting from mmc ...; run mmcargs; run loaduimagefat; bootm ${kloadaddr}
    mmcdev=0
    mmcroot=/dev/mmcblk0p2 rw
    mmcrootfstype=ext4 rootwait init=/init
    mtddevname=SPL
    mtddevnum=0
    mtdids=nand0=omap2-nand.0
    mtdparts=mtdparts=omap2-nand.0:128k(SPL),128k(SPL.backup1),128k(SPL.backup2),128k(SPL.backup3),1920k(u-boot),128k(u-boot-env),5m(ke)
    nand_erasesize=20000
    nand_oobsize=40
    nand_writesize=800
    nandargs=run bootargs_defaults;setenv bootargs ${bootargs} root=${nandroot} init=/init rootfstype=${nandrootfstype}
    nandboot=echo Booting from nand ...; run nandargs; nand read ${loadaddr} ${nandsrcaddr} ${nandimgsize}; bootm ${loadaddr}
    nandimgsize=0x500000
    nandroot=ubi0:rootfs rw ubi.mtd=7,2048
    nandrootfstype=ubifs rootwait=1
    nandsrcaddr=0x280000
    netargs=setenv bootargs console=${console} ${optargs} root=/dev/nfs nfsroot=${serverip}:${rootpath},${nfsopts} rw ip=dhcp
    netboot=echo Booting from network ...; setenv autoload no; dhcp; tftp ${loadaddr} ${bootfile}; run netargs; bootm ${loadaddr}
    nfsopts=nolock
    partition=nand0,0
    ramargs=setenv bootargs console=${console} ${optargs} root=${ramroot} rootfstype=${ramrootfstype}
    ramboot=echo Booting from ramdisk ...; run ramargs; bootm ${loadaddr}
    ramroot=/dev/ram0 rw ramdisk_size=65536 initrd=${rdaddr},64M
    ramrootfstype=ext2
    rdaddr=0x81000000
    rootpath=/export/rootfs
    soc=am33xx
    spiargs=run nandargs
    spiboot=echo Booting (ashok)from spi ...; run spiargs; sf probe ${spibusno}:0; sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; boo}
    spibusno=0
    spiimgsize=0x399250
    spisrcaddr=0x220000
    static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}::off
    stderr=serial
    stdin=serial
    stdout=serial
    vendor=ti
    ver=U-Boot 2013.01.01 (Sep 07 2015 - 19:46:33)

    Environment size: 2694/131068 bytes

    ******************************************************************

    ASHOK# mtdparts

    device ashok nand0 <omap2-nand.0>, # parts = 8
     #: name                size            offset          mask_flags
     0: SPL                 0x00020000      0x00000000      0
     1: SPL.backup1         0x00020000      0x00020000      0
     2: SPL.backup2         0x00020000      0x00040000      0
     3: SPL.backup3         0x00020000      0x00060000      0
     4: u-boot              0x001e0000      0x00080000      0
     5: u-boot-env          0x00020000      0x00260000      0
     6: kernel              0x00500000      0x00280000      0
     7: rootfs              0x1f880000      0x00780000      0

    active partition: nand0,0 - (SPL) 0x00020000 @ 0x00000000

    defaults:
    mtdids  : nand0=omap2-nand.0
    mtdparts: mtdparts=omap2-nand.0:128k(SPL),128k(SPL.backup1),128k(SPL.backup2),128k(SPL.backup3),1920k(u-boot),128k(u-boot-env),5m(k)

    ASHOK# nand info

    Device 0: nand0, sector size 128 KiB
      Page size      2048 b
      OOB size         64 b
      Erase size   131072 b

    ****************************************************************

    Datasheet details:

    Organization
    – Page size x8: 2112 bytes (2048 + 64 bytes)
    – Page size x16: 1056 words (1024 + 32 words)
    – Block size: 64 pages (128K + 4K bytes)
    – Plane size: 2 planes x 2048 blocks per plane
    – Device size: 4Gb: 4096 blocks; 8Gb: 8192 blocks
    16Gb: 16,384 blocks

    nand_bad_blocks.txt
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    ADVANCED_ENERGY# nand bad
    Device 0 bad blocks:
    00000000
    00020000
    00040000
    00060000
    00080000
    000a0000
    000c0000
    000e0000
    00100000
    00120000
    00140000
    00160000
    00180000
    001a0000
    001c0000
    001e0000
    00200000
    00220000
    00240000
    00260000
    00280000
    002a0000
    002c0000
    002e0000
    00300000
    00320000
    00340000
    00360000
    00380000
    003a0000
    003c0000
    003e0000
    00400000
    00420000
    00440000
    00460000
    00480000
    004a0000
    004c0000
    004e0000
    00500000
    00520000
    00540000
    00560000
    00580000
    005a0000
    005c0000
    005e0000
    00600000
    00620000
    00640000
    00660000
    00680000
    006a0000
    006c0000
    006e0000
    00700000
    00720000
    00740000
    00760000
    00780000
    007a0000
    007c0000
    007e0000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I am getting nand write issues as shown below

    ASHOK# nand write  ${loadaddr} 0x780000 0x400a000

    NAND write: device 0 offset 0x780000, size 0x400a000
    Attempt to write outside the flash area
     0 bytes written: ERROR

    Even If I make one partion with big size also I am getting same error.

    I am not sure what is the issue.

    Code changes:

    I added pinmux details in uboot and kernel. and enabled the 16bit in mem.h file as shown below.

    diff --git a/u-boot/arch/arm/include/asm/arch-am33xx/mem.h b/u-boot/arch/arm/include/asm/arch-am33xx/mem.h
    index ddcad62..be75403 100644
    --- a/u-boot/arch/arm/include/asm/arch-am33xx/mem.h
    +++ b/u-boot/arch/arm/include/asm/arch-am33xx/mem.h
    @@ -53,7 +53,8 @@
     #define GPMC_SIZE_32M  0xE
     #define GPMC_SIZE_16M  0xF
     
    -#define M_NAND_GPMC_CONFIG1 0x00000800
    +/*#define M_NAND_GPMC_CONFIG1 0x00000800  */ /*8 bit nand*/
    +#define M_NAND_GPMC_CONFIG1 0x00001810 /*ashok 16 bit nand*/
     #define M_NAND_GPMC_CONFIG2 0x001e1e00
     #define M_NAND_GPMC_CONFIG3 0x001e1e00
     #define M_NAND_GPMC_CONFIG4 0x16051807

    Please let me know is there any other code changes I have to do.

  • Hi Sunil and all,

    Some more updates.

    In Uboot log nand size is 512

    Configurou interrupcao

    Configurou LCD

    NAND:  512 MiB



    Here is the options enabled in the bootloader config file. Please let me know with respect to size/16bit do we have to do changes the

    value of CONFIG_SYS_NAND_PAGE_SIZE from to 2048 to 1024. 

      #define CONFIG_SPL_NAND_AM33XX_BCH
      #define CONFIG_SPL_NAND_SUPPORT
      #define CONFIG_SPL_NAND_BASE
      #define CONFIG_SPL_NAND_DRIVERS
      #define CONFIG_SPL_NAND_ECC
      #define CONFIG_SYS_NAND_5_ADDR_CYCLE

    #define CONFIG_SYS_NAND_PAGE_COUNT (CONFIG_SYS_NAND_BLOCK_SIZE / \
          CONFIG_SYS_NAND_PAGE_SIZE)
    #define CONFIG_SYS_NAND_PAGE_SIZE 2048
    #define CONFIG_SYS_NAND_OOBSIZE  64
    #define CONFIG_SYS_NAND_BLOCK_SIZE (128*1024)
    #define CONFIG_SYS_NAND_BAD_BLOCK_POS NAND_LARGE_BADBLOCK_POS
    #define CONFIG_SYS_NAND_ECCPOS  { 2, 3, 4, 5, 6, 7, 8, 9, \
          10, 11, 12, 13, 14, 15, 16, 17, \
          18, 19, 20, 21, 22, 23, 24, 25, \
          26, 27, 28, 29, 30, 31, 32, 33, \
          34, 35, 36, 37, 38, 39, 40, 41, \
          42, 43, 44, 45, 46, 47, 48, 49, \
          50, 51, 52, 53, 54, 55, 56, 57, }

    #define CONFIG_SYS_NAND_ECCSIZE  512
    #define CONFIG_SYS_NAND_ECCBYTES 14

    #define CONFIG_SYS_NAND_ECCSTEPS 4
    #define CONFIG_SYS_NAND_ECCTOTAL (CONFIG_SYS_NAND_ECCBYTES * \
          CONFIG_SYS_NAND_ECCSTEPS)

    #define CONFIG_SYS_NAND_U_BOOT_START CONFIG_SYS_TEXT_BASE

     #define CONFIG_SYS_NAND_U_BOOT_OFFS 0x80000

    /* NAND support */
    #ifdef CONFIG_NAND
    #define CONFIG_CMD_NAND
    #define CONFIG_CMD_MTDPARTS
    #define MTDIDS_DEFAULT   "nand0=omap2-nand.0"
    #define MTDPARTS_DEFAULT  "mtdparts=omap2-nand.0:128k(SPL)," \
         "128k(SPL.backup1)," \
         "128k(SPL.backup2)," \
         "128k(SPL.backup3),1920k(u-boot)," \
         "128k(u-boot-env),5m(kernel),-(rootfs)"

    #define CONFIG_NAND_OMAP_GPMC
    #define GPMC_NAND_ECC_LP_x16_LAYOUT 1
    #define CONFIG_SYS_NAND_BASE  (0x08000000) /* physical address */
           /* to access nand at */
           /* CS0 */
    #define CONFIG_SYS_MAX_NAND_DEVICE 1  /* Max number of NAND
              devices */

    Thanks in advance.