Attach ubifs with linux-imx 4.1.15 and u-boot-fslc 2015-10

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

Attach ubifs with linux-imx 4.1.15 and u-boot-fslc 2015-10

2,863 Views
dunax
Contributor I

Hello,

I'm working on an imx6 of phytec with 1GB nand and I want to write my rootfs.ubifs in nand from u-boot and be able to mount it at boot.

My ubifs is build from yocto as follow:

MKUBIFS_ARGS = "-F -m 2048 -e 126976 -c 8083"
UBINIZE_ARGS = "-m 2048 -p 128KiB -s 2048 -O 2048"

IMAGE_CMD_ubi () {
    echo \[ubifs\] > ubinize.cfg
    echo mode=ubi >> ubinize.cfg
    echo image=${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs >> ubinize.cfg
    echo vol_id=0 >> ubinize.cfg
    echo vol_type=dynamic >> ubinize.cfg
    echo vol_name=${UBI_VOLNAME} >> ubinize.cfg
    echo vol_flags=autoresize >> ubinize.cfg
    mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS}
    ubinize -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubi ${UBINIZE_ARGS} ubinize.cfg
}
IMAGE_TYPEDEP_ubi = "ubifs"

IMAGE_CMD_ubifs = "mkfs.ubifs -r ${IMAGE_ROOTFS} -o ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.rootfs.ubifs ${MKUBIFS_ARGS}"

My deviceTree content:

&gpmi {
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_gpmi_nand>;
    nand-on-flash-bbt;
    status = "disabled";
    #address-cells = <1>;
    #size-cells = <1>;
    
    partition@0 {
        label = "bootloader";
        reg = <0x80000 0x80000>;
    };
    partition@1 {
        label = "backup-bootloader";
        reg = <0x240000 0x80000>;
    };
    partition@2 {
        label = "environment";
        reg = <0x1000000 0x20000>;
    };
    partition@3 {
        label = "backup-environment";
        reg = <0x1080000 0x20000>;
    };
    partition@4 {
        label = "devicetree";
        reg = <0x1100000 0x100000>;
    };
    partition@5 {
        label = "kernel";
        reg = <0x1200000 0x800000>;
    };
    partition@6 {
        label = "initrd";
        reg = <0x1a00000 0x400000>;
    };
    partition@7 {
        label = "filesystem";
        reg = <0x1e00000 0x10000000>;
    };
};

1) To write my ubifs in nand from uboot I do :

=> mtdparts

device nand0 <gpmi-nand>, # parts = 8
 #: name                size            offset          mask_flags
 0: bootloader          0x00080000      0x00080000      0
 1: backup-bootloader   0x00080000      0x00240000      0
 2: environment         0x00020000      0x01000000      0
 3: backup-environment  0x00020000      0x01080000      0
 4: devicetree          0x00100000      0x01100000      0
 5: kernel              0x00800000      0x01200000      0
 6: initrd              0x00400000      0x01a00000      0
 7: filesystem          0x10000000      0x01e00000      0

active partition: nand0,0 - (bootloader) 0x00080000 @ 0x00080000

=> ext4load mmc 0:2 0x20000000 rootfs.ubifs // load ubifs from ext4 partition of SD card

=> ubi part filesystem

=> ubi create rootfs

=> ubi write 0x20000000 rootfs 0x30ae000 // size ubifs

Then I set the bootargs:

=> setenv bootargs console=${console},${baudrate} rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs

And I try too boot:

=> run loadfdt_from_nand; run loadimage_from_nand; bootz ${loadaddr} - ${fdt_addr}

But when kernel tries to mount attach ubifs I get these logs and it continues endlessly:

[   74.083436] ubi0: attaching mtd7
[   74.088030] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[   74.099909] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[   74.111746] ubi0 warning: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read only 64 bytes, retry
[   74.123613] ubi0 error: ubi_io_read: error -74 (ECC error) while reading 64 bytes from PEB 0:0, read 64 bytes

...

2) I also tried to write ubifs from Linux (from SD Card). To write ubifs in nand I did:

=>ubiformat /dev/mtd7
=>ubiattach -p /dev/mtd7
=>ubimkvol /dev/ubi0 -N rootfs -m

=>ubiupdatevol /dev/ubi0_0 rootfs.ubifs

With this approach I can boot from nand but I can't attach the ubifs from uboot:

=>ubi part filesystem
UBI: attaching mtd1 to ubi0
UBI: scanning is finished
UBI init error 22

3) Am I right to suppose that if I write ubifs from u-boot and can't attach it from Linux and vis versa that means Kernel and u-boot don't use the same ECC algorithm ? And if it's true how can I verify or change ECC algorithm in order to be able to attach ubifs from Linux and u-boot ?

Best regards,

Dunax.

0 Kudos
Reply
2 Replies

1,511 Views
b36401
NXP Employee
NXP Employee

You need to use the same NAND driver in both u-boot and kernel for theit ECC algorithm to fit.

Have a great day,
Victor

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos
Reply

1,511 Views
pietercardoen
Contributor II

Dear

I have already read multiple times that the ECC algorithm needs to fit. However this doesn't help...

Can you please explain how you can verify the ECC configuration in kernel and in u-boot...

Best regards

Pieter Cardoen

0 Kudos
Reply