Asus TUF AX4200 support

@daniel , @patrykk

After install my biggest sysupgrade image (more 50 MB) i saw the following:

root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                50.8M     50.8M         0 100% /rom
tmpfs                   243.4M      5.4M    238.1M   2% /tmp
/dev/ubi0_7              12.5M    216.0K     11.7M   2% /overlay
overlayfs:/overlay       12.5M    216.0K     11.7M   2% /
tmpfs                   512.0K         0    512.0K   0% /dev

Only 11 megabytes available))

ubinfo
root@OpenWrt:/# ubinfo /dev/ubi0 -a
ubi0
Volumes count:                           8
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     2016 (255983616 bytes, 244.1 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:  40
Current maximum erase counter value:     9
Minimum input/output unit size:          2048 bytes
Character device major/minor:            249:0
Present volumes:                         0, 1, 2, 3, 4, 5, 6, 7

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        1 LEBs (126976 bytes, 124.0 KiB)
State:       OK
Name:        nvram
Character device major/minor: 249:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        8 LEBs (1015808 bytes, 992.0 KiB)
State:       OK
Name:        Factory
Character device major/minor: 249:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        8 LEBs (1015808 bytes, 992.0 KiB)
State:       OK
Name:        Factory2
Character device major/minor: 249:3
-----------------------------------
Volume ID:   3 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        30 LEBs (3809280 bytes, 3.6 MiB)
State:       OK
Name:        linux
Character device major/minor: 249:4
-----------------------------------
Volume ID:   4 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        578 LEBs (73392128 bytes, 69.9 MiB)
State:       OK
Name:        linux2
Character device major/minor: 249:5
-----------------------------------
Volume ID:   5 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        799 LEBs (101453824 bytes, 96.7 MiB)
State:       OK
Name:        jffs2
Character device major/minor: 249:6
-----------------------------------
Volume ID:   6 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        418 LEBs (53075968 bytes, 50.6 MiB)
State:       OK
Name:        rootfs
Character device major/minor: 249:7
-----------------------------------
Volume ID:   7 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        128 LEBs (16252928 bytes, 15.5 MiB)
State:       OK
Name:        rootfs_data
Character device major/minor: 249:8

It seems to me that the file system should be pre-prepared.
Something similar has already been done for Xiaomi routers:

1 Like

then you should have ~50MB available post install using a vanilla openwrt image, what's the problem ?

As a developer, this doesn't matter to me.
But many users will soon notice this and will ask why they have volume jffs2 on flash memory, which takes up 90 MiB.

1 Like

(don't own the device, just guessing ... )

openwrt avoids modifying the flash layout, if the volume was there when the Asus fw was used, then it'll usually remain post openwrt install.

So this volume (and others) are deleted when returning to stock:

I ran the following commands in the console:

ubirename /dev/ubi0 rootfs_data rootfs__d
ubirename /dev/ubi0 jffs2 rootfs_data
reboot

After reboot I saw:

root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                50.8M     50.8M         0 100% /rom
tmpfs                   243.4M      4.8M    238.7M   2% /tmp
/dev/ubi0_5              87.6M    284.0K     87.3M   0% /overlay
overlayfs:/overlay       87.6M    284.0K     87.3M   0% /
tmpfs                   512.0K         0    512.0K   0% /dev

Everything turned out to be quite simple.


The bootloader was not happy about this and created a new volume jffs2:

UBI:        4            242          1         0   dynamic            1f000       242     45fe000         1f000          0           0         6  linux2
UBI:        5            31f          1         0   dynamic            1f000       31f     60c1000         1f000          0           0         b  rootfs_data
UBI:        6            1a2          1         0   dynamic            1f000       1a2     329e000         1f000          0           0         6  rootfs
UBI:        7             80          1         0   dynamic            1f000        80      f80000         1f000          0           0         9  rootfs__d
UBI: 7fffefff              2          1         0   dynamic            1f000         2       3e000             2          0           0         d  layout volume
UBI volume [linux] size 3a2000 smaller than 45fe000!
No size specified -> Using max size (0x3e000)
Creating dynamic volume jffs2 of size 0x3e000
ubinfo
root@OpenWrt:/# ubinfo /dev/ubi0 -a
ubi0
Volumes count:                           9
Logical eraseblock size:                 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks:     2016 (255983616 bytes, 244.1 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:  38
Current maximum erase counter value:     9
Minimum input/output unit size:          2048 bytes
Character device major/minor:            249:0
Present volumes:                         0, 1, 2, 3, 4, 5, 6, 7, 8

Volume ID:   0 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        1 LEBs (126976 bytes, 124.0 KiB)
State:       OK
Name:        nvram
Character device major/minor: 249:1
-----------------------------------
Volume ID:   1 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        8 LEBs (1015808 bytes, 992.0 KiB)
State:       OK
Name:        Factory
Character device major/minor: 249:2
-----------------------------------
Volume ID:   2 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        8 LEBs (1015808 bytes, 992.0 KiB)
State:       OK
Name:        Factory2
Character device major/minor: 249:3
-----------------------------------
Volume ID:   3 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        30 LEBs (3809280 bytes, 3.6 MiB)
State:       OK
Name:        linux
Character device major/minor: 249:4
-----------------------------------
Volume ID:   4 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        578 LEBs (73392128 bytes, 69.9 MiB)
State:       OK
Name:        linux2
Character device major/minor: 249:5
-----------------------------------
Volume ID:   5 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        799 LEBs (101453824 bytes, 96.7 MiB)
State:       OK
Name:        rootfs_data
Character device major/minor: 249:6
-----------------------------------
Volume ID:   6 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        418 LEBs (53075968 bytes, 50.6 MiB)
State:       OK
Name:        rootfs
Character device major/minor: 249:7
-----------------------------------
Volume ID:   7 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        128 LEBs (16252928 bytes, 15.5 MiB)
State:       OK
Name:        rootfs__d
Character device major/minor: 249:8
-----------------------------------
Volume ID:   8 (on ubi0)
Type:        dynamic
Alignment:   1
Size:        2 LEBs (253952 bytes, 248.0 KiB)
State:       OK
Name:        jffs2
Character device major/minor: 249:9
1 Like

asus has 128mb of flash i think, it must keep a partition of its firmware, i know that with the rt3200 ubi i had quite a lot of space to install packages in software

The Xiaomi AX6000 got ~120MB, with uboot-mod, but 50MB ain't bad.

1 Like

Tell me, plz, how many free flash I will get after complete basic OpenWRT 23.05 installation? The router has 256M flash, so I hope to have at least 170-180M of flash free. Am I wrong?

Scroll back 3 posts ?

1 Like

70 MB (linux) - 4 MB (kernel) - 8 MB (rootfs) = 58 MB free space

I'm currently working on increasing the available space.
It is very strange that the OpenWRT maintainer @blocktrron did not immediately attend to this point...

Where is all other flash space :woozy_face: ? Are there any hope to recover it?

I just tried using OpenWRT LUCI (WEB) to install initramfs image (not trx) on the linux volume (forced mode). And the image was successfully flashed and started successfully.
And in initramfs-mode we can do whatever we want with ubi volumes.
This is how you can return to stock firmware.

I also need to publish this initramfs image....


Restoring the stock AsusWRT from initramfs-mode:

ubirmvol /dev/ubi0 -N rootfs
ubirmvol /dev/ubi0 -N rootfs_data
ubirmvol /dev/ubi0 -N jffs2
ubirmvol /dev/ubi0 -N linux
ubimkvol /dev/ubi0 -N linux -s 0x45fe000
dd if=/tmp/tufax4200.trx bs=64 skip=1 > /tmp/tufax4200.fit
linux_num=$( ubinfo -d 0 -N linux | awk 'NR==1 {print $3}' )
ubiupdatevol /dev/ubi0_$linux_num /tmp/tufax4200.fit
reboot
2 Likes

I have already fixed this in my OpenWRT repository:

As a result of these changes, free space increases by 90 MB.

Tomorrow I will also add the ability revert to stock firmware via the LuCI WEB interface...

3 Likes

thanks i will stay tomorrow so

very good work of your part

just one question before firmware version doesn't matter? for openwrt flash

3.0.0.4.388_31244

hi remittor , I've just seen that you added the commit a little while ago to go back to stock firmware,

If I understand correctly, I'll flash your new image here to be sure.

1 Like

Installiation OpenWrt image:

  1. Download TRX-image openwrt-23_tuf-ax4200-initramfs.trx and install its via WEB-interface AsusWRT.
    Change computer IP-addr to 192.168.1.10 and wait 60...90 seconds.
  2. Download OpenWRT sysupgrade image openwrt-mediatek-filogic-asus_tuf-ax4200-squashfs-sysupgrade.bin (or download the sysupgrade image from another location) and install its via WEB-interface OpenWRT.
    Wait for the system to restart for 60...120 seconds.

Revert to stock AsusWRT:

  1. Install package facinstall.
  2. Install Asus stock TRX-image via OpenWRT LuCI interface.
    Change computer IP-addr to 192.168.50.10 and wait 70...120 seconds.

All the files listed above can be downloaded from here: my google drive


My sysupgrade image is very large because there are a lot of huge applications there: Samba, btrfs, nextdns, etc.

14 Likes

thanks for explanation first inittramfs.trx via asus i wait the flash 90 sec

and if never i will revert to asus i put inittramfs.bin

2 Likes

Please excuse me, this might be a dumb question, but will the factory wifi calibration be kept after whole this process? I’m not sure I understand all of that correctly, but during a similar process, I damaged Linksys WRT1900AC wifi calibration (I think it’s called DST).

all is good :pray: :stuck_out_tongue: :slight_smile:

2 Likes