Partition Problem / Flash Size

Hello,

I am build a new Image for my TP-Link WR6400 V5.3, that device has already official firmware, but i modified my device, while i need more space.

Originally has my TP-Link a Windbond W25Q64 Flash with 8 Mbit, i changed to W25Q128 with 16 MBit Flash size, porting was easy, i cloned the flash content from the 8 Mbit Flash and Write it to the 16 Mbit.

i added my new device profile:

my new .dts:

&spi0 {
        status = "okay";

        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <10000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        partition@0 {
                                label = "boot";
                                reg = <0x0 0x20000>;
                                read-only;
                        };

                        partition@20000 {
                                compatible = "tplink,firmware";
                                label = "firmware";
                                reg = <0x20000 0xfa0000>;
                        };
                        partition@fc0000 {
                                label = "config";
                                reg = <0xfc0000 0x10000>;
                                read-only;
                        };

                        factory: partition@fd0000 {
                                label = "factory";
                                reg = <0xfd0000 0x30000>;
                                read-only;
                        };
                };
        };
};

my old dts:

&spi0 {
        status = "okay";

        flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0>;
                spi-max-frequency = <10000000>;

                partitions {
                        compatible = "fixed-partitions";
                        #address-cells = <1>;
                        #size-cells = <1>;

                        partition@0 {
                                label = "boot";
                                reg = <0x0 0x20000>;
                                read-only;
                        };

                        partition@20000 {
                                compatible = "tplink,firmware";
                                label = "firmware";
                                reg = <0x20000 0x7a0000>;
                        };

                        partition@7c0000 {
                                label = "config";
                                reg = <0x7c0000 0x10000>;
                                read-only;
                        };

                        factory: partition@7d0000 {
                                label = "factory";
                                reg = <0x7d0000 0x30000>;
                                read-only;
                        };
                };
        };
};

new device config:

define Device/tplink_tl-mr6400-v5-16mb
  $(Device/tplink-v2)
  DEVICE_MODEL := TL-MR6400
  TPLINK_FLASHLAYOUT := 16Mmtk
  DEVICE_VARIANT := v5 16mb
  TPLINK_HWID := 0x64000005
  TPLINK_HWREV := 0x5
  TPLINK_HWREVADD := 0x5
  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \
        kmod-usb-serial-option kmod-usb-net-qmi-wwan uqmi
  IMAGES := sysupgrade.bin tftp-recovery.bin
  IMAGE/tftp-recovery.bin := pad-extra 128k | $$(IMAGE/factory.bin)
endef
TARGET_DEVICES += tplink_tl-mr6400-v5-16mb

device config:

My Partition Table 8 Mbit:

cat /proc/mtd:
dev:    size   erasesize  name
mtd0: 00020000 00010000 "boot"		=> 128kbib
mtd1: 007a0000 00010000 "firmware"	=> 7808kib
mtd2: 0021b67c 00010000 "kernel"	=> 2157kib
mtd3: 00584984 00010000 "rootfs"	=> 5650kib
mtd4: 001e0000 00010000 "rootfs_data"	=> 1920kib
mtd5: 00010000 00010000 "config"	=> 1024kib
mtd6: 00030000 00010000 "factory"	=> 192kib
config:
define Device/tplink_tl-mr6400-v5
  $(Device/tplink-v2)
  IMAGE_SIZE := 7808k
  DEVICE_MODEL := TL-MR6400
  DEVICE_VARIANT := v5
  TPLINK_FLASHLAYOUT := 8Mmtk
  TPLINK_HWID := 0x64000005
  TPLINK_HWREV := 0x5
  TPLINK_HWREVADD := 0x5
  DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \
        kmod-usb-serial-option kmod-usb-net-qmi-wwan uqmi
  IMAGES := sysupgrade.bin tftp-recovery.bin
  IMAGE/tftp-recovery.bin := pad-extra 128k | $$(IMAGE/factory.bin)
endef
TARGET_DEVICES += tplink_tl-mr6400-v5

after flashing my new image,i got these errors from booting:

[    0.368334] spi-mt7621 10000b00.spi: sys_freq: 193333333
[    0.388062] spi-nor spi0.0: w25q128 (16384 Kbytes)
[    0.392996] 4 fixed-partitions partitions found on MTD device spi0.0
[    0.399555] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.407025] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.414891] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.422332] OF: Bad cell count for /palmbus@10000000/spi@b00/flash@0/partitions
[    0.430362] Creating 4 MTD partitions on "spi0.0":
[    0.435310] 0x000000000000-0x000000020000 : "boot"
[    0.444206] 0x000000020000-0x000000ff0000 : "firmware"
[    0.451281] 2 tplink-fw partitions found on MTD device firmware
[    0.457392] Creating 2 MTD partitions on "firmware":
[    0.462446] 0x000000000000-0x000000222a59 : "kernel"
[    0.467493] mtd: partition "kernel" doesn't end on an erase/write block -- force read-only
[    0.478920] 0x000000222a5c-0x000000fd0000 : "rootfs"
[    0.483974] mtd: partition "rootfs" doesn't start on an erase/write block boundary -- force read-only
[    0.494511] mtd: setting mtd3 (rootfs) as root device
[    0.500837] 1 squashfs-split partitions found on MTD device rootfs
[    0.507203] 0x000000890000-0x000000fd0000 : "rootfs_data"
[    0.513939] 0x0000007c0000-0x0000007d0000 : "config"
[    0.522129] 0x0000007d0000-0x000000800000 : "factory"
[    0.583314] rt3050-esw 10110000.esw: mediatek esw at 0xb0110000, irq 25 initialized
[    0.592004] mtk_soc_eth 10100000.ethernet eth0: mediatek frame engine at 0xb0100000, irq 5
[    0.602272] NET: Registered protocol family 10
[    0.612519] Segment Routing with IPv6
[    0.616469] NET: Registered protocol family 17
[    0.621067] 8021q: 802.1Q VLAN Support v1.8
[    0.632610] unable to read id index table
[    0.637109] Flash size not aligned to erasesize, reducing to 13952KiB

[   15.830805] VFS: Cannot open root device "(null)" or unknown-block(31,3): error -5
[   15.838504] Please append a correct "root=" boot option; here are the available partitions:
[   15.846987] 1f00             128 mtdblock0 
[   15.846991]  (driver?)
[   15.853617] 1f01           16192 mtdblock1 
[   15.853620]  (driver?)
[   15.860253] 1f02            2186 mtdblock2 
[   15.860257]  (driver?)
[   15.866889] 1f03           14005 mtdblock3 
[   15.866893]  (driver?)
[   15.873517] 1f04            7424 mtdblock4 
[   15.873520]  (driver?)
[   15.880152] 1f05              64 mtdblock5 
[   15.880155]  (driver?)
[   15.886788] 1f06             192 mtdblock6 
[   15.886791]  (driver?)
[   15.893414] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)
[   15.901883] Rebooting in 1 seconds..

What are wrong with my partition files?
"Flash size not aligned to erasesize, reducing to 13952KiB" why?

i modified the mktplinkfw2 program, and added a modified layout:

 {
                .id             = "16Mmtk",
                .fw_max_len     = 0xfa0000,
                .kernel_la      = 0x80000000,
                .kernel_ep      = 0x80000000,
                .rootfs_ofs     = 0x140000,
        }

the program had only "8Mmtk", the others "16Mltq, 16Mqca" not worked, the router is bricked.

can any one help me? :slight_smile:

thank you!