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 ALFA Network AP121F #2199

Closed
wants to merge 1 commit into from

Conversation

rogerpueyo
Copy link
Contributor

This commit ports to the ALFA Network AP121F, a pocket-size router with 1 Ethernet and 2.4 GHz WiFi based on the AR9331 SoC, to the ath79 target (it was already supported in ar71xx; see commit
0c6165d for more details).

Notes:

  • The art partition contains only one MAC address, inside the radio
    caldata. Use the same MAC, +1, for eth0 (previously, on ar71xx, it
    got a randomly-generated one).
  • The device is said to support an optional microSD reader, which is
    not currently available, but could be added in a latter commit.

@aparcar Could you please check the commit and test it on the actual device?
@pepe2k If you have the microSD optional board (I don't have it), would you please mind completing the code?

@aparcar
Copy link
Member

aparcar commented Jul 5, 2019

Thanks for you work, tested and works on my (SDcard less) device.

@pepe2k
Copy link
Member

pepe2k commented Jul 5, 2019

@rogerpueyo

* The art partition contains only one MAC address, inside the radio
  caldata. Use the same MAC, +1, for eth0 (previously, on ar71xx, it
  got a randomly-generated one).

Do you have a production or a sample device?

@pepe2k If you have the microSD optional board (I don't have it), would you please mind completing the code?

Sure, will do it.

BTW. Please, use alfa-network for the compatible string, as we already did in ramips target.

Cheers,
Piotr

@pepe2k pepe2k self-assigned this Jul 5, 2019
@pepe2k pepe2k added the target/ath79 pull request/issue for ath79 target label Jul 5, 2019
@adschm
Copy link
Member

adschm commented Jul 5, 2019

So, is the +1 for eth0 your invention or is it also found in stock firmware?

@rogerpueyo
Copy link
Contributor Author

rogerpueyo commented Jul 5, 2019

@rogerpueyo

* The art partition contains only one MAC address, inside the radio
  caldata. Use the same MAC, +1, for eth0 (previously, on ar71xx, it
  got a randomly-generated one).

Do you have a production or a sample device?

I got it from @aparcar, I guess it must be a sample device (he has one, with the same issue, BTW).

@pepe2k If you have the microSD optional board (I don't have it), would you please mind completing the code?

Sure, will do it.

Thank you very much.

BTW. Please, use alfa-network for the compatible string, as we already did in ramips target.

Sure, I'll change it.

@rogerpueyo
Copy link
Contributor Author

So, is the +1 for eth0 your invention or is it also found in stock firmware?
The device arrived to me with OpenWrt (ar71xx) already, and I can't find any stock firmware on the manufacturer's website.

The place under the art partition where the eth0 MAC address should be is blank (0xFFs), so I assumed adding +1 to the wlan MAC would be neat. But as Piotr suggested, I might have ended up getting a sample rather than a production device. In this case, I'll try to reach the manufacturer.

@KCinJP
Copy link

KCinJP commented Jul 5, 2019

... But as Piotr suggested, I might have ended up getting a sample rather than a production device. In this case, I'll try to reach the manufacturer.

If that is one if the devices I gave to Paul last summer then it should be production.

@adschm
Copy link
Member

adschm commented Jul 5, 2019

BTW, that would mean that &wmac stores label-mac-address?

@rogerpueyo
Copy link
Contributor Author

rogerpueyo commented Jul 16, 2019

BTW, that would mean that &wmac stores label-mac-address?

Apparently, yes. I will add it to the commit, but first I would like to understand where MACs are stored.

@KCinJP, do you know if there is any way to get the vendor's stock firmware? I've searched through https://files.alfa.com.tw/ with no luck.
@pepe2k, is your device a development one or a production one? Does it have anything at the beginning of the "art" partition? Mine is blank (0xFFs) until 0x1000.

I've renamed alfa=>alfa-network as indicated and rebased master.

Best,
Roger

@rogerpueyo rogerpueyo force-pushed the ath79-ap121f branch 2 times, most recently from 1d1fbef to b6ae06f Compare July 16, 2019 17:53
@pepe2k
Copy link
Member

pepe2k commented Jul 16, 2019

@rogerpueyo

I have two correct MAC addresses (with ALFA OUI) at the begin of ART... but at least in case of the device I have here the MAC address inside calibration data is incorrect/fake (00:c0:ca:00:00:01) - looks like generic ART, before calibration and MAC assignment.

I will double check that with someone in ALFA. This device doesn't have a dedicated/custom vendor firmware, AFAIK its sold with generic OpenWrt image.

BTW could you send me your device ART dump?

Cheers,
Piotr

@pepe2k
Copy link
Member

pepe2k commented Jul 17, 2019

@rogerpueyo one more thing, if you can open the case (be careful with plastic locks!), could you check if there is a sticker/label on the DRAM, with MAC address and some other code?

Thanks!

@rogerpueyo
Copy link
Contributor Author

rogerpueyo commented Jul 17, 2019

@pepe2k
Please find the art partition in the attached gzip.

I went through the whole flash and found the "00 C0 CA XX XX XX" pattern twice:

  1. At 0x1000 in art, and contains the MAC address printed on the sticker.
  2. At 0x120c in art, and contains "00 C0 CA 11 22 33", which is probably not a real MAC.

The sticker on the RAM reads AGJDBD and the same MAC as on the external sticker and at 0x1000 in art.

Thanks!

mtd2-art.dd.gz

@pepe2k
Copy link
Member

pepe2k commented Jul 18, 2019

@rogerpueyo

I checked another one piece of the AP121F and it also has correct MAC addresses (this is default Atheros ART template):

  • the same as on label (used for Wi-Fi) at 0x1002 in ART
  • ethernet0 (label one + 1) at 0x0 in ART
  • ethernet1 (not used, label one + 2) at 0x6 in ART

I also confirmed that with ALFA. Ethernet MAC addresses are written to ART in LSDK based firmware, during (or just after) radio calibration process. The Wi-Fi MAC address is the main one, printed also on the label.

I think you can safely add missing ethernet MAC address in your ART.

BTW If you want to do some hacking, here is a short instruction how to switch USB to device mode:
alfa-network_ap121f_usb-device-mode_1
alfa-network_ap121f_usb-device-mode_2
alfa-network_ap121f_usb-device-mode_3

Cheers,
Piotr

@rogerpueyo
Copy link
Contributor Author

Piotr,

Thanks for the information. I've tweaked the art partition and now have a standard device :)

I'll be updating the PR in a few minutes.

Can I upload your images and instructions for the USB mod to the OpenWrt's wiki?

Best,
Roger

@rogerpueyo rogerpueyo force-pushed the ath79-ap121f branch 4 times, most recently from 1a359b7 to ac4e2d1 Compare July 18, 2019 14:28
@rogerpueyo
Copy link
Contributor Author

Rebased master; good to go, I think.

Shall I add the "label-mac-device = &wmac;" thing for #2159?

@adschm
Copy link
Member

adschm commented Jul 18, 2019

Shall I add the "label-mac-device = &wmac;" thing for #2159?

That's essentially up to you.
I already added it to my recent device support PRs, as it does not hurt if it gets into master already.
Still, #2159 is not approved or merged yet, so it technically still is an unsupported feature.

@rogerpueyo
Copy link
Contributor Author

OK then. The PR already includes it, so it's #2159-ready :)

@adschm
Copy link
Member

adschm commented Jul 18, 2019

Just had another look at it, I fear that since you do not set mtd-mac-address for wmac (which you do not need normally), the MAC address will not be available via device tree.
Can you do a quick find /proc/device-tree/ -name "*mac-address*" and check whether "wmac" shows up there?

This commit ports to the ALFA Network AP121F, a pocket-size router
with 1 Ethernet and 2.4 GHz WiFi based on the AR9331 SoC, to the
ath79 target (it was already supported in ar71xx; see commit
0c6165d for more details).

Signed-off-by: Roger Pueyo Centelles <roger.pueyo@guifi.net>
@rogerpueyo
Copy link
Contributor Author

Can you do a quick find /proc/device-tree/ -name "*mac-address*" and check whether "wmac" shows up there?

Correct, nothing related to wmac:

root@OpenWrt:~# find /proc/device-tree/ -name "*mac-address*"
/proc/device-tree/ahb/eth@19000000/mac-address
/proc/device-tree/ahb/eth@19000000/mtd-mac-address

I have to explicitly set the mtd-mac-address = <&art 0x1002>; option to make it appear under /proc.

@adschm
Copy link
Member

adschm commented Jul 19, 2019

@rogerpueyo Okay, keep the label-mac-device, it is still correct, though it is not helpful at the moment.
Adding the mtd-mac-address anyway seems redundant to me.

After my PR is through, I might simply add label_mac=$(cat /sys/class/ieee80211/phy0/mac-address) in 02_network for this device then.

@pepe2k
Copy link
Member

pepe2k commented Jul 28, 2019

@rogerpueyo I have merged your changes (with some minor fixes) into my staging tree. If you have time, please test image on your device. And feel free to use the photos on the Wiki!

Cheers,
Piotr

@rogerpueyo
Copy link
Contributor Author

Thank you, @pepe2k!

I've just given your staging tree a try. I didn't test it thoroughly, but I can confirm board detection, Ethernet, WiFi are working. 👍

@CodeFetch
Copy link
Contributor

@rogerpueyo Only one NIC is connected. Which one is it and why didn't you disable the other one?

@adschm
Copy link
Member

adschm commented Aug 11, 2019

If I remember correctly:
With status=disabled, you still see the both ethX on the device.
With compatible = "syscon", "simple-mfd";, you really hide one of them and only have eth0 on the device. That's how we did it with one-port CPE210v2/v3.
I'm not sure about the status = okay, though.

adschm added a commit to adschm/openwrt that referenced this pull request Nov 22, 2019
In d421a8b ("ath79: read label MAC address from flash instead
of using phy0/phy1") the source of the label MAC address was changed
for devices just reading it from phy0. To get rid of the dependency
from phy startup, addresses were read directly from the flash
locations that are used to initialize the phy MAC addresses.

Unfortunately, it turned out that Ubiquiti XM devices seem to have
different flash locations than expected, and also seem to have
specific locations for different devices (all in art/EEPROM):

0xe012 AR9280 Nanostation M2 - 0x120c
0xe035 AR9280 Nanostation M3 - 0x120c
0xe1b2 AR9280 Rocket M2 - 0x120c
0xe1c3 AR9280 Rocket M3 - 0x120c
0xe1b5 AR9280 Rocket M5 - 0x120c
0xe2d5 AR9280 Bullet M2 Titanium - 0x120c
0xe2b5 AR9280 Nanobridge M5 - 0x120c
0xe202 AR9280 Bullet M2 - 0x120c
0xe232 AR9287 Nanobridge M2 - 0x110c
0xe4a2 AR9285 AirRouter - 0xa0bf
Picostation M2 - 0x120c and 0xa0bf
Nanostation Loco M2 - not in 0x120c, other locations not checked

An additional problem of the Ubiquiti device support in OpenWrt is
that we provide images that match several subvariants of the devices,
which might have different MAC address locations.

Given that reading the address from phy0 in 02_network _is_ working
for the ath79 target in general, it does not seem reasonable to
rebuild a complex MAC address retrieval mechanism which is already
present in the ath9k driver.

So, this patch reverts the label MAC address source for Ubiquiti XM
devices (and the Unifi AP) to /sys/class/ieee80211/phy0/macaddress.

This doesn't affect XW and Unifi AC devices, where the label MAC
address source is defined via device tree.

For alfa-network,ap121f the location 0x1002 is kept, as this has
been verified during device support preparation in PR openwrt#2199.

Fixes: d421a8b ("ath79: read label MAC address from flash
instead of using phy0/phy1")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
jow- pushed a commit that referenced this pull request Dec 3, 2019
In d421a8b ("ath79: read label MAC address from flash instead
of using phy0/phy1") the source of the label MAC address was changed
for devices just reading it from phy0. To get rid of the dependency
from phy startup, addresses were read directly from the flash
locations that are used to initialize the phy MAC addresses.

Unfortunately, it turned out that Ubiquiti XM devices seem to have
different flash locations than expected, and also seem to have
specific locations for different devices (all in art/EEPROM):

0xe012 AR9280 Nanostation M2 - 0x120c
0xe035 AR9280 Nanostation M3 - 0x120c
0xe1b2 AR9280 Rocket M2 - 0x120c
0xe1c3 AR9280 Rocket M3 - 0x120c
0xe1b5 AR9280 Rocket M5 - 0x120c
0xe2d5 AR9280 Bullet M2 Titanium - 0x120c
0xe2b5 AR9280 Nanobridge M5 - 0x120c
0xe202 AR9280 Bullet M2 - 0x120c
0xe232 AR9287 Nanobridge M2 - 0x110c
0xe4a2 AR9285 AirRouter - 0xa0bf
Picostation M2 - 0x120c and 0xa0bf
Nanostation Loco M2 - not in 0x120c, other locations not checked

An additional problem of the Ubiquiti device support in OpenWrt is
that we provide images that match several subvariants of the devices,
which might have different MAC address locations.

Given that reading the address from phy0 in 02_network _is_ working
for the ath79 target in general, it does not seem reasonable to
rebuild a complex MAC address retrieval mechanism which is already
present in the ath9k driver.

So, this patch reverts the label MAC address source for Ubiquiti XM
devices (and the Unifi AP) to /sys/class/ieee80211/phy0/macaddress.

This doesn't affect XW and Unifi AC devices, where the label MAC
address source is defined via device tree.

For alfa-network,ap121f the location 0x1002 is kept, as this has
been verified during device support preparation in PR #2199.

Fixes: d421a8b ("ath79: read label MAC address from flash
instead of using phy0/phy1")

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
@rogerpueyo rogerpueyo deleted the ath79-ap121f branch January 31, 2020 15:32
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

6 participants