Hi! I have purchased ZTE MF286D 4G router hoping to have sufficient internal storage of around 128MiB on its NAND chip (as per specs on openwrt official site). However after installing sysupgrade I have discovered that only around 14MiB is available((( I understand that some of the NAND memory need to be reserved for U-boot and OpenWRT files, but, obviously most of the NAND memory is left unused. Needless to say that I purchased the router for use with OpenWRT and not planning to come back to stock firmware. Is there a way to utilize the unused NAND memory?
create your own custom firmware, with the NAND repartitioned.
or put a flash drive in the USB port, and https://openwrt.org/docs/guide-user/additional-software/extroot_configuration.
I am familiar with the Extroot approach, but in this particular case, since the device has only USB2 and sufficient NAND chip I guess the only other option is to create custom image. Is there a guide which I can start from addressing NAND repatitioning issue when building custom firmware? I have no knowledge on filesystems, NAND memory, where U-boot or other files may be stored and if they are needed by openwrt core (eg. modem drivers, IMEI, MACs and so on)
perhaps check if https://openwrt.org/toh/zte/mf286d#flash_layout is correct ?
and which partitions are perhaps unsused ?
you could then apply extroot to one of those, or if they are next to each other, combine them.
whatever you do, backup everything 1st.
There is a huge chunk space in NAND (0x000004e00000-0x000008000000 : "fota"), roughly 50 MB, would it be fair to assume that it can be added to usable storage? what sort of data oem may label "fota" from your experience? can it have some data what openwrt may use? can it be utilized providing I have no plans to go back to stock fw?
My guess is, it's the staging area for the LTE modem, when it does firwmare upgrades, but I'm only guessing.
@Leo-PL would you know ?
Negative. Due to kernel being in UBI, we can't expand the existing UBI volume besides where U-boot knows it resides.
FOTA is temporary writable partition used for stock firmware updates. It can be re-used in theory, but probably we would have to either create a separate UBI volume for it only and use that as rootfs_data, or modify U-boot as well to expand the existing one.
Most OpenWrt packages are pretty small and what is stored on /overlay is compressed so 14MiB is the minimum that can be stored but often a lot more can fit. This is enough space to fit a decent number of additional packages.
Packages that store information - like ad blocking lists - can have the data moved to USB without much difficulty leaving /overlay for just the added/updated packages themselves without having to mess with extroot.
Before you put in a lot of effort to get more space - find out if you actually need it. Keeping with the defaults means easier upgrades and less chance of messing things up.
so, modifying qcom-ipq4019-mf286d.dts file from:
partition@3500000 {
label = "data";
reg = <0x3500000 0x1900000>;
};
partition@4e00000 {
label = "fota";
reg = <0x4e00000 0x3200000>;
};
to:
partition@3500000 {
label = "data";
reg = <0x3500000 0x0x4B00000>; // ~75MB = original 25 + 50 from fota
};
compiling and upgrading to new image won't work?
I guess 14MiB for most applications is really more then enough, but I need at least sing-box (10Mib) and dnscrypt-proxy2 (4MiB). Other packages such as Samba4 would also be nice to run of internal storage. Once again, this issue can easily be solved with Extroot, but since the router has sufficient NAND chip on board, it would be nice to use the most of it. If it is at all possible, of cause.
use fota for extroot then ?
you get the space you need, and no custom firmware required ?
two birds one stone.
Obviously, there is a mistake, the correct values should be as follows:
partition@3500000 {
label = "data";
reg = <0x3500000 0x4B00000>; // ~75MB = original 25 + 50 from fota
};
@Leo-PL, does your "Like" to the above post mean that I am on the right track or it means that I really should not do this as in will definitelly brick my router?
It sounds like a safe option, if not the only one! Is there a guide or discussion on how NAND partition can be prepared and used as extroot? I have tryed sollution offered by ChatGPT, but it did not create an extroot((
https://openwrt.org/docs/guide-user/additional-software/extroot_configuration should contain all the info you need.
I have used this article a few times when installing extroot to USB Flash drive. However it has no information on preparing extra partition on NAND flash. Around 50MiB of FOTA are not shown in output of this command ubinfo -a. I am guessing this extra partition should be created/formatted and somehow attached to the system as accessible device, as /dev/sda in case with USB Drive. But, I have no idea how to do that. Any advice or refferences?
I took my chances, applied changes to DTS file, compiled and updated firmware!
Good news: I didn't brick my router!
Bad news: only 14.52MiB is still in /overlay.
output of cat /proc/mtd now is:
dev: size erasesize name
mtd0: 000a0000 00020000 "fota-flag"
mtd1: 00080000 00020000 "ART"
mtd2: 00080000 00020000 "mac"
mtd3: 000c0000 00020000 "reserved2"
mtd4: 00400000 00020000 "cfg-param"
mtd5: 00400000 00020000 "log"
mtd6: 000a0000 00020000 "oops"
mtd7: 00500000 00020000 "reserved3"
mtd8: 00800000 00020000 "web"
mtd9: 01d00000 00020000 "rootfs"
mtd10: 04b00000 00020000 "data"
mtd11: 00040000 00010000 "0:SBL1"
mtd12: 00020000 00010000 "0:MIBIB"
mtd13: 00060000 00010000 "0:QSEE"
mtd14: 00010000 00010000 "0:CDT"
mtd15: 00010000 00010000 "0:DDRPARAMS"
mtd16: 00010000 00010000 "0:APPSBLENV"
mtd17: 000c0000 00010000 "0:APPSBL"
mtd18: 00050000 00010000 "0:reserved1"
mtd11 "fota" is gone and size of "data" now is 04b00000HEX, which is desired 75MiB, I am guessing some other files may need to be edited, which set UBI structure, at the moment it is (same as before):
root@OpenWrt:~# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:127
Present UBI devices: ubi0
ubi0
Volumes count: 3
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 232 (29458432 bytes, 28.0 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 4
Minimum input/output unit size: 2048 bytes
Character device major/minor: 245:0
Present volumes: 0, 1, 2
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 27 LEBs (3428352 bytes, 3.2 MiB)
State: OK
Name: kernel
Character device major/minor: 245:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 34 LEBs (4317184 bytes, 4.1 MiB)
State: OK
Name: rootfs
Character device major/minor: 245:2
-----------------------------------
Volume ID: 2 (on ubi0)
Type: dynamic
Alignment: 1
Size: 147 LEBs (18665472 bytes, 17.8 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 245:3
@frollic , @Leo-PL , your thoughts on this will be highly appreciated.
ubitools ?
ubidelvol (rmvol?) and ubimkvol ...
You didn't yet reformat UBI partition to the remaining blocks, and at that moment, or during the next update would be the point in which you would brick it, because kernel data would land after the boundary U-boot knows for UBI volume.
So, i reverted back to the official 24.10.2 release, so as before I have:
root@OpenWrt:~# cat /proc/mtd
...
mtd8: 00800000 00020000 "web"
mtd9: 01d00000 00020000 "rootfs"
mtd10: 01900000 00020000 "data"
mtd11: 03200000 00020000 "fota"
mtd12: 00040000 00010000 "0:SBL1"
...
I suppose that openwrt and overlay resides in mtd9:
root@OpenWrt:~# ubinfo -a
UBI version: 1
Count of UBI devices: 2
UBI control device major/minor: 10:127
Present UBI devices: ubi0, ubi1
ubi0
Volumes count: 3
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 232 (29458432 bytes, 28.0 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 20
Current maximum erase counter value: 6
Minimum input/output unit size: 2048 bytes
Character device major/minor: 245:0
Present volumes: 0, 1, 2
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 27 LEBs (3428352 bytes, 3.2 MiB)
State: OK
Name: kernel
Character device major/minor: 245:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 34 LEBs (4317184 bytes, 4.1 MiB)
State: OK
Name: rootfs
Character device major/minor: 245:2
-----------------------------------
Volume ID: 2 (on ubi0)
Type: dynamic
Alignment: 1
Size: 147 LEBs (18665472 bytes, 17.8 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 245:3
hence, I should be able to create extroot in mtd10("data", 25MiB) or mtd11("fota", 50MiB). Ideally, if merged it could get 25+50=75MiB, which should be more then enough for most of my purposes.
Next reasonable option is to use only mtd11 with 50MiB of total space, however when I try to format is for ubi I get all bad erase blocks:
root@OpenWrt:~# ubiformat /dev/mtd11
ubiformat: mtd11 (nand), size 52428800 bytes (50.0 MiB), 400 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 399 -- 100 % complete
ubiformat: 2 eraseblocks have valid erase counter, mean value is 2
ubiformat: 398 bad eraseblocks found, numbers: 0, 1, 2, 3,..., 396, 397, 398, 399
ubiformat: formatting eraseblock 399 -- 100 % complete
while mtd10(data) formats just fine:
root@OpenWrt:~# ubiformat /dev/mtd10
ubiformat: mtd10 (nand), size 26214400 bytes (25.0 MiB), 200 eraseblocks of 131072 bytes (128.0 KiB), min. I/O size 2048 bytes
libscan: scanning eraseblock 199 -- 100 % complete
ubiformat: 200 eraseblocks have valid erase counter, mean value is 1
ubiformat: formatting eraseblock 199 -- 100 % complete
- What could be wrong with mtd11() and is anything can be done about it?
- Can mtd10 and mtd11 be merged to get a total of 75Mib for extroot on official sysupgrade image? if not, what approach should I take otherwise?
Are you saying the MTD block needs to be reformatted? Is it possible to do this while OpenWrt is already using it? Or would simply creating another UBI volume to utilize the available space in the MTD be enough?