Controlling LEDs through a 74x164 shift register

Well,you cant export it again as its already exported.
Just simply go to /sys/class/leds and you will see lan and wan.
Its weird that power LED does not work automatically since aliases are set.

target/linux/ipq806x/base-files/etc/board.d/01_leds is right place to set various trigger for LEDs.
While default on/off should be done in DTS.

WiFi looks weird since I cant see that variant is printed at all.

The /sys/class/leds interface behaves the same way as when I was trying directly with the GPIO62:
root@OpenWrt:/# echo 0 > /sys/class/leds/wac510:green:wan/brightness
root@OpenWrt:/# echo 1 > /sys/class/leds/wac510:green:wan/brightness
root@OpenWrt:/# [ 79.764534] ess_edma c080000.edma: eth1: GMAC Link is down
[ 80.804751] ess_edma c080000.edma: eth1: GMAC Link is up with phy_speed=1000
root@OpenWrt:/#

And then the WAN LED starts working as expected..

This is how Netgear initialise the WAN/LAN ports:

ssdk_sh looks like it's part of the qcom ath10k sdk toolkit.

I see the aliases for the power LEDs in the DTS. From my limited experience, they look like all the other LED aliases I can find in other DTS's, so I assume there are no errors there. I can toggle the LEDs using the /sys/class/leds interface, but the kernel does not toggle either the green or amber automatically. Uboot sets the amber LED on boot, then the kernel clears it once it's loaded up. All I can assume is that GPIO62 is not an LED, rather the control line for the WAN port, and somehow by resetting it, the kernel sees it and behaves normally.

I've tried the other GPIO's on the shift register and they all cause the gpio module to crash when I try to export them.

WiFi
I've noticed that the wifi chip variant is not printed if the correct entry is found in board-2.bin. If I push over my pre-cal bin files, for some reason it stops it loading the BDF's from board-2.bin. This is a modprobe ath10k_pci with my own pre-cal bin files, and firmware-5.bin copied to firmware-6.bin:
root@OpenWrt:~# modprobe ath10k_pci
[ 95.758388] ath10k_ahb a000000.wifi: qca4019 hw1.0 target 0x01000000 chip_id 0x003b00ff sub 0000:0000
[ 95.758495] ath10k_ahb a000000.wifi: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1
[ 95.786914] ath10k_ahb a000000.wifi: firmware ver 10.4-3.4-00104 api 6 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps crc32 6c332c67
[ 95.829478] ath10k_ahb a000000.wifi: failed to fetch board data for bus=ahb,bmi-chip-id=0,bmi-board-id=31,variant=Netgear-WAC510 from ath10k/QCA4019/hw1.0/board-2.bin
[ 95.829860] ath10k_ahb a000000.wifi: Direct firmware load for ath10k/QCA4019/hw1.0/board.bin failed with error -2
[ 95.843472] ath10k_ahb a000000.wifi: Falling back to user helper
[ 95.948654] firmware ath10k!QCA4019!hw1.0!board.bin: firmware_loading_store: map pages failed
[ 95.949109] ath10k_ahb a000000.wifi: failed to fetch board-2.bin or board.bin from ath10k/QCA4019/hw1.0
[ 95.956366] ath10k_ahb a000000.wifi: failed to fetch board file: -11
[ 95.966025] ath10k_ahb a000000.wifi: could not probe fw (-11)
[ 96.158103] ath10k_ahb a800000.wifi: qca4019 hw1.0 target 0x01000000 chip_id 0x003b00ff sub 0000:0000
[ 96.158211] ath10k_ahb a800000.wifi: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1
[ 96.186708] ath10k_ahb a800000.wifi: firmware ver 10.4-3.4-00104 api 6 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps crc32 6c332c67
[ 96.229316] ath10k_ahb a800000.wifi: failed to fetch board data for bus=ahb,bmi-chip-id=0,bmi-board-id=31,variant=Netgear-WAC510 from ath10k/QCA4019/hw1.0/board-2.bin
[ 96.229700] ath10k_ahb a800000.wifi: Direct firmware load for ath10k/QCA4019/hw1.0/board.bin failed with error -2
[ 96.243321] ath10k_ahb a800000.wifi: Falling back to user helper
[ 96.343921] firmware ath10k!QCA4019!hw1.0!board.bin: firmware_loading_store: map pages failed
[ 96.344581] ath10k_ahb a800000.wifi: failed to fetch board-2.bin or board.bin from ath10k/QCA4019/hw1.0
[ 96.351467] ath10k_ahb a800000.wifi: failed to fetch board file: -11
[ 96.360990] ath10k_ahb a800000.wifi: could not probe fw (-11)
root@OpenWrt:~#

I assume then, that the pre-cal files in the initramfs are not the same as my ones. You mentioned before that they are automatically extracted from the ART partition and that Netgear use standard offsets? Where are they defined? Can I check them?

Tim

Ok, so we gotta figure out how to pull GPIO62 high after everything else is initialized.
That can be done in init scripts.
Netgear just sets separate VLANs for LAN and WAN ports and that's it.

You cant do that stuff to aht10k driver.
Helper script in OpenWRT will load calibration for both radios from flash.

Like I previously said,firmware-6.bin error is normal as QCA4018/9 does not use firmware-6.bin at all.
Can you send me a dump of 0:ART partition and all BDFs you have.
It could be that we have been trying with wrong BDFs.

Also,can you tell me which exact code were you compiling because I dont think we are in sync?

Its really hard not having physical access to the hardware

I appreciate that it is difficult to do this remotely - I could send you my device but I'm being selfish and learning so much from doing this with your help. The info you're giving me I cannot find on Google and is priceless!

Before I compile my initramfs each time I 'git pull' to make sure I pick up any changes you've made.

I've just picked up the DTS changes you've made, and I'm going to try adding a bit into 11-ath10k-caldata to extract the pre-cal data next..

0:ART partition dump and all BDFs will be on github in a few minutes - I'll update here when they're up.

Tim

Great that you are doing git pull,but after a change in DTS or anything related to kernel you must also do make clean.
Otherwise kernel wont be rebuilt and any changes in DTS wont be in the built binary
I already added WAC510 to 11-ath10k-caldata

Ahh.. I've not been doing 'make clean'. Rookie mistake! :persevere:

Tim

I see your wac510 additions to that file now.. Still re-compiling after make clean..

Here's my mtd's:
root@OpenWrt:~# cat /proc/mtd
dev: size erasesize name
mtd0: 00040000 00010000 "0:SBL1"
mtd1: 00020000 00010000 "0:MIBIB"
mtd2: 00060000 00010000 "0:QSEE"
mtd3: 00010000 00010000 "0:CDT"
mtd4: 00010000 00010000 "0:DDRPARAMS"
mtd5: 00010000 00010000 "0:APPSBLENV"
mtd6: 000f0000 00010000 "0:APPSBL"
mtd7: 00010000 00010000 "0:MANUDATA"
mtd8: 00010000 00010000 "0:ART"
mtd9: 03800000 00020000 "rootfs"
root@OpenWrt:~#

mtd8 is here:
https://github.com/7604timo/netgear-wac510/blob/master/mtd8.dd

BDFs are here:

You can see all regarding to WLAN calibrations in this init script of the stock firmware.

And you can see that offsets and size for calibration match ones set in 11-ath10k-caldata

Yes, I see them and I see that you've added the wac510 into the pre-cal extraction script with the same offsets.

But, when I 'diff' my dd extracted pre-cal files and the OpenWrt scripted extracted ones, they differ.

If the offsets are correct, it must be that we're addressing the wrong 0:ART partition?

Tim

How did you you extract you precals?
Since there is only one 0:ART partition it cant be adressing wrong ones

I used dd and the command from the script you linked in.

I'm going to try extracting it again and see if I can manually get the scripted extract or my extract..

Tim

Which command exactly?
Just link a line from gists I linked

Line 102 - this one:

Tim

Well,you can see that command do the same thing as OpenWRT script.
Its just that Netgear used block size of 32 instead of OpenWRTs 1.
At the end they do the exactly same thing with the same offset and size.

So the content is exactly the same.
ART content pretty much always uses the same offsets

Exactly, so why do the extracted files differ and ath10k_pci errors out saying the auto-extracted pre-cal data fails to load? Seems odd.. Can I trust 'diff' to tell me if there's a difference in binary files?

Tim

To which exact error are you reffering to?
[ 95.829860] ath10k_ahb a000000.wifi: Direct firmware load for ath10k/QCA4019/hw1.0/board.bin failed with error -2
[ 95.843472] ath10k_ahb a000000.wifi: Falling back to user helper

This is just telling you that it cant load calibration directly from the radio,but instead relies on helper script in OpenWRT this is normal in built in radios as they dont have EEPROM like mini PCIe modules.

I dont understand why board_data is not loading as it was sucessfuly loading before.

There is an error on bootup with freshly compiled initramfs:
[ 8.244771] ath10k_ahb a000000.wifi: Direct firmware load for ath10k/pre-cal-ahb-a000000.wifi.bin failed with error -2
[ 8.244823] ath10k_ahb a000000.wifi: Falling back to user helper
[ 9.614089] ath10k_ahb a000000.wifi: Direct firmware load for ath10k/QCA4019/hw1.0/firmware-6.bin failed with error -2
[ 9.614133] ath10k_ahb a000000.wifi: Falling back to user helper
[ 9.668314] firmware ath10k!QCA4019!hw1.0!firmware-6.bin: firmware_loading_store: map pages failed
[ 9.670360] ath10k_ahb a000000.wifi: qca4019 hw1.0 target 0x01000000 chip_id 0x003b00ff sub 0000:0000
[ 9.676270] ath10k_ahb a000000.wifi: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1
[ 9.691526] ath10k_ahb a000000.wifi: firmware ver 10.4-3.4-00104 api 5 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps crc32 6c332c67
[ 9.735053] ath10k_ahb a000000.wifi: board_file api 2 bmi_id 0:16 crc32 de67223f
[ 11.077538] ath10k_ahb a000000.wifi: htt-ver 2.2 wmi-op 6 htt-op 4 cal pre-cal-file max-sta 512 raw 0 hwcrypto 1
[ 11.275093] ath10k_ahb a800000.wifi: Direct firmware load for ath10k/pre-cal-ahb-a800000.wifi.bin failed with error -2
[ 11.275148] ath10k_ahb a800000.wifi: Falling back to user helper
[ 12.939686] ath10k_ahb a800000.wifi: Direct firmware load for ath10k/QCA4019/hw1.0/firmware-6.bin failed with error -2
[ 12.939739] ath10k_ahb a800000.wifi: Falling back to user helper
[ 13.010711] firmware ath10k!QCA4019!hw1.0!firmware-6.bin: firmware_loading_store: map pages failed
[ 13.011019] ath10k_ahb a800000.wifi: qca4019 hw1.0 target 0x01000000 chip_id 0x003b00ff sub 0000:0000
[ 13.018684] ath10k_ahb a800000.wifi: kconfig debug 0 debugfs 1 tracing 0 dfs 1 testmode 1
[ 13.036570] ath10k_ahb a800000.wifi: firmware ver 10.4-3.4-00104 api 5 features no-p2p,mfp,peer-flow-ctrl,btcoex-param,allows-mesh-bcast,no-ps crc32 6c332c67
[ 13.077924] ath10k_ahb a800000.wifi: board_file api 2 bmi_id 0:17 crc32 de67223f
[ 14.420767] ath10k_ahb a800000.wifi: htt-ver 2.2 wmi-op 6 htt-op 4 cal pre-cal-file max-sta 512 raw 0 hwcrypto 1

That error goes away if I use my own manually extracted pre-cal data, but then the board's BDF's aren't found.

There is a difference in my extracted pre-cal data and the auto-extracted one:
tim@ITDept002 ~/caldata $ cmp wifi0.caldata.tim wifi0.caldata.openwrt
wifi0.caldata.tim wifi0.caldata.openwrt differ: byte 1, line 1

Could that be causing the issue?

Tim

Take a look at this Jalapeno bootlog:

You will notice the same errors,like I said,direct load errors are normal since we are loading calibration from flash.

Ahh, OK, I see now..

I think the BDFs are loading, but because they're loading successfully it doesn't get reported. When I've been playing around with it, I was always getting BDF loading errors until I found that script which puts the BDFs into the board-2.bin file - then they weren't reported any more.

I can confirm that both radio's are working and I can connect to them using your wac510 branch..

I'll fiddle with the power LED settings in 01_leds and see about adding an init.d script that re-loads eth1 and eth0 to get the LEDs to work.

Once I've done that, you mentioned I can just sysupgrade a sysupgrade binary to permanently install OpenWrt on this, so I'll try that and then add my configs to it and try it out in the Real World..

Tim

I was thinking the same.
We can actually make hotplug script which will check if port is up and if it is simply pull GPIO high.