Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ramips: add support for ASUS RT-AC54U #3017

Closed
wants to merge 1 commit into from
Closed

ramips: add support for ASUS RT-AC54U #3017

wants to merge 1 commit into from

Conversation

castiel652
Copy link
Contributor

@castiel652 castiel652 commented May 12, 2020

Specification:

  • CPU: MTK MT7620A
  • RAM: 64MB
  • ROM: 16MB SPI Flash Macronix MX25L12835E
  • WiFi1: MediaTek MT7620A
  • WiFi2: MediaTek MT7612E
  • Button: reset, wps
  • LED: 9 LEDs:Power, WiFi 2.4G,WiFi 5G, USB, LAN1, LAN2, LAN3, LAN4, WAN
  • Ethernet: 5 ports, 4 LAN + 1 WAN
  • Other: 1x UART 1x USB2.0

Installation:
Update using ASUS Firmware Restoration Tool:

  1. Download the ASUS Firmware Restoration Tool but don't open it yet
  2. Unplug your computer from the router
  3. Put the router into Rescue Mode by: turning the power off, using a pin
    to press and hold the reset button, then turning the router back on while
    keeping the reset button pressed for ~5 secs until the power LED starts
    flashing slowly (which indicates the router has entered Rescue Mode)
  4. Important (if you don't do this next step the Asus Firmware
    Restoration Tool will wrongly assume that the router is not in Rescue Mode
    and will refuse to flash it): go to the Windows Control Panel and
    temporarily disable ALL other network adapters except the one you will use
    to connect your computer to the router
  5. For the single adapter you left enabled, temporarily give it the
    static IP 192.168.1.10 and the subnet mask 255.255.255.0
  6. Connect a LAN cable between your computer (make sure to use the
    Ethernet port of the adapter you've just set up) and port 1 of the router
    (not the router's WAN port)
  7. Rename sysupgrade.bin to factory.trx
  8. Open the Asus Firmware Restoration Tool, locate factory.trx and click
    upload (if Windows shows a compatibility prompt, confirm that the tool worked fine)
  9. Flashing and reboot is finished when the power LED stops blinking and
    stays on

MAC assignment based on vendor firmware:

2g 0x4 label
5g 0x8004 label + 4
lan 0x22 label + 4
wan 0x28 label

Signed-off-by: Zhijun You hujy652@gmail.com

@adschm
Copy link
Member

adschm commented May 12, 2020

Hi, in your commit message, I'd prefer to replace the tab indent by something requiring less space; either one/two spaces, bullet points or no indent at all.

Despite, you should wrap your lines so each line has less than 75 characters.

@adschm adschm added the target/ramips pull request/issue for ramips target label May 12, 2020
flash@0{
compatible = "jedec,spi-nor";
reg = <0>;
spi-max-frequency = <10000000>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be increased?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do I know how much to increase?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have a look at the datasheets (if you find some) and/or try increasing and see whether it's stable. You may also check which other recently added devices have the same flash, as we started to request this quite frequently.
Most of the older devices just always copied 10 MHz from some other DTS, and this is considerably slower than necessary.

Copy link
Contributor Author

@castiel652 castiel652 May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

datasheet says it's 50MHz when doing normal read. I will start with that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may try that with and without m25p,fast-read;. Just benchmark with a simple dd if the device is booting. Normally, only certain steps are possible for the frequency, so you might only see a performance change if you double etc.

You may also try 80 MHz with fast-read if the specs state it's supported and recovery is not too painful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specs say read 50MHz
fast read 104MHz
datasheet (Table 13. AC CHARACTERISTICS)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may try 100 MHz for fun, but I don't think it will boot.
Based on you evaluation, I'd take the 50 with fast-read ...


&ethernet {
status = "okay";
mtd-mac-address = <&factory 0x4>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a proper address in 0x28, 0x2e, 0xe000 or 0xe006?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0x4, 0x22, 0x28 have addresses.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then please give an overview over the addresses in flash and the addresses on vendor firmware, so we can assign them properly.
FYI: https://openwrt.org/docs/guide-developer/mac.address

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

factory 0x4, 0x28: WAN, 2.4G (both addresses have the same value)
factory 0x22: LAN, 5G

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, perfect. Then, please use the 0x22 for &ethernet and the 0x28 for wan_mac in the lower part of 02_network (instead of the increment). The 5g address should also be in 0x8004, as this is what's read automatically with mediatek,mtd-eeprom, like 0x4 is automatically read for 2g ...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If your label shows LAN address, then you should add label-mac-device = &ethernet; to the aliases section.

Copy link
Contributor Author

@castiel652 castiel652 May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LAN(label): aa:bb:cc:dd:ee:6c
WAN: aa:bb:cc:dd:ee:68
so the offset should be -4?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, exactly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed as above now 5G doesn't get the right address

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just push your latest state so I can have a look.

@@ -37,6 +37,9 @@ asus,rp-n53)
ucidef_set_led_netdev "eth" "Network" "$boardname:white:back" "eth0"
set_wifi_led "$boardname:blue:wifi"
;;
asus,rt-ac54u)
ucidef_set_led_netdev "wifi2g" "Wifi 2.4G" "$boardname:blue:wifi" "wlan1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check whether you can use a device tree trigger instead.

@adschm
Copy link
Member

adschm commented May 12, 2020

Since your DTS is essentially mostly a copy of the one for rt-ac51u, please create a shared DTSI for them.

@@ -235,6 +236,7 @@ ramips_setup_macs()
case $board in
aigale,ai-br100|\
asus,rt-ac51u|\
asus,rt-ac54u|\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check whether the WAN MAC address you find in vendor firmware is also found in flash (check the locations given in my comment above).

What's the MAC address assignment on vendor firmware (LAN, WAN, 2g, 5g)?

&pcie0 {
wifi@0,0 {
reg = <0x0000 0 0 0 0>;
mediatek,mtd-eeprom = <&factory 0x8004>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be 0x8000. The MAC address is automatically read from offset +4, so caldata at 0x8000 will have the address read from 0x8004.

Following the same mechanism, wmac gets the address at 0x4 because mtd-eeprom start at 0x0 ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok I will fix it

wifi {
label = "rt-ac54u:blue:wifi";
gpios = <&gpio3 0 GPIO_ACTIVE_LOW>;
linux,default-trigger = "phy1tpt";
Copy link
Member

@adschm adschm May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You state the device has two Wifi LEDs? I assume 5g is controlled by driver, so this is 2g?
If yes, you should rename label and node wifi->wifi2g ...

And please double-check that phy1tpt is the correct trigger then (different from the one added as member of pcie0 ...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's 2.4G wifi.
I am sure phy1tpt works. I just tested.

@castiel652
Copy link
Contributor Author

  • 10Mhz
    root@OpenWrt:~# time cat /dev/mtd* > /dev/null
    real 4m 37.78s
    user 0m 0.02s
    sys 2m 43.92s

  • 50Mhz
    root@OpenWrt:~# time cat /dev/mtd* > /dev/null
    real 1m 28.34s
    user 0m 0.03s
    sys 0m 46.96s

  • 50Mhz fast read
    root@OpenWrt:~# time cat /dev/mtd* > /dev/null
    real 1m 11.94s
    user 0m 0.01s
    sys 0m 46.94s

  • 80Mhz
    root@OpenWrt:~# time cat /dev/mtd* > /dev/null
    real 1m 12.31s
    user 0m 0.04s
    sys 0m 46.96s

  • 80Mhz fast read
    root@OpenWrt:~# time cat /dev/mtd* > /dev/null
    real 1m 12.15s
    user 0m 0.02s
    sys 0m 46.97s

@adschm
Copy link
Member

adschm commented May 14, 2020

looks like 50 and fast-read to me. :-)

Might have been easier if you just had used dd with fixed size on a single mtd partition.

But you should clearly see why I forced you to do this if you compare 10 and 50 MHz results.

Specification:
-CPU: MTK MT7620A
-RAM: 64MB
-ROM: 16MB SPI Flash Macronix MX25L12835E
-WiFi1: MediaTek MT7620A
-WiFi2: MediaTek MT7612E
-Button: reset, wps
-LED: 9 LEDs:Power, WiFi 2.4G,WiFi 5G, USB, LAN1, LAN2, LAN3, LAN4, WAN
-Ethernet: 5 ports, 4 LAN + 1 WAN
-Other: 1x UART 1x USB2.0

Installation:
  Update using ASUS Firmware Restoration Tool:
  1. Download the ASUS Firmware Restoration Tool but don't open it yet
  2. Unplug your computer from the router
  3. Put the router into Rescue Mode by: turning the power off, using a pin
to press and hold the reset button, then turning the router back on while
keeping the reset button pressed for ~5 secs until the power LED starts
flashing slowly (which indicates the router has entered Rescue Mode)
  4. Important (if you don't do this next step the Asus Firmware
Restoration Tool will wrongly assume that the router is not in Rescue Mode
and will refuse to flash it): go to the Windows Control Panel and
temporarily disable ALL other network adapters except the one you will use
to connect your computer to the router
  5. For the single adapter you left enabled, temporarily give it the
static IP 192.168.1.10 and the subnet mask 255.255.255.0
  6. Connect a LAN cable between your computer (make sure to use the
Ethernet port of the adapter you've just set up) and port 1 of the router
(not the router's WAN port)
  7. Rename sysupgrade.bin to factory.trx
  8. Open the Asus Firmware Restoration Tool, locate factory.trx and click
upload (if Windows shows a compatibility prompt, confirm that the tool worked fine)
  9. Flashing and reboot is finished when the power LED stops blinking and
stays on

MAC assignment based on vendor firmware:

2g    0x4	label
5g    0x8004	label + 4
lan   0x22	label + 4
wan   0x28	label

Signed-off-by: Zhijun You <hujy652@gmail.com>
@castiel652
Copy link
Contributor Author

I found that command in one of the spi-max-frequency related commit.

@castiel652
Copy link
Contributor Author

Since your DTS is essentially mostly a copy of the one for rt-ac51u, please create a shared DTSI for them.

I should make the DTSI in a separated PR right?

@adschm
Copy link
Member

adschm commented May 14, 2020

Since your DTS is essentially mostly a copy of the one for rt-ac51u, please create a shared DTSI for them.

I should make the DTSI in a separated PR right?

No, I'd have preferred to do it together with adding device support here.

But to not make things more complicated than necessary, it might be easier if you just keep the separate DTS (= current state) for now and I will do the DTSI myself when merging this to my staging tree...

@castiel652
Copy link
Contributor Author

Gotcha. Thanks for your help!

@adschm
Copy link
Member

adschm commented May 14, 2020

lan 0x22 label + 4

I thought lan was the label address?

@castiel652
Copy link
Contributor Author

lan 0x22 label + 4

I thought lan was the label address?

No sorry didn't mention it earlier.

WAN is the label address.

@adschm
Copy link
Member

adschm commented May 14, 2020

I've pushed my DTS split and a rebase of your patch to my staging tree here:
https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/staging

Please give it another test and report any issues or comments.

@adschm
Copy link
Member

adschm commented May 14, 2020

@Redfoxymoon @LorenzoBianconi @DavideFioravanti I've pushed a patch with improvements for RT-AC51U based on the findings for RT-AC54U here to my staging tree:
https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/staging

Would one you test these and report whether this is working (flash speed increase, Wifi LEDs for 2g and 5g)?

Despite, can you report the MAC addresses in factory partition (full partition dump or just retrieve 0x4, 0x22, 0x28, 0x2e, 0x8004). If possible, the corresponding MAC assignment from vendor OS would be quite helpful. I assume this would end up with the same setup as AC51U ...

@LorenzoBianconi
Copy link
Contributor

LorenzoBianconi commented May 14, 2020 via email

@adschm
Copy link
Member

adschm commented May 14, 2020

RT-AC54U runs mt76x2 IIUC, right?

Ah, that's right.

However, there are some mt76x0e devices with similar (yet different) 5g LED setup as well:

		led {
			led-sources = <0>;
			led-active-low;
		};

So, this would need some additional testing on RT-AC51U ...

@castiel652
Copy link
Contributor Author

I've pushed my DTS split and a rebase of your patch to my staging tree here:
https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/staging

Please give it another test and report any issues or comments.

Everything is working fine.

Tested: LEDs, both WiFi, MAC address, LAN & WAN ports, USB port

@DavideFioravanti
Copy link
Contributor

@Redfoxymoon @LorenzoBianconi @DavideFioravanti I've pushed a patch with improvements for RT-AC51U based on the findings for RT-AC54U here to my staging tree:
https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/staging

Would one you test these and report whether this is working (flash speed increase, Wifi LEDs for 2g and 5g)?

Despite, can you report the MAC addresses in factory partition (full partition dump or just retrieve 0x4, 0x22, 0x28, 0x2e, 0x8004). If possible, the corresponding MAC assignment from vendor OS would be quite helpful. I assume this would end up with the same setup as AC51U ...

I will test these changes on a RT-AC51U tomorrow 😉

@DavideFioravanti
Copy link
Contributor

@Redfoxymoon @LorenzoBianconi @DavideFioravanti I've pushed a patch with improvements for RT-AC51U based on the findings for RT-AC54U here to my staging tree:
https://git.openwrt.org/?p=openwrt/staging/adrian.git;a=shortlog;h=refs/heads/staging

Would one you test these and report whether this is working (flash speed increase, Wifi LEDs for 2g and 5g)?

Flash is working.
Wifi LED 2g is working
Wifi LED 5g not working (I tried also led-sources = <0>; or led-sources = <1>; or led-sources = <2>;)

Despite, can you report the MAC addresses in factory partition (full partition dump or just retrieve 0x4, 0x22, 0x28, 0x2e, 0x8004). If possible, the corresponding MAC assignment from vendor OS would be quite helpful. I assume this would end up with the same setup as AC51U ...

Currently the Openwrt has these addresses:
Mac address label is the same as lan and 2g wifi: XX:XX:XX:XX:XX:38
5g wifi: XX:XX:XX:XX:XX:3C
wan: XX:XX:XX:XX:XX:39

On the factory partitions there are these addresses:
Factory 0x04: XX:XX:XX:XX:XX:38
Factory 0x22: XX:XX:XX:XX:XX:3C
Factory 0x28: XX:XX:XX:XX:XX:38
Factory 0x2e: 00:0C:43:76:20:66
Factory 0x8004: XX:XX:XX:XX:XX:3C

I don't remember the OEM implementation. However, reading the openwrt wiki I think that I will be able to come back to stock fw and let you know 😉

@adschm
Copy link
Member

adschm commented May 16, 2020

Wifi LED 5g not working (I tried also led-sources = <0>; or led-sources = <1>; or led-sources = <2>;

Did you try with led-active-low; ?

@adschm
Copy link
Member

adschm commented May 16, 2020

Wifi LED 2g is working

Can you check whether 2g LED really shows 2g activity by selectively enabling that? I'm not perfectly sure whether phy1tpt is correct here (because that would mean it was wrong before, as 01_leds uses phy0tpt ...)

@adschm
Copy link
Member

adschm commented May 17, 2020

@DavideFioravanti I plan to merge the flash frequency increase separately from the rest, can I add your tested-by there?

@adschm
Copy link
Member

adschm commented May 17, 2020

So, I've merge the device support itself now, but kept both devices to 10 MHz SPI freq. I have built a separate patch to increase SPI freq on both devices, which is only waiting for Davide's testing by now. The rest will be sorted out after further feedback ...

@DavideFioravanti
Copy link
Contributor

Wifi LED 5g not working (I tried also led-sources = <0>; or led-sources = <1>; or led-sources = <2>;

Did you try with led-active-low; ?

Yes, but I can't be sure if I tried every combination of led-sources = <X>; and led-active-low;. I will test it later today.

Wifi LED 2g is working

Can you check whether 2g LED really shows 2g activity by selectively enabling that? I'm not perfectly sure whether phy1tpt is correct here (because that would mean it was wrong before, as 01_leds uses phy0tpt ...)

I will test this too.

@DavideFioravanti I plan to merge the flash frequency increase separately from the rest, can I add your tested-by there?

Yes, sure! 😉

@DavideFioravanti
Copy link
Contributor

DavideFioravanti commented May 18, 2020

@adrianschmutzler
I tested every combination with led-sources = <X>; (where X is 0, 1 or 2) and with or without led-active-low; but 5G led didn't turn on.

Moreover I confirm that phy1tpt is the right one for 2G wifi. phy0tpt is referred to 5G wireless interface.

@adschm
Copy link
Member

adschm commented May 18, 2020

@DavideFioravanti Thanks. So this device won't get a 5G led for now.

So, the only thing missing now is the OEM MAC assignment. :-)

@DavideFioravanti
Copy link
Contributor

@DavideFioravanti Thanks. So this device won't get a 5G led for now.

So, the only thing missing now is the OEM MAC assignment. :-)

Ok I flashed the OEM FW. Here you are
LAN MAC address
XX:XX:XX:XX:XX:3C
WAN MAC address
XX:XX:XX:XX:XX:38
Wireless 2.4GHz MAC address
XX:XX:XX:XX:XX:38
Wireless 5GHz MAC address
XX:XX:XX:XX:XX:3C

(Just to recall, mac address on the label is XX:XX:XX:XX:XX:38)

@adschm
Copy link
Member

adschm commented May 18, 2020

Thanks again for your help, I will merge the rest during the next hour.

@adschm adschm closed this May 18, 2020
jow- pushed a commit that referenced this pull request May 18, 2020
Like for the RT-AC54U, this uses a DT trigger for WiFi also at the
RT-AC51U. While at it, rename node and label to wifi2g.

Note that the 5g WiFi LED still isn't supported (see PR #3017 for
further details: #3017 )

Tested-by: Davide Fioravanti <pantanastyle@gmail.com>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
aiamadeus pushed a commit to immortalwrt/immortalwrt that referenced this pull request May 19, 2020
Like for the RT-AC54U, this uses a DT trigger for WiFi also at the
RT-AC51U. While at it, rename node and label to wifi2g.

Note that the 5g WiFi LED still isn't supported (see PR #3017 for
further details: openwrt/openwrt#3017 )

Tested-by: Davide Fioravanti <pantanastyle@gmail.com>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
aiamadeus pushed a commit to immortalwrt/immortalwrt that referenced this pull request May 20, 2020
Like for the RT-AC54U, this uses a DT trigger for WiFi also at the
RT-AC51U. While at it, rename node and label to wifi2g.

Note that the 5g WiFi LED still isn't supported (see PR #3017 for
further details: openwrt/openwrt#3017 )

Tested-by: Davide Fioravanti <pantanastyle@gmail.com>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
@castiel652 castiel652 deleted the asus-rt-ac54u branch June 17, 2020 16:17
jollaman999 pushed a commit to jollaman999/openwrt that referenced this pull request Jul 10, 2020
Like for the RT-AC54U, this uses a DT trigger for WiFi also at the
RT-AC51U. While at it, rename node and label to wifi2g.

Note that the 5g WiFi LED still isn't supported (see PR #3017 for
further details: openwrt/openwrt#3017 )

Tested-by: Davide Fioravanti <pantanastyle@gmail.com>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ramips pull request/issue for ramips target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants