AnsweredAssumed Answered

UBI Attaching fails due to improper NAND flash erase.

Question asked by Koil Arul Raj on Jun 1, 2018
Latest reply on Jun 18, 2018 by igorpadykov

Hi,

 

I am trying to format and flash the iMX7 Solo custom board having NAND flash with MFGTool.

 

This is my mtdparts command output.
U-boot> mtdparts

device nand0 <gpmi-nand>, # parts = 5
 #: name                size            offset          mask_flags
 0: boot                0x04000000      0x00000000      0
 1: kernel              0x01000000      0x04000000      0
 2: dtb                 0x01000000      0x05000000      0
 3: initrd              0x00400000      0x06000000      0
 4: rootfs              0x79c00000      0x06400000      0

 

active partition: nand0,0 - (boot) 0x04000000 @ 0x00000000

defaults:
mtdids  : nand0=gpmi-nand
mtdparts: mtdparts=gpmi-nand:64m(boot),16m(kernel),16m(dtb),4m(initrd),-(rootfs)

 

While erasing the rootfs partition using flash_erase command(flash_erase /dev/mtd4 0 0) using MFGTool, some bad blocks are skipped as shown below.

LOG:
flash_erase /dev/mtd4 0 0
Erasing 512 Kibyte @ 79980000 -- 99 % complete flash_erase: Skipping bad block at 79a00000
flash_erase: Skipping bad block at 79a80000
flash_erase: Skipping bad block at 79b00000
flash_erase: Skipping bad block at 79b80000
Erasing 512 Kibyte @ 79b80000 -- 100 % complete

 

To erase those bad blocks, I added the option -N as per the flash_erase command help (flash_erase -N /dev/mtd4 0 0). But it throws the following error.

LOG:
% nand: nand_erase_nand: attempt to erase a bad block at page 0x0007fe00
Erasing 512 Kibyte @ 78nand: nand_erase_nand: attempt to erase a bad block at page 0x0007fe80
Erasing 512 Kibyte @ 78400000 -- 98 % conand: nand_erase_nand: attempt to erase a bad block at page 0x0007ff00
Erasing 512 Kibyte @ 7848nand: nand_erase_nand: attempt to erase a bad block at page 0x0007ff80
Erasing 512 Kibyte @ 79a00000 -- 99 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 3892 (mtd4)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd4: MTD Erase failure
             error 5 (Input/output error)
Erasing 512 Kibyte @ 79a80000 -- 99 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 3893 (mtd4)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd4: MTD Erase failure
             error 5 (Input/output error)
Erasing 512 Kibyte @ 79b00000 -- 99 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 3894 (mtd4)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd4: MTD Erase failure
             error 5 (Input/output error)
Erasing 512 Kibyte @ 79b80000 -- 99 % complete libmtd: error!: MEMERASE64 ioctl failed for eraseblock 3895 (mtd4)
        error 5 (Input/output error)
flash_erase: error!: /dev/mtd4: MTD Erase failure
             error 5 (Input/output error)
Erasing 512 Kibyte @ 79b80000 -- 100 % complete

 

I need to erase those bad blocks also. Because I added UBI command support to my Uboot. While trying to attach with rootfs partition using "ubi part ${partition_name}" command, Attaching fails due to the bad Physical Erase Blocks(PEB) containing the bad image sequence number. The exact error message from U-Boot can be given as follows,

LOG:

scan_peb:bad image sequence number 1583579994 in PEB 3892, expected 220897030
scan_peb:bad image sequence number 1583579994 in PEB 3893, expected 220897030

 

These Physical Erase Blocks are not correctly erased during MFGTool flashing.

 

Also another important thing is that, from uboot if we erase the rootfs partition using "U-Boot> nand erase.part rootfs" command and then flashed the images using MFGTool. Now if we try to attach with the given partition using "ubi part ${partition_name}" command there is no issue. And the above the mentioned uboot error didn't appear due to proper erasing of all the PEBs. But the issue occurs if we don't use the "nand erase" command.

 

Please help me to achieve this clean erase while flashing with MFGTools itself.

 

Thanks,

Koil Arul Raj S

Outcomes