Replaced chip 4m to 8m, but still shows small space

Hello!
I have built openwrt from trunk for TP Link WR-2041N v2 (941N v7 cn), changed in target/linux/ath79/image/tiny-tp-link.mk

define Device/tplink_tl-wr941n-v7-cn
$(Device/tplink-4mlzma)
SOC := qca9558
DEVICE_MODEL := TL-WR941N
DEVICE_VARIANT := v7 (CN)
TPLINK_HWID := 0x09410007
endef
TARGET_DEVICES += tplink_tl-wr941n-v7-cn

to

define Device/tplink_tl-wr941n-v7-cn
$(Device/tplink-8mlzma)
SOC := qca9558
DEVICE_MODEL := TL-WR941N
DEVICE_VARIANT := v7 (CN)
TPLINK_HWID := 0x09410007
endef
TARGET_DEVICES += tplink_tl-wr941n-v7-cn

because I replaced chip to 8M.
How I did?
Flashed router to chinese openwrt version, backed up art, then flashed breed to 'u-boot'. Next, I did chip dump on programmer and made 8M file to write on chip - dd if=/dev/zero of=router.rom bs=1K count=4096 seek=4096. After that, booted to breed, restored art and flashed my openwrt build.

And after successful boot I see this:
df -h

root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 3.0M 3.0M 0 100% /rom
tmpfs 29.4M 60.0K 29.3M 0% /tmp
tmpfs 29.4M 32.0K 29.4M 0% /tmp/root
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock4 36.0K 28.0K 8.0K 78% /overlay
overlayfs:/overlay 36.0K 28.0K 8.0K 78% /

root@OpenWrt:~# cat /proc/mtd

dev: size erasesize name
mtd0: 00020000 00001000 "u-boot"
mtd1: 003d0000 00001000 "firmware"
mtd2: 00171ea9 00001000 "kernel"
mtd3: 0025e154 00001000 "rootfs"
mtd4: 00009000 00001000 "rootfs_data"
mtd5: 00010000 00001000 "art"

Available only 8K! Must be at least 4M free. Why?

You need to change the DTS as well, the flash layout is hardcoded in there.

2 Likes
1 Like

I edited dts/qca9558_tplink_tl-wr941n-v7-cn.dts

                    uboot: partition@0 {
                            label = "u-boot";
                            reg = <0x000000 0x020000>;
                            read-only;
                    };

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

                    art: partition@7f0000 {
                            label = "art";
                            reg = <0x7D0000 0x800000>;
                            read-only;
                    };
            };

to

                    uboot: partition@0 {
                            label = "u-boot";
                            reg = <0x000000 0x020000>;
                            read-only;
                    };

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

                    art: partition@7f0000 {
                            label = "art";
                            reg = <0x3f0000 0x010000>;
                            read-only;
                    };
            };

Am I did (calculated) right?

root@OpenWrt:~# df -h
Filesystem Size Used Available Use% Mounted on
/dev/root 3.0M 3.0M 0 100% /rom
tmpfs 29.4M 60.0K 29.3M 0% /tmp
tmpfs 29.4M 32.0K 29.4M 0% /tmp/root
tmpfs 512.0K 0 512.0K 0% /dev
/dev/mtdblock4 4.0M 220.0K 3.8M 5% /overlay
overlayfs:/overlay 4.0M 220.0K 3.8M 5% /
root@OpenWrt:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00020000 00001000 "u-boot"
mtd1: 007d0000 00001000 "firmware"
mtd2: 00171ea8 00001000 "kernel"
mtd3: 0065e158 00001000 "rootfs"
mtd4: 00409000 00001000 "rootfs_data"
mtd5: 00030000 00001000 "art"

Now shows 3.8M free. That's brilliant! But I'm not sure that (clear) firmware can take ~3M. It's ok, or must be free more?

Looks wrong, both the old and the new one. Did you swap them above?

The second number is not the end of the area, but instead the length.

It should be

reg = <0x020000 0x7d0000>;
reg = <0x7f0000 0x010000>;

Quite normal hexadecimal math...

And you should somehow copy the art contents to 0x7f0000 (as originally they were at 0x3f0000 that is in the middle of the new large partition.

1 Like

Perhaps this could be helpfull to some extent, of course only after translation ;- )

reg = <0x020000 0x7d0000>;

Why 7D,
if art size is 10000=65536 bytes, 8M= 8 388 608 dec bytes, so it should be 8323072=0x7F0000 ?

                        uboot: partition@0 {
                                label = "u-boot";
                                reg = <0x000000 0x020000>;
                                read-only;
                        };

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

                        art: partition@7f0000 {
                                label = "art";
                                reg = <0x7F0000 0x010000>;
                                read-only;
                        };

Right! Forgot about bootloader, which size is 131072. Sorry!

That would have naturally been wrong, as a partition starting from 0x020000 with size 0x7F0000 would reach upto 0x810000, past your flash chip end...

I said already earlier that it is not the end but size.
Not < start end > but instead it is < start size >

1 Like

How about this?

                    uboot: partition@0 {
                            label = "u-boot";
                            reg = <0x000000 0x020000>;
                            read-only;
                    };

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

                    art: partition@7f0000 {
                            label = "art";
                            reg = <0x7F0000 0x010000>;
                            read-only;
                    };

Yes, now it looks ok.
( Just the values that I told you in message 6 of this thread... )

Ps usually those hex addresses in DTS are written with small caps, not capitals, but that may not hurt you, hopefully.

1 Like

Thank you everyone!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.