Adding OpenWrt support for Asus RT-AC57U v2

CPU data:

admin@RT-AC57U_V2:/tmp/home/root# cat /proc/cpuinfo
system type             : Qualcomm Atheros QCA5502 ver 1 rev 0
machine                 : ASUS RT-AC59U
processor               : 0
cpu model               : MIPS 74Kc V5.0
BogoMIPS                : 385.84
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes, count: 4, address/irw mask: [0x0ffc, 0x0ffc, 0x0ffb, 0x0ffb]
isa                     : mips1 mips2 mips32r1 mips32r2
ASEs implemented        : mips16 dsp dsp2
shadow register sets    : 1
kscratch registers      : 0
package                 : 0
core                    : 0
VCED exceptions         : not available
VCEI exceptions         : not available

admin@RT-AC57U_V2:/tmp/home/root# uname -a
Linux RT-AC57U_V2 4.4.60 #1 Wed Jan 6 15:07:10 CST 2021 mips GNU/Linux

Comparing with the other forum thread (Add support for Asus RT-AC57U_V2) cpu is sligtly different.

"Qualcomm Atheros QCA5502 rev 0" VS "Qualcomm Atheros QCA5502 ver 1 rev 0"

Sligtly different capabilities:
isa : mips1 mips2 mips32r1 mips32r2
ASEs implemented : mips16 dsp dsp2

VS
ASEs implemented : mips16 dsp

I think it is not a big deal, and the two device is identical.

I upgraded to the newest Asus firmware (3.0.0.4.382_52482), what use 4.4.60 kernel.

Thanks for your research. Didn't know they updated the kernel. It would have been nice if they also published the sources for it. The latest source release as of now is 3.0.0.4.382.52274 which is based on kernel 3.3.8 (according to top-level kernel Makefile). Any chance you remember what version of the kernel was reported by uname in previous firmware releases? I would like to make sure they didn't just leave the old version numbers.

1 Like

"Any chance you remember what version of the kernel was reported by uname in previous firmware releases?"

When I updated firmware have not interested in openWRT router firmware. So I did not use ssh.

I would not downgrade firmware, because I use the router.

Older firmwares can be downloaded here:

I'm a beginer in that field, so my next idea may be strange.

The openwrt-19-07-8 relase (OpenWrt 19.07.8 service release) use Linux kernel 4.14.241.
The newest Asus firmware use 4.4.60 kernel. Without kernel building, could we make openwrt-19-07-8 firmware image?
Or simpli we install openwrt by ssh?

No. Please read the following information from the wiki.

tl;dr: In order to install an OS on a device you need to patch the kernel so that it has all the drivers required to boot and run the OS on this specific device. Neither the mainline linux kernel nor OpenWrt project have patches for the hardware used on this device.

Our work therefore looks like this:

  1. Figure out which parts of code provided by ASUS are needed for this particular SoC;
  2. Port these patches to mainline kernel;
  3. Backport them to current kernel version used by OpenWrt if needed;
  4. Build OpenWrt image with patches from (3) and test it;
  5. Submit (2) and (3) to the community and work towards having them integrated into mainline.
1 Like

First I search for leds.

The router has 9 leds:
Power
Port4
Port3
Port2
Port1
Wan
2.4Ghz Wifi
5 Ghz Wifi
Usb

GPIO directory there is 9 files.

admin@RT-AC57U_V2:/sys/class/gpio# ls
export gpio1 gpio15 gpio16 gpio17 gpio4 gpio5 gpiochip0 unexport

It may be coincidence, but I dont think so. :slight_smile:

1 Like

Reading values:

admin@RT-AC57U_V2:/tmp/home/root# cd /sys/class/gpio
admin@RT-AC57U_V2:/sys/class/gpio# cat ./gpio1/value
1
admin@RT-AC57U_V2:/sys/class/gpio# cat ./gpio15/value
0
admin@RT-AC57U_V2:/sys/class/gpio# cat ./gpio17/value
1
admin@RT-AC57U_V2:/sys/class/gpio# cat ./gpio4/value
1
admin@RT-AC57U_V2:/sys/class/gpio# cat ./gpio5/value
0
admin@RT-AC57U_V2:/sys/class/gpio#

I created an basic OpenWRT Device Page for router:

I still would be happy if we doen not need to create new platform. :wink:
It is hard.

The ath79 platform conatains NETGEAR EX7300.
NETGEAR EX7300 uses Qualcomm Atheros QCN5502 cpu.
I think our plarform will be ath79 too.

I downloaded the source. https://dlcdnets.asus.com/pub/ASUS/wireless/RT-AC57U_V2/GPL_RT_AC57U_V2_300438252107.zip

It contains a file README.TXT. It is build manual for different routers, but it not contains RT-AC57U_V2, nor Qualcomm Atheros QCA5502.

A bit confusing. :slight_smile:

1 Like

Yes we will use the existing ath79 arch. But! Every single SoC (sometimes even specific board!) needs a little bit of code specific to this SoC / board.

However, your information regarding NETGEAR EX7300 (v2 to be precise) is very interesting. This board is indeed based on QCN5502 and the openwrt wiki page says that there's a pending PR for it. Not sure what "pending" means here and where it exists if there is one. Waiting for the page author's reply regarding this.

1 Like

As for building the official ASUS sources, see my instructions above in this thread.

1 Like

I have created a public git repository. Relevant tasks will be created as "issues". Make sure to read the project's main wiki page to understand which branch contains what. There's nothing of interest there at the moment - just mainline kernel code and code from ASUS firmware. I will be creating issues in the next few days. Anyone is welcome to read / comment / open merge requests / etc.

@Hsxsky here's my router's info as you requested (without dmesg since the forum doesn't allow very long messages):

/proc/cmdline
 board=APJET01 console=ttyS0,115200 root=/dev/mtdblock4 rootfstype=squashfs mem=128M
/proc/cpuinfo
system type		: Qualcomm Atheros QCA5502 rev 0
machine			: Qualcomm Atheros APJET01 reference board
processor		: 0
cpu model		: MIPS 74Kc V5.0
BogoMIPS		: 385.84
wait instruction	: yes
microsecond timers	: yes
tlb_entries		: 32
extra interrupt vector	: yes
hardware watchpoint	: yes, count: 4, address/irw mask: [0x0000, 0x0ff8, 0x0ff8, 0x0ff8]
ASEs implemented	: mips16 dsp
shadow register sets	: 1
kscratch registers	: 0
core			: 0
VCED exceptions		: not available
VCEI exceptions		: not available

/proc/meminfo
MemTotal:         125848 kB
MemFree:           45256 kB
Buffers:            8128 kB
Cached:            21792 kB
SwapCached:            0 kB
Active:            25348 kB
Inactive:          14700 kB
Active(anon):      10300 kB
Inactive(anon):      112 kB
Active(file):      15048 kB
Inactive(file):    14588 kB
Unevictable:           0 kB
Mlocked:               0 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                 0 kB
Writeback:             0 kB
AnonPages:         10144 kB
Mapped:             3988 kB
Shmem:               284 kB
Slab:              20548 kB
SReclaimable:       1576 kB
SUnreclaim:        18972 kB
KernelStack:         480 kB
PageTables:          512 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       62924 kB
Committed_AS:      17768 kB
VmallocTotal:    1048372 kB
VmallocUsed:         828 kB
VmallocChunk:    1016188 kB
/proc/devices
Character devices:
  1 mem
  2 pty
  3 ttyp
  4 ttyS
  5 /dev/tty
  5 /dev/console
  5 /dev/ptmx
 10 misc
 13 input
 21 sg
 90 mtd
108 ppp
128 ptm
136 pts
180 usb
189 usb_device
228 nvram
252 sfe_ipv6
253 sfe_ipv4
254 bled

Block devices:
  1 ramdisk
259 blkext
  8 sd
 31 mtdblock
 65 sd
 66 sd
 67 sd
 68 sd
 69 sd
 70 sd
 71 sd
128 sd
129 sd
130 sd
131 sd
132 sd
133 sd
134 sd
135 sd
ls /sys/devices/platform
ag71xx-mdio.0
ag71xx.0
alarmtimer
ar724x-pci.0
ath79-spi
ath79-wdt
ehci-platform.0
qcn550x_wmac
serial8250
serial8250.0
uevent
/proc/mtd
dev:    size   erasesize  name
mtd0: 00040000 00010000 "Bootloader"
mtd1: 00010000 00010000 "nvram"
mtd2: 00010000 00010000 "Factory"
mtd3: 00f20000 00010000 "linux"
mtd4: 00de5480 00010000 "rootfs"
mtd5: 00080000 00010000 "jffs2"
mtd6: 01000000 00010000 "ALL"
ifconfig -a
ath0       Link encap:Ethernet  HWaddr A8:5E:45:47:D7:F8  
           UP BROADCAST RUNNING  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:544 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

ath1       Link encap:Ethernet  HWaddr A8:5E:45:47:D7:FC  
           UP BROADCAST RUNNING  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:418 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:0 (0.0 B)  TX bytes:95162 (92.9 KiB)

br0        Link encap:Ethernet  HWaddr A8:5E:45:47:D7:F8  
           inet addr:192.168.50.1  Bcast:192.168.50.255  Mask:255.255.255.0
           UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
           RX packets:27270 errors:0 dropped:0 overruns:0 frame:0
           TX packets:32280 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:1887245 (1.7 MiB)  TX bytes:19254896 (18.3 MiB)

eth0       Link encap:Ethernet  HWaddr A8:5E:45:47:D7:F8  
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:27292 errors:0 dropped:0 overruns:0 frame:0
           TX packets:32804 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000 
           RX bytes:2379821 (2.2 MiB)  TX bytes:19440330 (18.5 MiB)
           Interrupt:4 

imq0       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq1       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq2       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq3       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq4       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq5       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq6       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

imq7       Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  
           NOARP  MTU:16000  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:11000 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo         Link encap:Local Loopback  
           inet addr:127.0.0.1  Mask:255.0.0.0
           UP LOOPBACK RUNNING MULTICAST  MTU:16436  Metric:1
           RX packets:37 errors:0 dropped:0 overruns:0 frame:0
           TX packets:37 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:2344 (2.2 KiB)  TX bytes:2344 (2.2 KiB)

vlan1      Link encap:Ethernet  HWaddr A8:5E:45:47:D7:F8  
           UP BROADCAST RUNNING ALLMULTI MULTICAST  MTU:1500  Metric:1
           RX packets:27292 errors:0 dropped:0 overruns:0 frame:0
           TX packets:32711 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:1888565 (1.8 MiB)  TX bytes:19277308 (18.3 MiB)

vlan2      Link encap:Ethernet  HWaddr A8:5E:45:47:D7:F8  
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:93 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0 
           RX bytes:0 (0.0 B)  TX bytes:31806 (31.0 KiB)

wifi0      Link encap:UNSPEC  HWaddr A8-5E-45-47-D7-F8-00-41-00-00-00-00-00-00-00-00  
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:17629 errors:0 dropped:0 overruns:0 frame:0
           TX packets:5327 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:2699 
           RX bytes:4715844 (4.4 MiB)  TX bytes:1304679 (1.2 MiB)
           Interrupt:47 Memory:b8100000-b8120000 

wifi1      Link encap:UNSPEC  HWaddr A8-5E-45-47-D7-FC-00-41-00-00-00-00-00-00-00-00  
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:0 errors:0 dropped:0 overruns:0 frame:0
           TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:2699 
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
           Interrupt:40 

ls /sys/class/net
ath0
ath1
br0
eth0
imq0
imq1
imq2
imq3
imq4
imq5
imq6
imq7
lo
vlan1
vlan2
wifi0
wifi1
brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.a85e4547d7f8	yes		vlan1
							ath0
							ath1
/sys/kernel/debug/gpio
GPIOs 0-19, ath79:
 gpio-1   (sysfs               ) in  hi
 gpio-4   (sysfs               ) out hi
 gpio-5   (sysfs               ) out lo
 gpio-15  (sysfs               ) out lo
 gpio-16  (sysfs               ) out lo
 gpio-17  (sysfs               ) in  hi
1 Like

I have compared data. CPU is slightly different, and the ls /sys/devices/platform is totally different. Maybe different version of firmware. As I see, other parameters are same.

Please check "/tmp/home/root# uname -a" too.

As i see platform/target will be ath79
Subtarget: generic
Package architecture: mipsel_74kc or mips_24kc

Hardware:
Switch: Atheros AR8337 rev. 2
9 similar device: https://openwrt.org/toh/views/toh_extended_all?dataflt[Switch*~]=AR8337

WLAN 2.4GHz: Qualcomm Atheros 5500
0 similar device: https://openwrt.org/toh/views/toh_extended_all?dataflt[WLAN+Hardware*~]=5500
(Binary driver may extract from the firmrware. It may be a bottleneck.)

WLAN 5.0GHz QCA9888:
13 similar device: https://openwrt.org/toh/views/toh_extended_all?dataflt[WLAN+Hardware*~]=QCA9888

Summary of the past week.

  • I tried to figure out what parts of ASUS patches are required for the SoC to work. I tried removing things that seemed unnecessary, but this approach quickly made my device not boot.
  • I found a less error-prone way to remove irrelevant patches: by removing patches to files that aren't mentioned in the kernel compilation log. I tested the resulting image and it works fine.
  • Apparently there is a small patch that needs to be added for RT-AC59U v2, RT-AC57U v3, RT-AC58U v3 boards (they are identical). These are similar to the board discussed in this thread except with more flash memory.
  • Found out that there's a PR here which adds support for one QCN5502-based board. The patch is quite small.

Plans:

  • fix branches in my repository
  • there's code for boards that use device tree - investigate if it can be used for our board
  • remove patches for all the files that are not being compiled
  • finish writing device tree for the router
  • solder header pins to get access to UART

In order to use ASUS TFTP recovery without ASUS program for windows:

  • set a static IP to 192.168.1.10/24
  • turn off the device
  • hold and don't release the reset button
  • turn on the device while holding the reset button
  • wait until power LED is slowly blinking
  • release the reset button
  • send new image with atftp --put -l /path/to/image.trx 192.168.1.1 69
1 Like

Good news, everyone!

With the help of other developers, I've been able to build an OpenWrt image for my RT-AC57U v2. Switch and wireless don't work yet, but the CPU runs OpenWrt just fine. I have created a repository which is a mirror of OpenWrt with my patches in apjet01 branch. Choose Qualcomm Atheros APJET01 (16M) in Target Profile. Once you flash the image your device will loose connectivity and the only way to access it is by soldering a pin header to UART and using TTL-USB adapter. Only use this image if you have access to UART! You can return to stock firmware at any time via TFTP recovery though.

The device is not really useful at this point, but we've got so much closer...

3 Likes

Good news once again!

All 5 ports are now working correctly. We've had support for LAN ports for a while in my repository, but I wanted to have the switch part finished before saying anything. Apparently there are more than 1 phy. There is phy at register 4 which I was using, but WAN port didn't work and it crashed when using VLANs (required to tell WAN from LAN) so it had limited functionality. Then recently @merlin discovered there's also a phy at register 0 which makes everything work if you provide PORT0_STATUS in qca,ar8327-initvals. Most recent commit fixes that. There is no distinction between LAN and WAN at the moment, I will fix this soon. USB support by @merlin is also on the way!

Note that this is my 3rd consecutive message so I will have to modify it instead of writing new ones.

1 Like

Dear Alex,

Thanks your work.

Hi,
Thanks for your work.
Any ETA on when do you think we should be expecting to see fully functional openwrt images with support for RT-AC58U v2/v3?
I just got one recently and I was planning to use openwrt since the stock firmware does not support VLANs.
Thanks,
Roy

Hi! We're resuming our work after a bit of a break. The following is missing functionality as of now:

  • 2.4 GHz Wi-Fi
  • 5 GHz Wi-Fi
  • USB

As far as I know, it is possible to get USB and 5 GHz Wi-Fi working, but the patch for these features is not yet ready and we'll be preparing it soon. I will post an update here as soon as things become more clear.

As for 2.4 GHz Wi-Fi, it is not clear when we'll be able to support it. I think it would be helpful if you could ask the manufacturer for the source code of wireless drivers used in this model.

2 Likes

Hi.
What about this ?
https://dlcdnets.asus.com/pub/ASUS/wireless/RT-AC57U_V2/GPL_RT_AC57U_V2_3004382.52274.zip

Hi! I'm tagging everyone who expressed interest in this work because I need your input. I will be making community (i.e. unofficial) builds for testing.

IMPORTANT: do NOT expect 2.4 GHz Wi-Fi anytime soon! Everything else, including 5 GHz Wi-Fi is expected to work after we integrate the remaining patches.

Please tell me if you're interested and also which packages / settings are important to you so that I know what to include in my builds.

Thanks,
Alex


@merlin @Hsxsky @yeste @dipol0 @big_bang @qasta @rdxmaster @Jhonny-2005 @PolynomialDivision

3 Likes

Hi. Important update.

We are a two-man team from Ukraine. In light of recent events, it is not clear if / when we'll be able to continue actively working on this project. We might loose internet access or get hit by a missile or have to evacuate leaving non-essential equipment behind. Therefore I decided to explain the current status of the patches. We're mostly fine at the moment, but will spend less time on this side-project due to more pressing concerns.

If you wish to work on this and need help getting started, reach out to me on this forum. If you already have patches to contribute, you can ask me for my email address or open a merge request in my gitlab repository.

If you have something to contribute and you message me in this topic and you don't get a response from us for 4 weeks, consider taking the code from the last commit in apjet01-rebase branch, adding whatever you have and submitting it to OpenWrt. Don't forget to change the signed-off lines according to this doc though.

Technical information

Unsupported features

Branches

  • apjet01 contains tested code with true history of development
  • apjet01-dev is derived from apjet01, but includes untested patches
  • apjet01-rebase has the same code as apjet01-dev except all our commits
    are squashed and rebased on top of upstream master branch. It has a
    single commit with the message I am planning to use when submitting
    the patch via email. This branch will be forced-pushed to, keep this in mind when doing git pull.
  • apjet01_usb contains a patch for USB support, needs to be rebased on
    apjet01-dev and tested

How to install

The process is the same as building OpenWrt from source, except you clone our repository instead of official one with the branch you want:
git clone https://gitlab.com:alexconst.sh/openwrt -b apjet01-rebase

In menuconfig you should select the following:

  • Target System: Atheros ATH79
  • Subtarget: Generic
  • Target Profile: Qualcomm Atheros APJET01

There are two variants of Target Profile depending on your device

Use 16M variant if you have these devices:

  • RT-AC57U v2
  • RT-AC58U v2
  • RT-AC59U v1

Use 32M variant if you have these devices:

  • RT-AC57U v3
  • RT-AC58U v3
  • RT-AC59U v2

Future plans

Apart from testing and integrating existing patches, I will be working on documentation and releasing images as promised. Just keep in mind that my ability to do so depends on how good my city's infrastructure will be in the coming weeks, which is very unpredictable.

3 Likes