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.