Adding OpenWrt support for Nokia Airscale AC400i

I'm not really sure about the PHY stuffs but it looks like that I could add delay on the PHY side by setting some registers, do you happen to know what it is? The PHY is AR8035, there's a mii command in U-boot for dumping values but I don't know which registers to look for

I have the same AP, where can I find a guide explaining how to install openwrt on this device ?

Hi @minhng99,
thanks for starting to get this device working with OpenWrt :slightly_smiling_face:

Some time ago I had rebased your code to master and tested building the images, it only required a few minor adaptions due to changes introduced to the target in the meantime:

  • rename &nand_controller dts node reference to &nand
  • change compatible = "qcom,smem" to "qcom,smem-part" for the spi-nor
  • rename 0:ART and 0:APPSBLENV to lowercase in 11-ath10k-caldata

Booting the initramfs image via tftp worked fine, however I was not successful getting the gmac settings to work, I tried various options in the dts, e.g.

&gmac0 {
    status = "okay";
    phy-mode = "rgmii";
    qcom,id = <0>;
    mdiobus = <&mdio0>;
    phy-handle = <&phy1>;
    qcom,phy-mdio-addr = <0x01>;
    qcom,poll-required = <0x01>;
    qcom,rgmii-delay = <0x01>;
 };

but I was not successful to get any throughput on either port (only link status was reported correctly for the non-PoE port), also I'm not sure how many of these are actually used by the current (non-OEM) driver.

So it seems there is either a regression, or just some further changes to the target in the meantime that require different settings for configuring ethernet? (Maybe the target will also be ported to DSA soon, as this happened to ipq804x recently...)

Maybe it needs another rebase to the very latest master; I just tried this real quick, but the smem driver would not find the partitions of the spi-nor with the new kernel anymore, this seems to require some further investigation.

Could you try building an image from the above branch and see if ethernet works for you, or whether you could find different settings for the gmac?

By the way, I also noticed that calling reboot is often not sufficient for loading a new image via bootloader tftp - I actually need to power-cycle the device to force a clean boot! So it seems the bootloader does not perform a full re-initialisation of the gmac and/or phy either, and tftp transfer is not working with the previous ethernet settings overwritten by OpenWrt :thinking:

I tried your build and had a little more success.
So LAN2 worked, I got an address through DHCP, and I could transfer files.
LAN1 did connect (no matter, if I used it before boot).
I couldn't get WiFi to work.

So I decided to try loading the Netgear R7800 image.
LEDs partially worked on that build, so we can probably copy them; the ethernet situation was identical, MTD actually read, and there were no changes with Wireless.

I then attempted to boot the qcom_ipq8064-ap161-fit-uImage.itb...
This resulted in a boot crash and scrambled the u-boot settings. LAN2 is dead, and I can't figure out how to get it to connect; it even fails in the OEM firmware now. I tried a few mii commands, but none of them resolved the issue. LAN1 is still in the same state, with connections but no traffic.
Now, I can't boot other images... so, that's a nice state to be in.

Do you still have a bootlog from that attempt? I tried rebasing to the very latest master (running on 5.15 rather than 5.10), but the smem driver could not detect the partitions of the spi-nor, which also includes 0:art, which is where the wireless scripts will pull the caldata from, so when there's an error detecting those smem partitions, the wifi would not work.

It's curious to see uboot settings changed by a generic ap161 image, can you still access the uboot shell at all, what's the output of printenv? Before booting another image via tftp, you need to power cycle the device, to erase all settings from the phy/gmac registers written during a previous OpenWrt boot.

What do you mean by OEM firmware, is there actually some way to access a Web or SSH-based config interface without using the AirScale controller, or did you mean the serial outputs upon connecting / removing the ethernet cable?

I went through my entire log file and have the following to show you: https://gist.github.com/krusic22/496f23d8ad3fd8829bd7b29c06bd903b
I also copied the device's ROM, which I can provide if necessary.

I can still access u-boot, but networking is completely broken. Even performing a full power cycle had no effect.

By OEM firmware I mean the OpenWRT 15 build that came with the device. I attempted to access the web-ui but was unable to do so. SSH authentication should be possible if an authorized key is added, but not to the root account.

So the Netgear R7800 is using a legacy uImage instead of FIT, thus the kernel would use the hardcoded partition layout from the devicetree that comes with the uImage, rather than using the mtdparts string from the bootloader. R7800 does not even have SPI nor, but apparently just NAND.
AP181 seems to use SMEM on both NOR and NAND, so maybe it did mount something while booting, and not just as read-only, although changes to the filesystem should not affect booting images via tftp either.

I could compare the bootloader environment when I'm back at my device within the next couple days, maybe I'll try booting AP161 as well and see whether anything changes :slightly_smiling_face:

1 Like

Further experimentation with both gmacs, the main issue with my LAN2 port still being

[   30.005726] ipq806x-gmac-dwmac 37200000.ethernet eth1: PHY [37000000.mdio-mii:00] driver [Qualcomm Atheros AR8035] (irq=POLL)
[   30.210062] ipq806x-gmac-dwmac 37200000.ethernet: Failed to reset the dma
[   30.210094] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
[   30.215833] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_open: Hw setup failed
eth0 is initialized successfully though:
[    2.429146] ipq806x-gmac-dwmac 37000000.ethernet: IRQ eth_wake_irq not found
[    2.429197] ipq806x-gmac-dwmac 37000000.ethernet: IRQ eth_lpi not found
[    2.435610] ipq806x-gmac-dwmac 37000000.ethernet: PTP uses main clock
[    2.442412] ipq806x-gmac-dwmac 37000000.ethernet: User ID: 0x10, Synopsys ID: 0x37
[    2.448219] ipq806x-gmac-dwmac 37000000.ethernet:    DWMAC1000
[    2.455797] ipq806x-gmac-dwmac 37000000.ethernet: DMA HW capability register supported
[    2.461568] ipq806x-gmac-dwmac 37000000.ethernet: RX Checksum Offload Engine supported
[    2.469219] ipq806x-gmac-dwmac 37000000.ethernet: COE Type 2
[    2.477184] ipq806x-gmac-dwmac 37000000.ethernet: TX Checksum insertion supported
[    2.482994] ipq806x-gmac-dwmac 37000000.ethernet: Wake-Up On Lan supported
[    2.490369] ipq806x-gmac-dwmac 37000000.ethernet: Enhanced/Alternate descriptors
[    2.497081] ipq806x-gmac-dwmac 37000000.ethernet: Enabled extended descriptors
[    2.504706] ipq806x-gmac-dwmac 37000000.ethernet: Ring mode enabled
[    2.511746] ipq806x-gmac-dwmac 37000000.ethernet: Enable RX Mitigation via HW Watchdog Timer
[    2.591067] ipq806x-gmac-dwmac 37200000.ethernet: IRQ eth_wake_irq not found
[    2.591118] ipq806x-gmac-dwmac 37200000.ethernet: IRQ eth_lpi not found
[    2.597420] ipq806x-gmac-dwmac 37200000.ethernet: PTP uses main clock
[    2.604045] ipq806x-gmac-dwmac 37200000.ethernet: User ID: 0x10, Synopsys ID: 0x37
[    2.610229] ipq806x-gmac-dwmac 37200000.ethernet:    DWMAC1000
[    2.617598] ipq806x-gmac-dwmac 37200000.ethernet: DMA HW capability register supported
[    2.623496] ipq806x-gmac-dwmac 37200000.ethernet: RX Checksum Offload Engine supported
[    2.631214] ipq806x-gmac-dwmac 37200000.ethernet: COE Type 2
[    2.639035] ipq806x-gmac-dwmac 37200000.ethernet: TX Checksum insertion supported
[    2.644941] ipq806x-gmac-dwmac 37200000.ethernet: Wake-Up On Lan supported
[    2.652317] ipq806x-gmac-dwmac 37200000.ethernet: Enhanced/Alternate descriptors
[    2.659000] ipq806x-gmac-dwmac 37200000.ethernet: Enabled extended descriptors
[    2.666623] ipq806x-gmac-dwmac 37200000.ethernet: Ring mode enabled
[    2.673651] ipq806x-gmac-dwmac 37200000.ethernet: Enable RX Mitigation via HW Watchdog Timer

...

[   29.854351] ipq806x-gmac-dwmac 37000000.ethernet eth0: PHY [37000000.mdio-mii:01] driver [Qualcomm Atheros AR8035] (irq=POLL)
[   29.860003] dwmac1000: Master AXI performs any burst length
[   29.864638] ipq806x-gmac-dwmac 37000000.ethernet eth0: No Safety Features support found
[   29.880137] ipq806x-gmac-dwmac 37000000.ethernet eth0: IEEE 1588-2008 Advanced Timestamp supported
[   29.880290] ipq806x-gmac-dwmac 37000000.ethernet eth0: registered PTP clock
[   29.887995] ipq806x-gmac-dwmac 37000000.ethernet eth0: configuring for phy/rgmii link mode
[   29.899522] br-lan: port 1(eth0) entered blocking state
[   29.903274] br-lan: port 1(eth0) entered disabled state
[   29.908487] device eth0 entered promiscuous mode
[   30.005726] ipq806x-gmac-dwmac 37200000.ethernet eth1: PHY [37000000.mdio-mii:00] driver [Qualcomm Atheros AR8035] (irq=POLL)
[   30.210062] ipq806x-gmac-dwmac 37200000.ethernet: Failed to reset the dma
[   30.210094] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
[   30.215833] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_open: Hw setup failed
[   30.227402] br-lan: port 2(eth1) entered blocking state
[   30.232882] br-lan: port 2(eth1) entered disabled state
[   30.238130] device eth1 entered promiscuous mode
[   32.022125] ipq806x-gmac-dwmac 37000000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
[   32.022212] br-lan: port 1(eth0) entered blocking state
[   32.030107] br-lan: port 1(eth0) entered forwarding state

but no throughput on eth0.

gmac settings
&mdio0 {
	status = "okay";

	pinctrl-0 = <&mdio0_pins>;
	pinctrl-names = "default";

	phy0: ethernet-phy@0 {
		reg = <0>;
	};

	phy1: ethernet-phy@1 {
		reg = <1>;
	};
};

&gmac0 {
	status = "okay";

	phy-mode = "rgmii";
	qcom,id = <0>;
	mdiobus = <&mdio0>;
	phy-handle = <&phy1>;

	qcom,phy-mdio-addr = <0x01>;

	qcom,poll-required = <0x01>;
	qcom,rgmii-delay = <0x01>;
};

&gmac1 {
	status = "okay";

	phy-mode = "rgmii";
	qcom,id = <1>;
	mdiobus = <&mdio0>;
	phy-handle = <&phy0>;

	qcom,phy-mdio-addr = <0x00>;

	qcom,poll-required = <0x01>;
	qcom,rgmii-delay = <0x01>;
};

Curiously, I could also force the DMA reset error on eth0 by unplugging the cable, setting iwconfig eth0 down and up, it would not init correctly but give the same DMA error as eth1 on boot. After re-plugging the cable, iwconfig eth0 up will make it initialize correctly again.

Looking at the code in https://elixir.bootlin.com/linux/latest/source/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c#L2903 was not quite helpful, maybe some attributes are missing to the __priv, so the callback does not work for dma reset?

@2in2 @minhng99 did you succeed in uploading via bootloader tftp using LAN2? For me booting initramfs only works when using LAN1... (maybe the LAN2 port of my device is just broken :joy: )

Regarding the bootloader, I could not find a way to reliably backup / restore the environment partition on spi-nor (the flash does not seem to be memory-mapped as in ath79, so I could not use md to dump it, or at least I did not yet find the start offset), so I did not yet dare to boot ap161 or anything else yet, still wondering in which ways it could break the bootloader though.

That's intersting. For me I can only boot via TFTP using LAN2. So, now only having LAN1 working, I'm stuck.

Guys i'm interested in this as i'm a fan of old nokia brand, bought one from ebay to play with. When i get mine i can play with it, have ch341 programmer and also multivoltage uart interface. Thanks

1 Like

Random discovery I made.
Since I could no longer use tftpboot, I tried using bootp, that somehow worked.
After trying a bunch of builds, managed to break bootp and tftpboot started working again.
Current state, got WiFi working (both 2.4Ghz and 5Ghz), PoE ethernet port still broken, LAN1 works (still has to have a forced link), no nand.

Edit 1: In U-Boot, the PoE port can connect and talk to a 100Mbps interface, trying a 1Gig interface, doesn't work.

Edit 2: Despite everything on the PCB itself pointing at the interface being gigabit, forcing it to run at 100Mbps, got it to work inside OpenWRT.
So, now we have both network interfaces working.

Edit 3: Even when forced to run at 100Mbps, when plugged into a gigabit port that will try to auto-negotiate, it will advertise itself as being gigabit capable and fail to establish a connection. This happens both in U-Boot and OpenWRT, setting the other end to 100Mbps, fixes the problem.
I assume we can somehow change the advertised options, to make it more compatible with other gear?

This reminds me of having the same issue with ath79 devices using Atheros Gigabit PHYs, this always required some fiddling with the PLL timing values (c.f. AR8021 phy not working in gigabit mode; how to configure pll-data cells?).
But for some devices, in that case DAP-2360 with AR72xx SoC, as far as I recall, even setting a fixed-link with speed = <100>; did not work (as this would require communication to the PHY via MDIO), not sure if that's the problem here though.

I'm currently working on Mediatek devices, everything is slightly different there (also everything is DSA), but as soon as these are done, I will switch back to QCA and give this one another try. Maybe even the ath79 devices I couldn't get working in Gigabit mode will suddenly work after switching to the qca8k DSA driver :joy: )

Got Gigabit working on both ports in OpenWRT.
Back to figuring out flash.

Edit 1: My current DTS, if anyone wants to try and figure out how to add partitions to it:
https://gist.github.com/krusic22/549479c13803f0a8bc31bd93a7c99e79

From what I can tell, I'm missing kernel, ubi_rootfs and rootfs_data.

Edit 2: I updated the gist.
"Everything" works now including installing.
The only problem is the device randomly switching into partB mode and booting the original firmware again.

That sounds awesome, I hope I can give this another try in the coming days :slightly_smiling_face:

Since you are setting a fixed speed of 1000 here, is communication with the PHY actually working, i.e. does also 100BASE-T Fast Ethernet work with these dts settings?

It can get full 1000 working on both (in OpenWRT).
So, no 100BASE-T doesn't work, except if you change the DTS.

Anyway, currently finishing up LEDs, then I'll publish my repo.

There we go. Most things are working.
Still some things to figure out:
How to get 2.4Ghz working from LuCI,
Possibly set ETH0 as WAN/POE,
Whatever weird thing the LEDs have going on.

I think there should indeed be a declaration in base-files/etc/board.d/02_network, I can't recall whether I tried this in my branch, but it seems even this target (with DSA) would still need it.

1 Like

Noticed that I forgot to add it to my commit.
I will fix it on the master branch.
But, personally, I think that the POE port should be WAN by default (currently, it's reversed).

I remember we had this discussion on github when adding DAP-3662, eventually it was suggested that both ports should be LAN, since this was consistent with the stock firmware (and this is by default an Access Point, not a router) and the user should just create a WAN interface and map it to one of the ports in case they need it.

In the course of that, it was found that the hack used to correct ethernet MAC address resulted in all the user-created new interfaces using a randomized mac on every boot... but at least this can not happen here since we can set it in dts for the gmac node / eth device, not just for the resulting lan / wan interface :innocent: .

There we go. Rebased on latest master.
Still has the same issues as before, we have to decide on WAN/LAN ports.
Having both as LAN sounds ideal.

LEDs being weird.
U-Boot randomly deciding to switch to PartB mode... I really can't figure out how to make it go back to PartA mode.

Edit 1: So, on every reboot PKRstCnt gets incremented. Once it hits 5, the partitions switch.
Tried using fw_setenv PKRstCnt 0 to reset it, but it didn't work.

Edit 2: Since I can't take care of it in the OS, we can just add another step to the installation.

set bootcmd "setenv PKRstCnt 0; saveenv; bootipq"
setenv

This will reset the counter to 0 on every reboot.