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

ath79: add support for TP-LINK Archer C7 v4 #1726

Closed
wants to merge 1 commit into from

Conversation

oldium
Copy link
Contributor

@oldium oldium commented Jan 7, 2019

TP-Link Archer C7 v4 is a dual-band AC1750 router, based on Qualcomm/Atheros
QCA9561+QCA9880.

Specification:

  • 775/650/258 MHz (CPU/DDR/AHB)
  • 128 MB of RAM (DDR2)
  • 16 MB of FLASH (SPI NOR)
  • 3T3R 2.4 GHz
  • 3T3R 5 GHz
  • 5x 10/100/1000 Mbps Ethernet
  • 7x LED, 2x button
  • UART header on PCB

Flash instruction:

  1. Upload openwrt-ath79-generic-tplink_archer-c7-v4-squashfs-factory.bin via Web interface

Flash instruction using TFTP recovery:

  1. Set PC to fixed ip address 192.168.0.66
  2. Download openwrt-ath79-generic-tplink_archer-c7-v4-squashfs-factory.bin
    and rename it to ArcherC7v4_tp_recovery.bin
  3. Start a tftp server with the file tp_recovery.bin in its root directory
  4. Turn off the router
  5. Press and hold Reset button
  6. Turn on router with the reset button pressed and wait ~15 seconds
  7. Release the reset button and after a short time
    the firmware should be transferred from the tftp server
  8. Wait ~30 second to complete recovery.

@oldium
Copy link
Contributor Author

oldium commented Jan 7, 2019

Based upon work on ath79 Archer A7/C7 v5, but I fixed few issues like LED aliases in DTS (led-boot and others) and fixed initialization of ar8327 (removed irrelevant LED initialization and aligned init of port6 with ar71xx init). This should probably be fixed the same on C7 v5, too.

C7 v4 and C7 v5 have completely different GPIOs (LEDs) and have two USBs, so I created new DTS instead of trying to bring a common base.

@oldium
Copy link
Contributor Author

oldium commented Jan 7, 2019

Just a note for ar8327 init values (Archer C7 v4 uses QCA8337N chip):

  1. The PORT0 PAD CTRL value sets bit 31 (MAC06_EXCHANGE_EN) same like in ar71xx mode
  2. The PORT6_STATUS value is set the same as in ar71xx mode

Without change 2 the PORT 6 is shown as connected, but with this change it is shown as "down" (in the swconfig dev switch0 show).

@blocktrron
Copy link
Member

In your commit message you mention a QCA9888, but the C7 uses a QCA9880.

The dtsi seems to be not necessary as there is no Archer A7 v4. So everything should be contained in the C7 v4 dts.

@oldium
Copy link
Contributor Author

oldium commented Jan 7, 2019

@blocktrron Commit message - fixed. Single DTS - fixed. I force-pushed the updated commit.

@oldium
Copy link
Contributor Author

oldium commented Jan 8, 2019

Quick-tested on two routers, both boot, power LED blinks during boot, normal startup. Updated patch works :-)

@chunkeey chunkeey added the target/ath79 pull request/issue for ath79 target label Jan 8, 2019
@oldium
Copy link
Contributor Author

oldium commented Jan 9, 2019

Tested also with pull request #1635 (kernel 4.19) on one of my two routers and it works fine so far.

@oldium
Copy link
Contributor Author

oldium commented Jan 9, 2019

Should I update generic-tp-link.mk as per #1718 (it is RFC actually)? The referenced pull request changes TP-LINK name to TP-Link in the DEVICE_TITLE variable.

@howl
Copy link
Contributor

howl commented Jan 13, 2019

Can you check the MAC addresses? I doubt the eth0 it's ok, as the wan interface in the stock firmware is the lan mac plus one. If you took as reference the ar7xx code it's wrong.

@oldium
Copy link
Contributor Author

oldium commented Jan 14, 2019

I think that it behaves the same as ar71xx code, so it might be wrong (I have not run stock for a long time). How it should be? eth0 MAC same as 2.4GHz wifi, but 5GHz should be +1? This should be easy to change in 02_network.

Currently it is eth0 MAC = phy#1 MAC (2.4GHz), phy#0 MAC (5GHz) is -1.

@oldium
Copy link
Contributor Author

oldium commented Jan 14, 2019

@howl Nope, it is correct. Same as stock.

2.4GHz MAC = LAN MAC
5GHz MAC = LAN MAC -1

@howl
Copy link
Contributor

howl commented Jan 14, 2019

Yes, but wan LAN MAC +1, in ar71xx lan, wifi2g and wifi5g are ok, but wan mac conflicts with lan and wifi2g and it should be plus 1.

I think eth0 is wan and eth1 is lan. Don't have mine near nowadays to recheck.

Edit just to be clear:
eth1 (LAN): mac ok +0
wlan2g: mac ok +0
wlan5g: mac ok -1
eth0 (WAN): mac wrong +0 but it should be +1

@oldium
Copy link
Contributor Author

oldium commented Jan 14, 2019

Yes, that looks correct. Stock:

5 GHz xx-xx-xx-xx-xx-AA
2.4 GHz xx-xx-xx-xx-xx-AB
LAN xx-xx-xx-xx-xx-AB
WAN xx-xx-xx-xx-xx-AC

This is out of my knowledge, I just tried to understand the DTS. I see only eth0 on openwrt and have no clue on what could be done in order to introduce eth1 with different MAC...

@howl
Copy link
Contributor

howl commented Jan 14, 2019

I will try to help you if I can, I'm in the same situation. Anyways if you are using your branch in your router check if wan it's ok, perhaps with ath79 openwrt brings the correct mac despite not specified.

Edit: in v4 and v5 eth0 could be lan and eth1 wan, v2 is the c7 that have eth0 wan and eth1 lan. I'm going to take back my v4 tomorrow to check.

@howl
Copy link
Contributor

howl commented Jan 14, 2019

Despite not having yet the v4, I have take a look to the code and I have found that there is only eth0 in v4 and v5. So at first sight only one mac can be defined in dts.

The same situation is with tl-wr1043nd-v4, previous versions have eth0 wan and eth1 lan, but v4 has only eth0. The approach I can see that makes setting the wan mac for the wan vlan in eth0 is in target/linux/ath79/base-files/etc/board.d/02_network file.

The first function ath79_setup_interfaces() define the interfaces and vlans. The second one ath79_setup_mac() set up macs for situations like the one we have here, so tl-wr1043nd-v4 have:
284 tplink,tl-wr1043nd-v4)
285 base_mac=$(mtd_get_mac_binary product-info 8)
286 wan_mac=$(macaddr_add "$base_mac" 1)
287 ;;

If I not in a mistake you need to add also in that file the following case:
tplink,archer-c7-v4)
base_mac=$(mtd_get_mac_binary config 8)
wan_mac=$(macaddr_add "$base_mac" 1)
;;

In tl-wr1043nd-v4 the mtd is labeled product-info and you have labeled it config:
info: partition@f00000 {
label = "config";
reg = <0xf00000 0x0f0000>;
read-only;
};

If they get labeled with the same name the case for the wr1043nd-v4 could be used for archer-c7-v4.

@howl
Copy link
Contributor

howl commented Jan 15, 2019

In ar71xx is also called config you used the same names. Any ways I'm trying to set the mac as it should be but It doesn't seems possible without using macvlan. I think your pull request can be accepted as is till some experienced developer shows how to define the mac address for a vlan at first boot.

Will try to find more devices that have the lan and wan in the same switch how they handle this.

@oldium
Copy link
Contributor Author

oldium commented Jan 15, 2019

The wan_mac trick should work actually. I have just tried to generate fresh /etc/config/network, the "wan" was generated as eth0.2 (VLAN 2) with macaddr option set and when I added it to my live configuration, the interface listed with ip addr got the wanted MAC. I will update the patch and test it with a freshly built firmware later this evening.

@oldium
Copy link
Contributor Author

oldium commented Jan 15, 2019

Tested with clean-config flash, eth0.2 interface has the +1 MAC. When you test it from PC and watch Wireshark, it really shows DHCP requests from +1 MAC. Other ports show communication from +0 MAC. The VLAN game works well here, the change in 02_network works :-)

@howl
Copy link
Contributor

howl commented Jan 17, 2019

Yes I tested too macaddr, but couldn't test at first boot the wan_mac code xD

Good port @oldium, that change for the wan mac I think should be in more tp-link devices that use one physical switch for lan and wan ethernet ports.

PD: The only thing left you need to do is to merge this in one commit, I did a pull request recently and ended up doing also more than one commit in the pull and cannot be merged in main openwrt's git in that situation. If you cannot remove the last commit and use amend to add also changes in the first commit I think you are going to create a new pull request with only one commit.

TP-Link Archer C7 v4 is a dual-band AC1750 router, based on Qualcomm/Atheros
QCA9561+QCA9880.

Specification:

- 775/650/258 MHz (CPU/DDR/AHB)
- 128 MB of RAM (DDR2)
- 16 MB of FLASH (SPI NOR)
- 3T3R 2.4 GHz
- 3T3R 5 GHz
- 5x 10/100/1000 Mbps Ethernet
- 7x LED, 2x button
- UART header on PCB

Flash instruction:
1. Upload openwrt-ath79-generic-tplink_archer-c7-v4-squashfs-factory.bin via Web interface

Flash instruction using TFTP recovery:
1. Set PC to fixed ip address 192.168.0.66
2. Download openwrt-ath79-generic-tplink_archer-c7-v4-squashfs-factory.bin
and rename it to ArcherC7v4_tp_recovery.bin
3. Start a tftp server with the file tp_recovery.bin in its root directory
4. Turn off the router
5. Press and hold Reset button
6. Turn on router with the reset button pressed and wait ~15 seconds
7. Release the reset button and after a short time
the firmware should be transferred from the tftp server
8. Wait ~30 second to complete recovery.

Signed-off-by: Oldřich Jedlička <oldium.pro@gmail.com>
@oldium
Copy link
Contributor Author

oldium commented Jan 17, 2019

@howl Force-committed squashed commit, ready for merge :-)

@oldium
Copy link
Contributor Author

oldium commented Jan 17, 2019

@howl It is worth mentioning that Archer C7 v5 DTS most probably should be fixed according to this pull request, because its DTS contains the following issues:

  • There is only one LED alias led-status, so I doubt that anything blinks during boot indicating correct boot stage
  • qca,ar8327-initvals:
    • it initializes LEDS, but if v5 is same as v4, there are no ethernet LEDS on the backpanel, so it is meaningless to initialize them
    • it does not initialize PORT6, so it will look like connected - ar71xx code initializes also PORT6 and it appears as disconnected (I have tested this on v4)
    • if v5 also uses QCA8337N, the PORT0 PAD CTRL init value on ath79 is different to one used during init on ar71xx, where the highest bit is set (bit MAC06_EXCHANGE_EN). I cannot say what this change means, though, but my intention was to have v4 init values aligned (ath79 uses the same values as ar71xx).

I do not have Archer C7 v5, so I cannot test any changes - I cannot provide a verified pull request that way.

@howl
Copy link
Contributor

howl commented Jan 17, 2019

@oldium me neither, I only have v2 and v4, I suppouse v5 is very similar and only one usb port removed. I will try to ping at email the original author of the v5 support to check it.

Another thing, the usb leds gets on properly when usb 1 and 2 have a usb device? I don't know about led definitions in dts file, if they don't work is very easy to change the dts definition and add it to board.d led configuration. If they work leave it as is.

@dedeckeh If you have time could you check this PR? It could possibly appoint to mac issues in several tp-link recent version routers. wan mac conflicting with lan mac in only one switch routers. In this pr is solved for the archer-c7-v4 but there are more tp-links with only one switch.

@oldium
Copy link
Contributor Author

oldium commented Jan 17, 2019

@howl
USB LEDs - yes, they work, I have tested them. I am just not sure about the order on the stock firmware (I forgot to test it), but definitely one lights-up when you use one USB and the other one when you use the other USB port... If you want, you can test it and possibly swap them in DTS :-)

@oldium
Copy link
Contributor Author

oldium commented Jan 17, 2019

Thanks for hints and help :-)

@howl
Copy link
Contributor

howl commented Jan 17, 2019

I tried to find the labels in the manual, but they don't specify. I don't think is an important change.In ar71xx I think the upper led is the one used for usb 1 and the lower one is the one used for usb 2.

I don't have privileges to merge, but I'm sure when someone watch this it's going to be merged without problems. Good work @oldium.

jow- pushed a commit to lede-project/source that referenced this pull request Jan 30, 2019
The correct MAC address for this device is lan_mac +1, there is no
need to set lan_mac so use base_mac variable instead lan_mac.

Based on this PR for ath79:
openwrt/openwrt#1726

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
[fix alphabetical ordering, reword subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
jow- pushed a commit that referenced this pull request Jan 30, 2019
The correct MAC address for this device is lan_mac +1, there is no
need to set lan_mac so use base_mac variable instead lan_mac.

Based on this PR for ath79:
#1726

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
[fix alphabetical ordering, reword subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>

(cherry picked from commit 4bcf581)
jollaman999 pushed a commit to jollaman999/openwrt that referenced this pull request Feb 1, 2019
The correct MAC address for this device is lan_mac +1, there is no
need to set lan_mac so use base_mac variable instead lan_mac.

Based on this PR for ath79:
openwrt/openwrt#1726

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
[fix alphabetical ordering, reword subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
@chunkeey
Copy link
Member

chunkeey commented Feb 5, 2019

Merged. Thanks.

@chunkeey chunkeey closed this Feb 5, 2019
@oldium oldium deleted the ath79_archer_c7_v4 branch February 10, 2019 19:58
ggbruno pushed a commit to anlix-io/openwrt that referenced this pull request Feb 18, 2019
The correct MAC address for this device is lan_mac +1, there is no
need to set lan_mac so use base_mac variable instead lan_mac.

Based on this PR for ath79:
openwrt#1726

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
[fix alphabetical ordering, reword subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>

(cherry picked from commit 4bcf581)
@howl
Copy link
Contributor

howl commented Feb 24, 2019

@oldium, I have created a pull request to swap usb leds. Already have to check in the original firmwares, but doing it makes usb1 led and usb2 led with their respective ports and match the behaviour that v2 have with openwrt, down led usb1 and upper led usb2.

@oldium
Copy link
Contributor Author

oldium commented Feb 24, 2019

Good, I will test it later this week

adschm added a commit to adschm/openwrt that referenced this pull request Apr 4, 2019
These devices share the network config with C7v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
adschm added a commit to adschm/openwrt that referenced this pull request Apr 4, 2019
This device shares the network config with v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
ynezz pushed a commit to ynezz/openwrt that referenced this pull request Apr 8, 2019
These devices share the network config with C7v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
ynezz pushed a commit to ynezz/openwrt that referenced this pull request Apr 8, 2019
This device shares the network config with v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
jollaman999 pushed a commit to jollaman999/openwrt that referenced this pull request Apr 9, 2019
These devices share the network config with C7v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt/openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
jollaman999 pushed a commit to jollaman999/openwrt that referenced this pull request Apr 9, 2019
This device shares the network config with v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt/openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
grosjo pushed a commit to grosjo/openwrt that referenced this pull request Aug 31, 2019
These devices share the network config with C7v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
grosjo pushed a commit to grosjo/openwrt that referenced this pull request Aug 31, 2019
This device shares the network config with v4, thus the WAN MAC
also needs to be fixed the same way. However, the partition
where the MAC address resides has been changed.

Based on: openwrt#1726

Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
ArtelMike pushed a commit to ArtelMike/openwrt-1 that referenced this pull request Jan 31, 2023
The correct MAC address for this device is lan_mac +1, there is no
need to set lan_mac so use base_mac variable instead lan_mac.

Based on this PR for ath79:
openwrt#1726

Signed-off-by: David Santamaría Rogado <howl.nsp@gmail.com>
[fix alphabetical ordering, reword subject]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>

(cherry picked from commit c81890f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
target/ath79 pull request/issue for ath79 target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants