R6220/R6230 unable to mount 60MB partition MTD5

Hello there, long time OpenWRT user first time poster. I am using 19.07.7

I have a Netgear R6230 that OpenWRT is installed on. OpenWRT doesn't actually have a firmware for the R6230 but It's hardware is nearly identical to the R6220 so it's recommended to use the R6220 firmware and indeed this works great! With one issue that is... Here is link to TOH and more info on the R6230: https://openwrt.org/toh/netgear/netgear_r6230

The 6220/6230 both have 20Mb of free space for files and Entware packages following an OpenWRT installation, however they also both have a partition labeled MTD5 which is 60MB in size and is not mounted by the default OpenWRT firmware. If one wishes to use this partition then is required to mount it for the first time manually and setup auto-mount scripting for thereafter. There is also other empty and or unused partitions but I will talk about those farther down... Anywho, I try to mount MTD5 like the instructions say here:

https://openwrt.org/toh/netgear/netgear_r6220 This page contains instructions for mounting the 60Mb partition on the R6220.

I get an error halfway through that I am not able to overcome. I have tried duckduckgoing the problem as well as searching this forum and have obviously turned up nothing I can use. I am sure the solution is out there but I am unable to find it by myself.
So I humbly ax the Gods of OpenWRT for help in my quest for an extra 60+MB....

Here is the error I get.....

root@OpenWrt_R6230:/tmp# opkg install kmod-mtd-rw
Installing kmod-mtd-rw (4.14.221+git-20160214-1) to root...
Downloading http://downloads.openwrt.org/releases/19.07.7/targets/ramips/mt7621/kmods/4.14.221-1-2e88863ccdd594fb8e842df3c25842ee/kmod-mtd-rw_4.14.221%2Bgit-20160214-1_mipsel_24kc.ipk
Configuring kmod-mtd-rw.
root@OpenWrt_R6230:/tmp# insmod mtd-rw i_want_a_brick=1
root@OpenWrt_R6230:/tmp# ubiattach -p /dev/mtd5
UBI device number 1, total 480 LEBs (60948480 bytes, 58.1 MiB), available 0 LEBs (0 bytes), LEB size 126976 bytes (124.0 KiB)
root@OpenWrt_R6230:/tmp# ubimkvol /dev/ubi1 -N database -m
ubimkvol: error!: UBI device does not have free logical eraseblocks

What does this mean and how can I fix this? Thank you all for any help you can give.

And finally my last query for info. This router has more partitions of empty space besides this one block of 60MB.
If you look on https://openwrt.org/toh/netgear/netgear_r6220
you will see that after MTD3 there is nearly 90MB of empty space and unused partitions! And the best part is that they are contiguous. Is there a way to erase all of them and replace them with 1 super partition so I can have all that lost and unused space? That would give me an extra 90MB of space compared to the default OpenWRT firmware,
The only partition I am not sure on is the partition labeled factory thats 1MB in size. I think it has OEM Netgear stuff but I am not positive. I don't mind erasing that if it wont brick me as I will never put this router back to stock firmware. It's going to stay on OpenWRT or at the very least, DD-WRT until it croaks. The factory firmware is as you may expect very stripped down and almost no option available.

But this is auxiliary and my main goal is mounting and using MTD5 for now. Please help!

master https://github.com/openwrt/openwrt/blob/master/target/linux/ramips/dts/mt7621_netgear_r6220.dts
1907 https://github.com/openwrt/openwrt/blob/openwrt-19.07/target/linux/ramips/dts/R6220.dts
here are the current flash partition layouts
it's weird that there are holes in the allocated MTD's as I like to backup all the mtd's of my routers
so this mean I'm not backing up some parts. of flash :frowning:
I have 2 of these & from my backup both the 60M partitions are full of FF's
can't tell what's on the parts allocated as I didn't back them up

I will point out that the 60M partition is read-only in the DTS's

I'm not sure what the criteria on these things are
but most of the area marked as unused & reserved (that are blank)
should be able to be concatenated into usable area
I don't think you could make a factory image the full size only the area until the factory partition
but for sysupgrade & usable space it could be allocated
the factory flashing will have limits maybe this is why 0x2200000 to 0x2e00000 is not allocated
0x2F00000 > 0x4200000 not sure what this is but stated as unused
0x4200000 with 0x3C00000 only goes to 0x7E00000
so 0x7E00000 to 0x7FFFFFF is not allocated

from netgear boot log explains some of it

0x000000000000-0x000000100000 : "Bootloader"
0x000000100000-0x000000200000 : "SC PID"
0x000000200000-0x000000600000 : "Kernel"
0x000000600000-0x000002200000 : "Rootfs"
0x000002200000-0x000002400000 : "English UI"
0x000002400000-0x000002600000 : "ML1"
0x000002600000-0x000002800000 : "ML2"
0x000002800000-0x000002a00000 : "ML3"
0x000002a00000-0x000002c00000 : "ML4"
0x000002c00000-0x000002e00000 : "ML5"
0x000002e00000-0x000002f00000 : "Factory"
0x000002f00000-0x000003000000 : "SC Private Data"
0x000003000000-0x000003200000 : "POT"
0x000003200000-0x000003400000 : "Traffic Meter"
0x000003400000-0x000003600000 : "DPF"
0x000003600000-0x000003800000 : "SC Nvram"
0x000003800000-0x000003a00000 : "Ralink Nvram"
0x000003a00000-0x000003c00000 : "Ralink Reserved"
0x000003c00000-0x000003e00000 : "ML6"
0x000003e00000-0x000004000000 : "Upgrade Flag"
0x000004000000-0x000004200000 : "Reserved Block3"
0x000004200000-0x000007e00000 : "Reserved Block4"

anyone know the limits & reason or policy's around why we can't just concatenate these unused areas ?

Are you able to backup any of the partitions via the gui? I've never been able to. it always errors out for me with "Invalid characters in filename"

nm i figured it out it was making the MTD partitions writable that makes them unable to be backed up via the gui.

you can but i find 19.07 has problems after i have set it up but not just flashed

writable or not read only ?
sounds weird anyway

are you able to compile your own firmware ?
and have you used nmrpflash.exe yet to recover ?

yes and yes although I haven't done any compiling in a few years so I'd be rusty at this point. I dont have any windows computers for nmrpflash.exe though so I use the linux version of nmrpflash but its basically the same thing. Saved my bacon many times. Does anyone know the reason the OpwnWRT TOH for the R6220 cautions not to use nmrpflash with OpenWRT images, only oem firmwares? Ive only ever used nmrpflash with OpenWRT, dont think ive ever flashed a oem firmware with it lol... Never had an issue either...

Yes, I was able to figure out what needed to be done to get the MTD5 to be writable. Now I need to figure out how to merge it with the partition opkg saves stuff to.

I had a go trying to use the fwconcat to concatenate the flash
seemed to boot OK says I had 77M but while initializing it
it keeps killing itself & would not boot up next time

good luck! Do you have a ch341a programmer with sop-8 clip? If not, please consider it! You can get them from amazon for about 10 bucks and then you are literally brick proof. I've used one dozens of times to rescue bad bios flashes, bricked routers, etc. Also made a full backup of my R6230 before going to OpenWRT and also before upgrading to the breed bootloader.

yes I have tho it's easy to do with the nor chips
but there are lots of pins on a NAND
but have not had to recover the boot loader yet
tho I do have it all backed up :slight_smile:

found this i think it;s why concat didn't work
https://bugs.openwrt.org/index.php?do=details&task_id=2097&string=mtd&order=category&sort=desc&order2=severity&sort2=desc

Thanks but I am going to have to give up for now and retire the R6230 as a stupid access point in my garage so my car has good WiFi conn for downloading operating system and map updates. Its not ideal but until I can consolidate the space on the rom I cant use it how I would like to.

this work now what ever problem there was has been fixed
but you do have to go back to netgear firmware 1st
due to the ubi change or at lest i don't know a way around it
gives you 76.6M free space

// SPDX-License-Identifier: GPL-2.0-only

#include "mt7621_netgear_sercomm_ayx.dtsi"

/ {
	compatible = "netgear,r6220", "mediatek,mt7621-soc";
	model = "Netgear R6220";
	
	virtual_flash {
		compatible = "mtd-concat";

		devices = <&fwconcat0 &fwconcat1>;

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

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

&nand {
	status = "okay";

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

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

		partition@100000 {
			label = "SC PID";
			reg = <0x100000 0x100000>;
			read-only;
		};

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

		fwconcat0: partition@600000 {
			label = "fwconcat0";
			reg = <0x600000 0x1c00000>;
		};

		factory: partition@2e00000 {
			label = "factory";
			reg = <0x2e00000 0x100000>;
			read-only;
		};

		fwconcat1: partition@4200000 {
			label = "fwconcat1";
			reg = <0x4200000 0x3de0000>;
		};
	};
};

I dont quite understand that. Are you saying that I need to flash the latest netgear firmware because it makes changes to the file system which increases the partition size for the partition which OpenWRT's package manager uses. Then flash back to OpenWRT and I should have 76.6MB free space for OPKG?

Is that how I am suppose to understand that?

if you just upgrade openwrt will try to use the old ubi partition & fail
I don't know how to get it to reformat this any other way
if you load the factory firmware 1st then openwrt
it will re format's the qbi correctly to the new size

it will add the 60MB partition to the current room
oh any version of netgear firmware

Hello! Can you help me with modifiying dts for WAC104?
Same as r6220

Hi I don't have one so i can't test it or look if there is anything there
but I can change the file for you to test ?
how's the recovery is it that same as with the R6220 ?

do backup all your flash partitions you need to do this to see if there blank anyway
this would most likely need to be flashed as a factory file due to partition charges

mt7621_netgear_wac104.dts

// SPDX-License-Identifier: GPL-2.0-only or MIT

#include "mt7621.dtsi"

#include <dt-bindings/gpio/gpio.h>
#include <dt-bindings/input/input.h>

/ {
	compatible = "netgear,wac104", "mediatek,mt7621-soc";
	model = "Netgear WAC104";

	aliases {
		led-boot = &led_power;
		led-failsafe = &led_power;
		led-running = &led_power;
		led-upgrade = &led_power;
		label-mac-device = &gmac0;
	};

	keys {
		compatible = "gpio-keys";

		wps {
			label = "wps";
			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_WPS_BUTTON>;
		};

		wifi {
			label = "wifi";
			gpios = <&gpio 8 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RFKILL>;
		};

		reset {
			label = "reset";
			gpios = <&gpio 14 GPIO_ACTIVE_LOW>;
			linux,code = <KEY_RESTART>;
		};
	};

	leds {
		compatible = "gpio-leds";

		wps {
			label = "green:wps";
			gpios = <&gpio 13 GPIO_ACTIVE_LOW>;
		};

		led_power: power {
			label = "green:power";
			gpios = <&gpio 18 GPIO_ACTIVE_LOW>;
		};

		wifi {
			label = "green:wifi";
			gpios = <&gpio 16 GPIO_ACTIVE_LOW>;
			linux,default-trigger = "phy0tpt";
		};
	};
	
	virtual_flash {
		compatible = "mtd-concat";

		devices = <&fwconcat0 &fwconcat1>;

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

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

&gmac0 {
	nvmem-cells = <&macaddr_factory_4>;
	nvmem-cell-names = "mac-address";
};

&nand {
	status = "okay";

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

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

		partition@100000 {
			label = "SC PID";
			reg = <0x100000 0x100000>;
			read-only;
		};

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

		fwconcat0: partition@600000 {
			label = "fwconcat0";
			reg = <0x600000 0x1c00000>;
		};

		factory: partition@2e00000 {
			label = "factory";
			reg = <0x2e00000 0x100000>;
			read-only;

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

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

				eeprom_factory_8000: eeprom@8000 {
					reg = <0x8000 0x200>;
				};

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

		fwconcat1: partition@4200000 {
			label = "fwconcat1";
			reg = <0x4200000 0x3c00000>;
		};
	};
};

&pcie {
	status = "okay";
};

&pcie0 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0 0 0 0 0>;
		nvmem-cells = <&eeprom_factory_8000>;
		nvmem-cell-names = "eeprom";
		ieee80211-freq-limit = <5000000 6000000>;
	};
};

&pcie2 {
	wifi@0,0 {
		compatible = "mediatek,mt76";
		reg = <0x0 0 0 0 0>;
		nvmem-cells = <&eeprom_factory_0>;
		nvmem-cell-names = "eeprom";
		ieee80211-freq-limit = <2400000 2500000>;
	};
};

&state_default {
	gpio {
		groups = "uart3", "jtag", "wdt";
		function = "gpio";
	};
};

&gmac1 {
	status = "okay";
	label = "lan4";
	phy-handle = <&ethphy0>;

	nvmem-cells = <&macaddr_factory_4>;
	nvmem-cell-names = "mac-address";
};

&mdio {
	ethphy0: ethernet-phy@0 {
		reg = <0>;
	};
};

&switch0 {
	ports {
		port@1 {
			status = "okay";
			label = "lan3";
		};

		port@2 {
			status = "okay";
			label = "lan2";
		};

		port@3 {
			status = "okay";
			label = "lan1";
		};
	};
};

&xhci {
	status = "disabled";
};

Thank you, ill test it soon