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...

2 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.