ubiattach not working on i.mx28 EVK ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ubiattach not working on i.mx28 EVK ?

4,527 Views
MarceloBarros
Contributor I

I installed a 256MB NAND in i.mx28 EVK REV D and I am trying to format and mount it using UBSFS. I am booting from an SDCARD and using the Linux version provided by FSL (2.6.35). I installed mtd-util and I am executing the following commands:

mknod /dev/ubi_ctrl c 10 63

flash_eraseall /dev/mtd1

ubiformat /dev/mtd1 -y

ubiattach /dev/ubi_ctrl -m 1

But ubiattach it is now working as expected:

ubiattach: error!: cannot attach mtd1
           error 38 (Function not implemented)

I updated mtd-util (now using 1.4.9, no success). Checking source code of libubi.c, it is possible to see that we have an error after a call to ioctrl. Kernel code at this point (drivers/mtd/ubi/cdev.c:ctrl_cdev_ioctl) is the same as code found at imx kernel code repository.

ret = ioctl(fd, UBI_IOCATT, r);

Any tips to solve this problem ?

Additional info:

root@/usr/bin$ cat /proc/mtd
dev:    size   erasesize  name
mtd0: 01400000 00020000 "gpmi-nfc-0-boot"
mtd1: 0ec00000 00020000 "gpmi-nfc-general-use"

root$ cat linux.config  | grep MTD | grep -v "^#"
CONFIG_MTD=y
CONFIG_MTD_DEBUG=y
CONFIG_MTD_DEBUG_VERBOSE=3
CONFIG_MTD_CONCAT=y
CONFIG_MTD_PARTITIONS=y
CONFIG_MTD_CMDLINE_PARTS=y
CONFIG_MTD_CHAR=y
CONFIG_MTD_BLKDEVS=y
CONFIG_MTD_BLOCK=y
CONFIG_MTD_MAP_BANK_WIDTH_1=y
CONFIG_MTD_MAP_BANK_WIDTH_2=y
CONFIG_MTD_MAP_BANK_WIDTH_4=y
CONFIG_MTD_CFI_I1=y
CONFIG_MTD_CFI_I2=y
CONFIG_MTD_M25P80=m
CONFIG_MTD_BLOCK2MTD=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_DENALI_

SCRATCH_REG_ADDR=0xFF108018
CONFIG_MTD_NAND_IDS=y
CONFIG_MTD_NAND_GPMI_NFC=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_RESERVE=1
CONFIG_MTD_UBI_DEBUG=y
CONFIG_MTD_UBI_DEBUG_MSG=y
CONFIG_MTD_UBI_DEBUG_MSG_BLD=y

roott$ cat linux.config  | grep UBI | grep -v "^#"
CONFIG_TCP_CONG_CUBIC=y
CONFIG_MTD_UBI=y
CONFIG_MTD_UBI_WL_THRESHOLD=4096
CONFIG_MTD_UBI_BEB_RESERVE=1
CONFIG_MTD_UBI_DEBUG=y
CONFIG_MTD_UBI_DEBUG_MSG=y
CONFIG_MTD_UBI_DEBUG_MSG_BLD=y
CONFIG_UBIFS_FS=y
CONFIG_UBIFS_FS_XATTR=y
CONFIG_UBIFS_FS_ADVANCED_COMPR=y
CONFIG_UBIFS_FS_LZO=y
CONFIG_UBIFS_FS_ZLIB=y
CONFIG_UBIFS_FS_DEBUG=y
CONFIG_UBIFS_FS_DEBUG_MSG_LVL=0


Labels (1)
0 Kudos
4 Replies

1,848 Views
ChristianPelleg
Contributor I

check ubi_ctl minor number for misc device in /proc/misc and if it is different from 63 (I have 60) re-mknod /dev/usb_ctl. I had the same error (ENOSYS) when it was wrong.

0 Kudos

1,848 Views
MichaelMinnick
NXP Employee
NXP Employee

Hi Marcelo,

Try enabling UBI debug messages in the kernel (MTD_UBI_DEBUG=y). You can find this in LTIB under "device drivers->MTD->UBI->UBI debug messages". Then after running ubiattach, type dmesg to see if any useful debug messages come out. Here is mine from a successful ubiattach:

dmesg
to free: PEB 3549, EC 1
UBI DBG (pid 2187): ubi_scan: process PEB 3550
UBI DBG (pid 2187): process_eb: scan PEB 3550
UBI DBG (pid 2187): ubi_io_read_vid_hdr: no VID header found at PEB 3550, only 0
xFF bytes
UBI DBG (pid 2187): add_to_list: add to free: PEB 3550, EC 1
UBI DBG (pid 2187): ubi_scan: process PEB 3551
UBI DBG (pid 2187): process_eb: scan PEB 3551
UBI DBG (pid 2187): ubi_io_read_vid_hdr: no VID header found at PEB 3551, only 0
xFF bytes
<<snip>>
UBI DBG (pid 2187): add_to_list: add to free: PEB 4053, EC 1
UBI DBG (pid 2187): ubi_scan: process PEB 4054
UBI DBG (pid 2187): process_eb: scan PEB 4054
UBI DBG (pid 2187): ubi_io_read_vid_hdr: no VID header found at PEB 4054, only 0
xFF bytes
UBI DBG (pid 2187): add_to_list: add to free: PEB 4054, EC 2
UBI DBG (pid 2187): ubi_scan: process PEB 4055
UBI DBG (pid 2187): process_eb: scan PEB 4055
UBI DBG (pid 2187): ubi_scan_add_used: PEB 4055, LEB 0:0, EC 2, sqnum 101, bitfl
ips 0
UBI DBG (pid 2187): ubi_scan: scanning is finished
UBI DBG (pid 2187): process_lvol: check layout volume
UBI DBG (pid 2187): uif_init: ubi0 major is 252
UBI DBG (pid 2187): ubi_add_volume: add volume 0
UBI: attached mtd1 to ubi0
UBI: MTD device name:            "gpmi-nfc-general-use"
UBI: MTD device size:            2028 MiB
UBI: number of good PEBs:        4052
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:     1
UBI: available PEBs:             0
UBI: total number of reserved PEBs: 4052
UBI: number of PEBs reserved for bad PEB handling: 40
UBI: max/mean erase counter: 3/1
UBI: image sequence number: 0
UBI: background thread "ubi_bgt0d" started, PID 2188
UBI DBG (pid 2187): ubi_open_volume: open device 0, volume 0, mode 1
UBI DBG (pid 2187): ubi_close_volume: close device 0, volume 0, mode 1
UBI DBG (pid 2187): ubi_open_volume: open device 0, volume 0, mode 2
 ubiblka:
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:0
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:512
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:1024
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:1536
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:2048
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:2560
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:3072
UBI DBG (pid 2191): ubi_leb_read: read 512 bytes from LEB 0:0:3584
 unknown partition table
UBI DBG (pid 2187): ubi_close_volume: close device 0, volume 0, mode 2
root@freescale ~$

-Mike

0 Kudos

1,848 Views
MarceloBarros
Contributor I

Hello Michael, thanks for answering !

Yes, mtdinfo provides a lot of information:

root@~$ mtdinfo -a
Count of MTD devices:           2
Present MTD devices:            mtd0, mtd1
Sysfs interface supported:      yes

mtd0
Name:                           gpmi-nfc-0-boot
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          160 (20971520 bytes, 20.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  2048 bytes
OOB size:                       64 bytes
Character device major/minor:   90:0
Bad blocks are allowed:         true
Device is writable:             true

mtd1
Name:                           gpmi-nfc-general-use
Type:                           nand
Eraseblock size:                131072 bytes, 128.0 KiB
Amount of eraseblocks:          1888 (247463936 bytes, 236.0 MiB)
Minimum input/output unit size: 2048 bytes
Sub-page size:                  2048 bytes
OOB size:                       64 bytes
Character device major/minor:   90:2
Bad blocks are allowed:         true
Device is writable:             true

flash_eraseall and ubiformat work as well. But ubiattach does not ...

Marcelo

0 Kudos

1,848 Views
MichaelMinnick
NXP Employee
NXP Employee


If you type:

mtdinfo -a

Does it find your NAND?

This is what worked for me using a Samsung 2GB MLC NAND K9GAG08U0M on the i.mx28 EVK board:

1. Build LTIB with UBIFS selected as the file system under target image generation options.

2. Set the kernel command line to:

noinitrd console=ttyAM0,115200 ubi.mtd=1 root=ubi0:rootfs rootfstype=ubifs rw rootwait ip=none gpmi

2. When LTIB finishes, type this to build the UBIFS image:

$ mkfs.ubifs -x none -m 4096 -e 516096 -c 4000 -r rootfs rootfs.ubifs

Note:
    No compression
    NAND block size (min I/O size) 4096 (use appropriate size for your NAND).
    Logical Erase Block Size (LEB) = 516096 (use size for your NAND, you can run the ubiattach command (see below) on the NAND to determine the proper LEB).
    Max number of LEB = 4000. For example, 4000*516096 = 1968 MB for 2G NAND.

3. Copy rootfs.ubifs and to the SD card. Also copy imx28_ivt_linux.sb to the SD card.

4. After booting from SD Card, type these commands:

flash_eraseall /dev/mtd0
kobs-ng init /imx28_ivt_linux.sb
sync
flash_eraseall /dev/mtd1
ubiattach /dev/ubi_ctrl -d 0 -m 1
ubimkvol /dev/ubi0 -N rootfs -m
ubiupdatevol /dev/ubi0_0 /rootfs.ubifs
sync

0 Kudos