Add support for D-Link M30 (AQUILA PRO AI AX3000 Smart Mesh Router)

But this would affect users trying to recover their bricked devices running OEM software as well?

I just ordered an M60 for € 185 by the way, so I have something to play with for the weekend :slightly_smiling_face:

Yes, if they create recovery images, for example with the scripts from the OpenWrt wiki. There are no official recovery images, it’s always an unpacked OEM image.

1 Like

Can we simply make own u-boot with custom pattition scheme like in others filogic devices?

What is the goal of the custom partition scheme? If you want to increase the available space for packages, it might also work to merge the partitions ubi and ubi1 to get 50M extra space in flash.
I did not yet try it out on the M30 but some time ago I did something similar with the M32/R32.

Yes, same like xiaomi ax3000t scheme, u-boot, recovery and rootfs. Or maybe i'll stay with ax3000t since it's rock solid.

Recently I tried to merge the partitions in the following way:

  • create recovery image (to be flashed with OEM recovery) with initramfs so that it doesn't try to mount ubi0
  • sysupgrade to "full" OpenWRT with ubi and ubi1 merged

It worked, but only on first boot. Then, on next boot u-boot was looking for 50 MB ubi volume, did not find it went straight into recovery. There may have been something I was missing:

On the other hand, I think if we include initramfs kernel in the recovery image, this can solve issues if the second partition is active: initramfs can boot from either, then on sysupgrade to full system it can set required u-boot env values and OpenWRT will work normally:

Was there any change in the u-boot-env (The U-Boot variables)?

The only difference between successful (first) and failed (second) boot is sw_tryactive (0 on first, 2 on second).

On first successful boot, due to sw_tryactive=0 it runs boot_by_tractive and finds ubi0 with no issues:

  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
Saving Environment to MTD... Erasing on MTD device 'nmbm0'... OK
Writing to MTD device 'nmbm0'... OK
OK
ubi_boot_image:569 ubi
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0: attached mtd6 (name "ubi", size 100 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 800, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 4/2, WL threshold: 4096, image sequence number: 496222874
ubi0: available PEBs: 2, total reserved PEBs: 798, PEBs reserved for bad PEB handling: 19
Reading from volume 'kernel' to 0x46000000, size 0x0 ... OK

On a second boot, it first starts aup, that tries to do something with nmbm0, maybe this is where it damages the new partition layout?

  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
aup_command::do multicast-upgrade checking
aup_start
start load_p_section
Reading from 0x0 to 0x5ffabd68, size 0x10 ... OK
load_section: start p mode
Reading from 0x0 to 0x5ffabd68, size 0x14d3 ... OK
load_section: found csxf tag
csxf->magic: 5343
csxf->checksum: c811
csxf->body_length: 000014b3
csxf->body_encoding: 00
csxf->raw_length: 000014b3
check p section: ok
load P section success
 romid: (DLK6E6110004)
 sys info PV 01
 model name: (M30/CP)
 ecn no: (200909100001)
 beid rule: 190A
 beid mac: ***redacted***
 default ip: 192:168:200:1
aup_start Using ethernet@15100000 device
mcast upgrade timeout.
"nmbm0" partitions still in use, can't delete them
ubi_boot_image:569 ubi
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0 error: ubi_read_volume_table: the layout volume was not found
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd6, error -22
UBI error: cannot attach mtd6
UBI error: cannot initialize UBI, error -22
*** Failed to attach UBI ***
*** Rebuilding UBI ***

Tomorrow I'll try with mupgrade_en = 0 to see if skipping aup helps. :slight_smile:

It works! If mupgrade_en is set to 0, u-boot no longer reverts partition layout and OpenWRT can boot normally, using ubi0+ubi1 as single partition with gross capacity of 100 MiB. :slight_smile:

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 24.10-SNAPSHOT, r28664-cb21ad2848
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 4.5M      4.5M         0 100% /rom
tmpfs                   242.9M    352.0K    242.6M   0% /tmp
/dev/ubi0_2              76.8M     44.0K     72.8M   0% /overlay
overlayfs:/overlay       76.8M     44.0K     72.8M   0% /
tmpfs                   512.0K         0    512.0K   0% /dev
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:     800 (101580800 bytes, 96.8 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:  19
Current maximum erase counter value:     4
Minimum input/output unit size:          2048 bytes
Character device major/minor:            249:0
Present volumes:                         0, 1, 2

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        33 LEBs (4190208 bytes, 3.9 MiB)
State:       OK
Name:        kernel
Character device major/minor: 249:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        38 LEBs (4825088 bytes, 4.6 MiB)
State:       OK
Name:        rootfs
Character device major/minor: 249:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        704 LEBs (89391104 bytes, 85.2 MiB)
State:       OK
Name:        rootfs_data
Character device major/minor: 249:3

Here are the commits - I also added M30/CP variant support as this is what I'm using: