Support for TP-Link RE450 v1/v2 for 22.03 releases (Change of partition layout)

Hello together,

thank you very much for the great work for the RE450 platform.

Could somebody please explain why the support for the TP-Link RE450 v1/v2 discontinued for the 22.03 release ?
Was it perhaps only forgotten ? Because the RE450 v3 is supported in the 22.03 release.

Thank you very much for your support.

All the best

Maximum image size for v1/ v2 (thanks to the very unfortunate OEM partitioning) is 6016 KB, the 22.03.0 image (for the v3) already weighs 6168.2 KB.

1 Like

Oh this is not good because the RE450 V1 has 8 MB Flash and 64 Ram.

Does anybody know if its possible to repartioned the device to make the new image available ?

Thanks for your support.

All the best

We could try changing the current partition layout

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

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

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

                        partition@600000 {
                                label = "partition-table";
                                reg = <0x600000 0x010000>;
                                read-only;
                        };

                        info: partition@610000 {
                                label = "info";
                                reg = <0x610000 0x020000>;
                                read-only;
                        };

                        partition@630000 {
                                label = "config";
                                reg = <0x630000 0x1c0000>;
                                read-only;
                        };

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

Into

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

                        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;
                        };
                };

Hoping that the stock loader doesn't care about the partition-table... Probably it also breaks the possibility to go back to stock firmware, but who would want that anyway...

Thx. Looks like a solution. Could you build an image for the RE450v1 ? Upgrade then with normal sysupgrade ?

In my earlier post I made a mistake RE450 V1 has 8 MB Flash and 128 MB Ram not 64MB.

Does anybody know if tplink stock loader checks the partitions ?

Thank you for your support.

All the best

It isn't that simple, "info" partition contains the mac address:

&info {
	compatible = "nvmem-cells";
	#address-cells = <1>;
	#size-cells = <1>;

	macaddr_info_8: macaddr@8 {
		reg = <0x8 0x6>;
	};
};

Try flashing an older Openwrt build and backup the important partitions just in case:
cd /tmp

# Ensure the mtd numbers are the correct by running:
cat /proc/mtd

# Backup the partitions
cat /dev/mtd0 > u-boot.bak
cat /dev/mtd5 > partition-table.bak
cat /dev/mtd6 > info.bak
cat /dev/mtd7 > config.bak
cat /dev/mtd8 > art.bak
tar -cvjf backup.tar.bz2 u-boot.bak partition-table.bak info.bak config.bak art.bak

# Now copy the file using SCP
# Also possible through http like this:
cd /www
ln -s /tmp/backup.tar.bz2
# Now get the file at http://openwrt_ip/backup.tar.bz2

If you want to restore them at any point, you can use this:

# First, transfer the backup file to /tmp the file using SCP, wget, etc

# Unpack the backup
cd /tmp
tar -xvf backup.tar.bz2

# Make all partitions writable!
opkg update && opkg install kmod-mtd-rw
insmod mtd-rw.ko i_want_a_brick=1

# Restore partitions
mtd write partition-table.bak partition-table
mtd write info.bak info
mtd write config.bak config
reboot

I tried this:

target/linux/ath79/dts/qca9558_tplink_rex5x.dtsi

&spi {
	status = "okay";

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

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

			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;
			};

		};
	};
};

&eth0 {
	status = "okay";

	phy-handle = <&phy4>;
	pll-data = <0xa6000000 0x00000101 0x00001616>;
};

&wmac {
	status = "okay";

	mtd-cal-data = <&art 0x1000>;
};

target/linux/ath79/image/generic-tp-link.mk

define Device/tplink_rex5x-v1
  $(Device/tplink-safeloader)
  SOC := qca9558
  IMAGE_SIZE := 8000k
  DEVICE_PACKAGES := kmod-ath10k-ct-smallbuffers ath10k-firmware-qca988x-ct
endef

However the final image build still fails, complaining about file-system partition too big:
[mktplinkfw] firmware file "/home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_re450-v1-kernel.bin.new" completed
7787+1 records in
7787+1 records out
3987214 bytes (4.0 MB, 3.8 MiB) copied, 0.0263872 s, 151 MB/s
7787+1 records in
7787+1 records out
3987214 bytes (4.0 MB, 3.8 MiB) copied, 0.0322814 s, 124 MB/s
file-system partition too big (more than 3735552 bytes): Success
file-system partition too big (more than 3795099 bytes): Success
cp: cannot stat '/home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re450-v1-squashfs-factory.bin': No such file or directory
stat: cannot stat '/home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re450-v1-squashfs-sysupgrade.bin': No such file or directory
bash: line 0: [: 8192000: unary operator expected
bash: 8: Bad file descriptor
Failed to open firmware file
sha256sum: /home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re450-v1-squashfs-sysupgrade.bin: No such file or directory
cp: cannot stat '/home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re450-v1-squashfs-sysupgrade.bin': No such file or directory
[mktplinkfw] firmware file "/home/user/stuff/openwrt-22.03/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re450-v1-initramfs-kernel.bin.new" completed

So there's something else in the image build process limiting the final image size...probably around here:

target/linux/ath79/image/common-tp-link.mk

DEVICE_VARS += TPLINK_HWID TPLINK_HWREV TPLINK_FLASHLAYOUT TPLINK_HEADER_VERSION
DEVICE_VARS += TPLINK_BOARD_ID TPLINK_HWREVADD TPLINK_HVERSION

define Device/tplink-v1
  DEVICE_VENDOR := TP-Link
  TPLINK_HWID := 0x0
  TPLINK_HWREV := 0x1
  TPLINK_HEADER_VERSION := 1
  LOADER_TYPE := gz
  KERNEL := kernel-bin | append-dtb | lzma
  KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | tplink-v1-header
  IMAGES += factory.bin
  IMAGE/sysupgrade.bin := tplink-v1-image sysupgrade | append-metadata
  IMAGE/factory.bin := tplink-v1-image factory
endef

define Device/tplink-safeloader
  $(Device/tplink-v1)
  TPLINK_HWREV := 0x0
  KERNEL := kernel-bin | append-dtb | lzma | tplink-v1-header -O
  KERNEL_INITRAMFS := $$(KERNEL)
  IMAGE/sysupgrade.bin := append-rootfs | tplink-safeloader sysupgrade | \
	check-size | append-metadata
  IMAGE/factory.bin := append-rootfs | tplink-safeloader factory
endef

However if I remove the wireless support to free up space:

target/linux/ath79/image/generic-tp-link.mk

define Device/tplink_rex5x-v1
  $(Device/tplink-safeloader)
  SOC := qca9558
  IMAGE_SIZE := 8000k
#  DEVICE_PACKAGES := kmod-ath10k-ct-smallbuffers ath10k-firmware-qca988x-ct
endef

define Device/tplink_re450-v1
  $(Device/tplink_rex5x-v1)
  DEVICE_MODEL := RE450
  DEVICE_VARIANT := v1
  TPLINK_BOARD_ID := RE450
  SUPPORTED_DEVICES += re450
endef
TARGET_DEVICES += tplink_re450-v1

Clear the config:

rm .config

And re-create it in menuconfig, it compiles.
I have no idea whether wired networking will fail without the mac address field, or if it will fallback to a default value.

So I made three different builds, all without wifi (it's impossible to make it fit otherwise), test in this order!
Proceed at your own risk!

  • Original partitioning. If wired networking works, try next build.

  • Original partitioning, removing the mac fields from DTS, to see what happens without mac.
    It's still safe as it won't modify the special partitions, in case unusable network/kernel panic you can still recover using uboot method.
    If wired network still works, ensure to make a backup of the partitions and try next build.

  • Modded partitioning, where partition-table+config+info are removed from DTS and the firmware area is extended to use that space.
    It could boot at first, but it's likely the special partitions will get wiped on first boot, when openwrt initializes the JFFS2 filesystem.
    This can take few minutes (Wait until system led stops blinking), then the reported partition space in LuCi should report about 2MB free (Totally empirical).
    Now this is the moment of true. Openwrt wiped all those partitions, and after the next reboot we'll finally see if u-boot takes care of these partitions or not.
    If it keeps booting nicely, then it's probable that only the original FW use them.

  • kmod-mtd-rw is already included in these builds, so no need to use opkg update/install, only the insmod line!

https://anonfiles.com/V8vcm6C9y6/Openwrt_22.03_test_re450v1_zip

2 Likes

It worked, now we proofed that these OEM partitions do not needed for uboot and OpenWrt.
Thank you very much for your efforts. :slight_smile:

Now only the problem needs to be resolved what is limiting the final image size that we can build an image with wifi support :wink:

Partitions after the third image installed :wink:

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 007d0000 00010000 "firmware"
mtd2: 00221765 00010000 "kernel"
mtd3: 005ae89b 00010000 "rootfs"
mtd4: 00230000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "art"

Thank you very much for your help and support.
All the best

2 Likes

Probably we also need to modify this file, removing the partitions:

build_dir/host/firmware-utils-2022-04-25-ddc3e00e/src/tplink-safeloader.c

	/** Firmware layout for the RE450 */
	{
		.id     = "RE450",
		.vendor = "",
		// (...)
		.partitions = {
			{"fs-uboot", 0x00000, 0x20000},
			{"firmware", 0x20000, 0x5e0000},
			{"partition-table", 0x600000, 0x02000},
			{"default-mac", 0x610000, 0x00020},
			{"pin", 0x610100, 0x00020},
			{"product-info", 0x611100, 0x01000},
			{"soft-version", 0x620000, 0x01000},
			{"support-list", 0x621000, 0x01000},
			{"profile", 0x622000, 0x08000},
			{"user-config", 0x630000, 0x10000},
			{"default-config", 0x640000, 0x10000},
			{"radio", 0x7f0000, 0x10000},
			{NULL, 0, 0}
		},

But it seems it's not so simple due the firmware update format.
You could try to install the wireless packages as a workaround:

opkg update && opkg install kmod-ath10k-ct-smallbuffers ath10k-firmware-qca988x-ct

But maybe it will complain about non-matching kernel version, give it a try.
In any case, you could compile with the said instructions, then in menuconfig enable these packages as modules by pressign m, you'll see it sets like <M>, afterwards you can manually download these packages into the router and install them.

It finally compiled. Something broke and had to completely reset the sources.
Also I was having trouble with tabs/spaces in the patch file and getting the patch rejected.

These are the files needed to compile using fresh openwrt 22.03 sources.
https://anonfiles.com/8b50raC3yf/Openwrt_22.03_RE450v1.tar_bz2

Clone openwrt 22.03 sources and extract the tar file overwriting the existing files.

If you already compiled openwrt in that source folder, you don't need to wipe everything and start over, just apply the modded files and recompile firmware-utils to apply the patch:

make tools/firmware-utils/clean
make tools/firmware-utils/compile

Then compile normally:

scripts/feeds update -a
scripts/feeds install -a

make menuconfig
#Configure the system, selecting the packages you want, ex. LuCi, etc, exit saving the config.
#----Target System (Atheros ATH79)
#----Subtarget (Generic)
#----Target Profile (TP-Link RE450 v1)

make -sjN
#Where N is your CPU cores+1, ex. -sj9

#Get the compiled images at bin/target/ath79/generic

But probably a stock Openwrt/OEM firmware won't allow to flash these images as they would overlap other partitions?

So when coming from OEM partitioning firmware, it might need to be done in several steps:

  • Flash older existing Openwrt image
  • Backup the partitions as described here
  • Download the first test images
  • Flash the image [Modded_partitioning][No_Wifi], which still fits the original system partition.
  • Now the system partition layout is larger, it should allow flashing a larger image that would normally overlap with partition-table, info and config partitions.

Here're the builds with wifi support and LuCi, system partition is larger than original limit so proceed with care and having made all backups first!
I have no idea wether the firmware image modification will work, brick your device, or just get refused.
https://anonfiles.com/5752r5C1ye/re450-v1_22.03_test_zip

To revert to original firmware:

  • Download the first test images
  • Flash the image [Original_partitioning][No_Wifi], which includes writable mtd.
  • Restore the partitions as described here
  • Flash the OEM firmware with the required method (Openwrt, U-Boot recovery, etc)
1 Like

Absolutely great !!! Thank you very much works like a charm and now we have a lot of free space for addons.

There is one issue in regards of the MAC adresses of the devices they will be now choosen randomly. But it is easy to adress by configuring them to fix adresses :wink:

How is the procedure that these changes will come into the future releases of openwrt that regulary builds will be available again for the future ?

Thank you so much for your work !!! :slight_smile: :slight_smile: :slight_smile:

All the best

The procedure is exactly as I described in my previous post.
Could you try flashing back the [Original_partitioning][No_Wifi] firmware, then trying to flash the latest build you've just applied, and see if having a different partition layout works when flashing larger images than original firmware partition size (Which I doubt), and confirm the two-step update requirement.

I flashed back to the first image [Original_partitioning][No_Wifi] firmware with no problems. After that I flashed as well without any problems back to the latest build from you without any problems. The flasher is telling you that you try to flash an image that does not fit into the flash memory and you have to force the upgrade (checkbox). After that I had as well the same free disk space as before

Understood but misunderstanding. I mean can we not make your patch available for the whole community that everybody can use the benefits of more disk space now for further future releases as well of earlier releases of OpenWrt ?

Then, when coming from OEM firmware, an old version of Openwrt must be flashed first, then force upgrade of modded image.

The hard part is already done, the files and the instructions are there, anyone can compile it in no time, there're ready to flash builds available.

I'm not an Openwrt developer, but I doubt these changes will be implemented into official Openwrt because installation requires some tedious and very delicated steps.

All those OEM partitions will get wiped, and unlike normal Openwrt would do, rolling back to OEM FW won't be straighforward.

It's easy to break something or even completely brick the device.

@daniel

Hi Daniel,
as you can see dabyd64 has made all descriptions & patches available for increasing the free disk space for the image up to 1,88 MB with an installed 22.03. Could this be integrated into the official Openwrt world ? Possibly the patches are valid for all tplink repeaters.

Thank you for your support.
All the best

could we shrink the default image by removing
for example ppp ppp-mod-pppoe?

You can do that (how long that gets you by into the future is a different question), for the default releases, the installed package set is the same for all devices and won't be customized on a per-package basis.

@slh : Absolutely right. We need a developer who could integrate the working patches from @daniel into the generic openwrt release for the tplink RE450v1. With the patches we will get again with luci 1,88MB free space.

@dabyd64 could you create a pull request for the changes?

Did anybody consider/tried moving RE450v1 to the tiny target. Similar move was accepted by upstream already for other routers with the same problem - for example here: https://github.com/openwrt/openwrt/commit/44e1e5d153d00915a7e516c9af3f440cbd84cf78

Hei dabyd64. Do you still got the sources? Could I get a new link?