Using spare firmware2 empty space as actual storage on ASUS RT-AX53U

What I want to do is, include mtd8 into the actual storage. See, in here mtd8 is empty, I checked it's content, it's a backup firmware but it's not used by the openwrt. I am doing some experiments so why not poke this?

I actually temporarily removed mtd8's contents, and rebooted. It worked fine, I think it doesn't have any critical data there.

root@OpenWrt:~# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00080000 00020000 "u-boot"
mtd1: 00060000 00020000 "u-boot-env"
mtd2: 00100000 00020000 "nvram"
mtd3: 00100000 00020000 "factory"
mtd4: 00100000 00020000 "factory2"
mtd5: 03200000 00020000 "firmware"
mtd6: 00400000 00020000 "kernel"
mtd7: 02e00000 00020000 "ubi"
mtd8: 03200000 00020000 "firmware2"
mtd9: 01020000 00020000 "jffs2"

I've been trying to recompile a firmware just for this, I've downloaded openwrt source code. Then I changed the /target/linux/ramips/dts/mt7621_asus_rt-ax53u.dts file, I changed the mtd partitions to this:
The part about mtd partitions was like this:

&nand {
	status = "okay";

	mediatek,nmbm;
	mediatek,bmt-remap-range =
		<0x000000 0x7e0000>,
		<0x35e0000 0x7800000>;

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

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

		/*
		 * u-boot gets split here while keeping u-boot read-only,
		 * which allows safe usage of fw_setenv
		 */
		partition@80000 {
			label = "u-boot-env";
			reg = <0x80000 0x60000>;
		};

		partition@e0000 {
			label = "nvram";
			reg = <0xe0000 0x100000>;
			read-only;
		};

		partition@1e0000 {
			label = "factory";
			reg = <0x1e0000 0x100000>;
			read-only;

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

				eeprom_factory_0: eeprom@0 {
					reg = <0x0 0xe00>;
				};

				macaddr_factory_4: macaddr@4 {
					reg = <0x4 0x6>;
				};

				precal_factory_e10: precal@e10 {
					reg = <0xe10 0x19c10>;
				};
			};
		};

		partition@2e0000 {
			label = "factory2";
			reg = <0x2e0000 0x100000>;
			read-only;
		};

		partition@3e0000 {
			label = "firmware";
			reg = <0x3e0000 0x3200000>;

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

			partition@0 {
				label = "kernel";
				reg = <0x0 0x400000>;
			};

			partition@400000 {
				label = "ubi";
				reg = <0x400000 0x2e00000>;
			};
		};

		partition@35e0000 {
			label = "firmware2";
			reg = <0x35e0000 0x3200000>;
		};

		partition@67e0000 {
			label = "jffs2";
			reg = <0x67e0000 0x1020000>;
		};

		/* Last 8M are reserved for NMBM management (bad blocks) */
	};
};

And now I changed it to this, calculating the maths and removing the firmware2, adding it to the UBI:

&nand {
	status = "okay";

	mediatek,nmbm;
	mediatek,bmt-remap-range =
		<0x000000 0x7e0000>,
		<0x35e0000 0x7800000>;

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

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

		/*
		 * u-boot gets split here while keeping u-boot read-only,
		 * which allows safe usage of fw_setenv
		 */
		partition@80000 {
			label = "u-boot-env";
			reg = <0x80000 0x60000>;
		};

		partition@e0000 {
			label = "nvram";
			reg = <0xe0000 0x100000>;
			read-only;
		};

		partition@1e0000 {
			label = "factory";
			reg = <0x1e0000 0x100000>;
			read-only;

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

				eeprom_factory_0: eeprom@0 {
					reg = <0x0 0xe00>;
				};

				macaddr_factory_4: macaddr@4 {
					reg = <0x4 0x6>;
				};

				precal_factory_e10: precal@e10 {
					reg = <0xe10 0x19c10>;
				};
			};
		};

		partition@2e0000 {
			label = "factory2";
			reg = <0x2e0000 0x100000>;
			read-only;
		};

		partition@3e0000 {
			label = "firmware";
			reg = <0x3e0000 0x6400000>;

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

			partition@0 {
				label = "kernel";
				reg = <0x0 0x400000>;
			};

			partition@400000 {
				label = "ubi";
				reg = <0x400000 0x6000000>; #here I removed firmware2 and added it to this UBI.
			};
		};

		partition@67e0000 {
			label = "jffs2";
			reg = <0x67e0000 0x1020000>;
		};

		/* Last 8M are reserved for NMBM management (bad blocks) */
	};
};

And then I changed this file target/linux/ramips/image/mt7621.mk, this is the stock file about rt-ax53u:

define Device/asus_rt-ax53u
  $(Device/nand)
  DEVICE_VENDOR := ASUS
  DEVICE_MODEL := RT-AX53U
  DEVICE_ALT0_VENDOR := ASUS
  DEVICE_ALT0_MODEL := RT-AX1800U
  IMAGE_SIZE := 51200k
  IMAGES += factory.bin
  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
  DEVICE_PACKAGES := kmod-mt7915-firmware kmod-usb3 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += asus_rt-ax53u

to this:

define Device/asus_rt-ax53u
  $(Device/nand)
  DEVICE_VENDOR := ASUS
  DEVICE_MODEL := RT-AX53U
  DEVICE_ALT0_VENDOR := ASUS
  DEVICE_ALT0_MODEL := RT-AX1800U
  IMAGE_SIZE := 102400k
  IMAGES += factory.bin
  IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \
        check-size
  DEVICE_PACKAGES := kmod-mt7915-firmware kmod-usb3 kmod-usb-ledtrig-usbport
endef
TARGET_DEVICES += asus_rt-ax53u

And I selected ax53u from the make menuconfig and all, then compiled it. I flashed the compiled file. But it still has 32mb empty space. I think I did something dumb.

Try to create additional ubi partition?

What I want to do is, just install samba4 to that, but I am not sure if opkg supports having two different places for stuff. If it were, I'd not need anything. ChatGPT says it's possible but I think it's just lying.

That's why you were given the extroot link in your other thread about this...

For once, AI's on the right track.

1 Like

Extroot is possible, I'll probably do that later. But having two locations for opkg isn't possible?

Isn't that exactly what extroot's doing ?

It is definitely possible to use that space. I have done it for my RT-AX53U.

But isn't ksmbd-server sufficient for your purposes? I ended up using it while I also noticed Samba4 was huge to install.

Extroot makes the / area cover the usb disk instead. How is it the same? I want to maybe merge mtd7-8 together, or use mtd8 too. Right?

How have you done it though? Explain please.

Do you have serial connection to it?

I might do that. When i get hands on the device again. I will be away for some while because of health issues.

You have to compile a firmware of your own as you already have done.

Do not change anything but the dts file nand definition. Mine looks like this:

&nand {
        status = "okay";

        mediatek,nmbm;
        mediatek,bmt-remap-range =
                <0x000000 0x7e0000>,
                <0x35e0000 0x7800000>;

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

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

                /*
                 * u-boot gets split here while keeping u-boot read-only,
                 * which allows safe usage of fw_setenv
                 */
                partition@80000 {
                        label = "u-boot-env";
                        reg = <0x80000 0x60000>;
                };

                partition@e0000 {
                        label = "nvram";
                        reg = <0xe0000 0x100000>;
                        read-only;
                };

                partition@1e0000 {
                        label = "factory";
                        reg = <0x1e0000 0x100000>;
                        read-only;
                        nvmem-layout {
                                compatible = "fixed-layout";
                                #address-cells = <1>;
                                #size-cells = <1>;

                                eeprom_factory_0: eeprom@0 {
                                        reg = <0x0 0xe00>;
                                };

                                macaddr_factory_4: macaddr@4 {
                                        reg = <0x4 0x6>;
                                };

                                precal_factory_e10: precal@e10 {
                                        reg = <0xe10 0x19c10>;
                                };
                        };
                };

                partition@2e0000 {
                        label = "factory2";
                        reg = <0x2e0000 0x100000>;
                        read-only;
                };

                partition@3e0000 {
                        label = "kernel";
                        reg = <0x3e0000 0x400000>;
                };

                partition@7e0000 {
                        label = "ubi";
                        reg = <0x7e0000 0x7020000>;
                };

                /* Last 8M are reserved for NMBM management (bad blocks) */
        };
};

Then you have to use u-boot option to flash firmware. You need the serial connection to do this. It's possible this can be done through original FW and terminal, but I have not done it that way.

While it boots up to your own FW it should have nand partitios like this in dmesg:

[    1.654146] Creating 7 MTD partitions on "mt7621-nand":
[    1.659383] 0x000000000000-0x000000080000 : "u-boot"
[    1.668096] 0x000000080000-0x0000000e0000 : "u-boot-env"
[    1.675938] 0x0000000e0000-0x0000001e0000 : "nvram"
[    1.685811] 0x0000001e0000-0x0000002e0000 : "factory"
[    1.696231] 0x0000002e0000-0x0000003e0000 : "factory2"
[    1.706523] 0x0000003e0000-0x0000007e0000 : "kernel"
[    1.727331] 0x0000007e0000-0x000007800000 : "ubi"

however it does not work until you ubiformat the overlay partition for it to take all available space. It might need to be unmount first. Then it needs reboot.

I did this all from u-boot and I'm not sure if I changed u-boot partition settings too.

You just need to try it.

But - again - isn't ksmbd-server probably even better choise? Because the culprint in making it this way is, that you can't update it using precompiled update FW, because changes in nand are overdriven by update.

1 Like

Because extroot doesn't care what kind of storage it is ?
Nothing stops you from using /dev/mtd[whatever] instead of /dev/sdX.