Adding OpenWrt support for Nokia Airscale AC400i

Hi, I'm trying to add support for a device that you're very unlikely to ever see this device in the wild because it's not for retail but I'm adding OpenWRT support for it, here are some specs about this device:

  • Model name: Nokia Airscale WI4A-AC440i
  • CPU: IPQ8065
  • RAM: 512MB
  • WiFi: 2 x PCIe QCA9984
  • NAND: 128MB containing UBI for rootfs and rootfs_data
  • NOR: 4MB for bootloader, calibration stuffs...
  • Eth: 2x1Gbps integrated GMAC, PoE
  • Misc:
    • 1x USB 2.0
    • 1x microSD slot (not working in stock rom)

The stock ROM is QSDK which based on Kernel 3.14.77 and OpenWrt Chaos Calmer 15.05.1 but the vendor never gave us the source code for it.

Here are some pictures inside the device:

Stuff inside stock ROM:

DTS that I've decompiled from stock firmware:

Stuff from OpenWRT which I've ported and mostly working:

Now I'm having the issue with the ethernet ports, 1 port never worked with OpenWRT no matter how hard I try to tune in the device-tree, the others does work but cannot detect link up/down, I could make it detect link up/down but then it will fail to receive any data from the ethernet ports.

My attempt at porting OpenWRT:

If anyone could help me take a look at this, I'll be greatly appreciated.

Hi,

The stock firmware is using the nss driver including acceleration.
You can see this on your ethernet nodes ("compatible = "qcom,nss-gmac")
But this is only working with the nss driver.

So you have two possibilities:

First one, try the openwrt vanilla approach, have a look at https://github.com/openwrt/openwrt/blob/master/target/linux/ipq806x/files/arch/arm/boot/dts/qcom-ipq8064-ap148.dts

Or you can use the repo von Ansuel including the nss driver + acceleration
https://github.com/Ansuel/openwrt/tree/kernel5.4-nss-qsdk10.0 )
Your dts might be working with that.

Well.. I tried every firmware build for other IPQ806x devices and none of them have 2 ports working, there's only a single port on the right works.

I'll check that repo out, thank you.

Make sure to get your device supported with plain OpenWrt first, NSS is merely an optimzation to achieve >~500 MBit/s - it has no functional component.

Well... I tried for 2 weeks now, copying every other similar board/device tree, tweak values... nothing seems to work :frowning:

@minhng99 did you notice that
both require the poll_required and the rgmii_delay ?
also did you notice that one gmac has mdio addr 0x0 ?
can you post the dts you are currently using?

also consider that probably any settings about poll_required and rgmii_delay could be missing.

I've tried to put in poll_required, rgmii_delay, phy_mdio_addr but nothing help at all.
The strange thing is that in order to have gmac* working then I have to plug an ethernet link to it before the kernel booted, otherwise it will be resulted in initialization failed and will be in a down state permanently.

Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.212448] ipq806x-gmac-dwmac 37000000.ethernet: Failed to reset the dma
Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.212484] ipq806x-gmac-dwmac 37000000.ethernet eth0: stmmac_hw_setup: DMA engine initialization failed
Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.218222] ipq806x-gmac-dwmac 37000000.ethernet eth0: stmmac_open: Hw setup failed
Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.362494] ipq806x-gmac-dwmac 37200000.ethernet: Failed to reset the dma
Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.362530] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_hw_setup: DMA engine initialization failed
Mon Jun 14 20:30:01 2021 kern.err kernel: [   21.368267] ipq806x-gmac-dwmac 37200000.ethernet eth1: stmmac_open: Hw setup failed

also only the gmac1 is working, the gmac0 somehow still can receive my PC's DHCPDISCOVER but my PC doesn't receive the DHCPOFFER that it has sent, I've checked it with Wireshark and there's nothing comes from the AP

My current OpenWrt tree based on master is here: https://github.com/minhng99/openwrt-old/commit/ba8fbc9b498f3d0a8cebc759b35d568ec297a8f5

syslog when both ports are plugged in: https://pastebin.com/SF57cfVH
syslog when none of the port are plugged in: https://pastebin.com/6AhbYug9

as i already said that option are not implemented that could be the problem

So there's no way to fix it for now?
I dont understand what's the difference between my device and another device which also use gmac0 but have their ethernet working?

yes there is... that option just needs to be implemented...
other device probably it works as the bootloader sets the values

Yeah, probably it have something to do with the bootloader also.... only gmac1 is working in bootloader when I tried to ping or tftpboot from it, gmac0 does seem to be able to detect link but it's doesn't respond

Is there an u-boot source code for this SoC with the gmac0 working? I do have an SPI programmer and can test the bootloader to see if it's really the case

&mdio0 {
	status = "okay";

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

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

	phy5: ethernet-phy@5 {
		reg = <5>;
	};
};

&gmac0 {
	status = "okay";

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

&gmac1 {
	status = "okay";

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

can you test with this?

also are you sure they are in rgmii mode and not sgmii mode

I'll test it tomorrow... how do I know which mode they're in? I'm not even sure about those MII stuffs and this is the first time I ported for ipq806x stuff so I'm not really sure what I'm doing, just copy and paste something that I think is correct and hope it will work, heh

considering it's just a device for wifi use... could really be that they just screw up the ethernet implementation... we will test both... we can use the unify device that also use the gmac port with no switch

Yeah... but that gmac0 port is PoE enabled so I really want it working, these device are made per order for an ISP and comes with a fancy cloud controller and stuff... and Nokia probably don't want us to install a custom firmware on it so there might be a chance that they really has screwed up with that port.
I do have the datasheet for ipq806x if you want it

That device have a very good WiFi coverage, it's even much much better than the unifi AP HD

That dts make gmac1 disappeared, gmac0 can detect link up/down now but it's no longer can receive anything

no link on boot: https://pastebin.com/SgKspEQH
both link plugged in on boot: https://pastebin.com/BLRBMTjT

So this is a lost cause? I've even tried the nss gmac implementation but that just crashing on my device and no interface ever came up.

You are correct, it looks like they somehow screwed the gmac0->PHY1 implementation, if I set the fixed-link speed to 100mbps then it's working fine, looks like it would need the rgmii-txid mode for it to work but this is unimplemented in the ipq806x_gmac_set_speed, guess I'll have to wait...

how did you discover that? we can implement that function if you need that.

I didn't noticed the 2 PHY chips on my last teardown... but it's having 2x AR8035, they're connected to the same MDIO bus, both running as rgmii on gmac0 and gmac1...

I've tweaked some stuffs but the gmac0 only working if I set the link speed to 100mbps in the device tree, also the link speed of my PC which connected to its gmac0

I've read some pages talking about rgmii and how mismatched clock and results in either TX or RX not working so I tried the slower 100mbps and it's worked, I suppose the 1000mbps will work if the "rgmii-txid" is implemented

Anyway... it's only kinda half-working... both gmac needs a link that's connected to it before kernel boot up, otherwise it will fail initialization and never come up again