MTD partition offset not correctly mapped when bad eraseblocks present
Username: Marco
Origin: https://bugs.openwrt.org/index.php?do=details&task_id=1926
- Device problem occurs on
Netgear R6220
- Software versions of OpenWrt/LEDE
OpenWrt 18.06.1, r7258-5eb05530
When OpenWrt detects a bad eraseblock, all following offsets are sifted by one.
I’ll try to explain better this issue with an example.
We have this situation in kernel log:
[ 2.853468] nand: device found, Manufacturer ID: 0xc2, Chip ID: 0xf1
[ 2.866112] nand: Macronix NAND 128MiB 3,3V 8-bit
[ 2.875473] nand: 128 MiB, SLC, erase size: 128 KiB, page size: 2048, OOB si4
[ 2.890555] Scanning device for bad blocks
[ 2.969549] Bad eraseblock 266 at 0x000002140000
[ 3.096049] Bad eraseblock 708 at 0x000005880000
[ 3.189001] 6 fixed-partitions partitions found on MTD device MT7621-NAND
[ 3.202518] Creating 6 MTD partitions on "MT7621-NAND":
[ 3.212922] 0x000000000000-0x000000100000 : "u-boot"
[ 3.223925] 0x000000100000-0x000000200000 : "SC PID"
[ 3.234878] 0x000000200000-0x000000600000 : "kernel"
[ 3.245854] 0x000000600000-0x000002200000 : "ubi"
[ 3.256476] 0x000002e00000-0x000002f00000 : "factory"
[ 3.267585] 0x000004200000-0x000007e00000 : "reserved"
[ 3.279423] [mtk_nand] probe successfully!
As you can see there are 2 bad eraseblocks. Let’s leave the last one, since it is at the end of the flash.
The kernel states that the ‘factory’ partition starts at 0x2e00000 (that’s correct), but in reality OpenWrt will search for the partition at 0x2e20000 (2e00000 + (1 * 128KiB)).
People that have 3 bad eraseblocks before the factory partition reported that their mtd4 (factory) partition content reflects what is in nand at 0x2e60000 (0x2e00000 + (3 * 128KiB)).
This issue led to the wrong belief that there is more than one flash layout for this device, as reported in
OpenWrt device page
too.
A rapid check with
sc_nand r
from U-boot prompt can confirm this behavior.