Porting guide ar71xx to ath79?

Are you sure this is realy needed and not encoded in the ath9k eeprom?
Probably this was done because the driver hasn´t access to the nand???
What are the values from debugfs?

cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_mask
cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_val

If they are really required to set manually, you will need a device tree property that is parsed in the of (device tree) init function ath9k_of_init() in drivers/net/wireless/ath/ath9k/init.c like it´s done in the old ath9k_init_platform() for the old mach behavior.

Your dts looks good so far. Can you also post a serial boot log or dmesg?

Starting kernel ...

[    0.000000] Linux version 4.19.115 (ubuntu@ubuntu) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 r12903+10-c30220d458)) #0 Tue Apr 28 16:56:07 2020
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] MIPS: machine is Buffalo WZR-HP-G300NH
[    0.000000] SoC: Atheros AR9132 rev 2
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 04000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Primary instruction cache 64kB, VIPT, 4-way, linesize 32 bytes.
[    0.000000] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 bytes
[    0.000000] Zone ranges:
[    0.000000]   Normal   [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000003ffffff]
[    0.000000] random: get_random_bytes called from start_kernel+0x98/0x4a8 with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16240
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
[    0.000000] Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 57516K/65536K available (4296K kernel code, 183K rwdata, 1016K rodata, 1216K init, 206K bss, 8020K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51
[    0.000000] CPU clock: 400.000 MHz
[    0.000000] clocksource: MIPS: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 9556302233 ns
[    0.000013] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[    0.007904] Calibrating delay loop... 265.98 BogoMIPS (lpj=531968)
[    0.050069] pid_max: default: 32768 minimum: 301
[    0.055047] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.061675] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.075565] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.085348] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.091621] pinctrl core: initialized pinctrl subsystem
[    0.098116] NET: Registered protocol family 16
[    0.142632] clocksource: Switched to clocksource MIPS
[    0.149240] NET: Registered protocol family 2
[    0.154873] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes)
[    0.162652] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.169637] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.176021] TCP: Hash tables configured (established 1024 bind 1024)
[    0.182591] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.188502] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.195269] NET: Registered protocol family 1
[    0.203892] Crashlog allocated RAM at address 0x3f00000
[    0.211087] workingset: timestamp_bits=14 max_order=14 bucket_order=0
[    0.227428] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.233305] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.259671] io scheduler noop registered
[    0.263668] io scheduler deadline registered (default)
[    0.269166] ar7200-usb-phy usb-phy: phy reset is missing
[    0.275746] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    0.283171] console [ttyS0] disabled
[    0.286842] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 9, base_baud = 12500000) is a 8250
[    0.295387] console [ttyS0] enabled
[    0.295387] console [ttyS0] enabled
[    0.302418] bootconsole [early0] disabled
[    0.302418] bootconsole [early0] disabled
[    0.312376] 1e000000.cfi: Found 1 x16 devices at 0x0 in 16-bit bank. Manufacturer ID 0x000001 Chip ID 0x002201
[    0.322529] Amd/Fujitsu Extended Query Table at 0x0040
[    0.327736]   Amd/Fujitsu Extended Query version 1.3.
[    0.332846] number of CFI chips: 1
[    0.342337] Searching for RedBoot partition table in 1e000000.cfi at offset 0x1fa0000
[    0.365833] Searching for RedBoot partition table in 1e000000.cfi at offset 0x1fc0000
[    0.389298] Searching for RedBoot partition table in 1e000000.cfi at offset 0x1fe0000
[    0.412754] No RedBoot partition table detected in 1e000000.cfi
[    0.418883] 5 fixed-partitions partitions found on MTD device 1e000000.cfi
[    0.425836] Creating 5 MTD partitions on "1e000000.cfi":
[    0.431215] 0x000000000000-0x000000040000 : "u-boot"
[    0.437325] 0x000000040000-0x000000060000 : "u-boot-env"
[    0.443826] 0x000000060000-0x000001fc0000 : "firmware"
[    0.452897] 2 uimage-fw partitions found on MTD device firmware
[    0.458931] Creating 2 MTD partitions on "firmware":
[    0.463961] 0x000000000000-0x0000001ba5d2 : "kernel"
[    0.470018] 0x0000001ba5d2-0x000001f60000 : "rootfs"
[    0.476085] mtd: device 4 (rootfs) set to be root filesystem
[    0.481885] 1 squashfs-split partitions found on MTD device rootfs
[    0.488143] 0x000000440000-0x000001f60000 : "rootfs_data"
[    0.494611] 0x000001fc0000-0x000001fe0000 : "user_property"
[    0.501389] 0x000001fe0000-0x000002000000 : "art"
[    0.508042] Realtek RTL8366S ethernet switch driver version 0.2.2
[    0.514350] rtl8366s switch: cannot find mdio bus from bus handle (yet)
[    0.521058] rtl8366s switch: using GPIO pins 19 (SDA) and 20 (SCK)
[    0.527457] rtl8366s switch: RTL8366 ver. 1 chip found
[    0.582251] libphy: switch: probed
[    0.589270] libphy: Fixed MDIO Bus: probed
[    0.912697] libphy: ag71xx_mdio: probed
[    0.918267] ag71xx 19000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    0.928253] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: rgmii
[    1.138629] random: fast init done
[    1.252733] libphy: ag71xx_mdio: probed
[    1.257526] ag71xx 1a000000.eth: connected to PHY at switch:04 [uid=001cc960, driver=Generic PHY]
[    1.267436] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: rgmii
[    1.277089] NET: Registered protocol family 10
[    1.289028] Segment Routing with IPv6
[    1.292967] NET: Registered protocol family 17
[    1.297572] 8021q: 802.1Q VLAN Support v1.8
[    1.311394] VFS: Mounted root (squashfs filesystem) readonly on device 31:4.
[    1.326101] Freeing unused kernel memory: 1216K
[    1.330706] This architecture does not have kernel memory protection.
[    1.337200] Run /sbin/init as init process
[    2.214420] init: Console is alive
[    2.218248] init: - watchdog -
[    3.487832] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    3.598600] usbcore: registered new interface driver usbfs
[    3.604336] usbcore: registered new interface driver hub
[    3.609859] usbcore: registered new device driver usb
[    3.623061] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    3.632000] ehci-platform: EHCI generic platform driver
[    3.637633] ehci-platform 1b000100.usb: EHCI Host Controller
[    3.643436] ehci-platform 1b000100.usb: new USB bus registered, assigned bus number 1
[    3.651473] ehci-platform 1b000100.usb: irq 3, io mem 0x1b000100
[    3.670661] ehci-platform 1b000100.usb: USB 2.0 started, EHCI 1.00
[    3.678068] hub 1-0:1.0: USB hub found
[    3.682478] hub 1-0:1.0: 1 port detected
[    3.688470] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    3.706379] init: - preinit -
[    4.794179] random: procd: uninitialized urandom read (4 bytes read)
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[    7.059687] mount_root: jffs2 not ready yet, using temporary tmpfs overlay
[    7.100513] urandom-seed: Seed file not found (/etc/urandom.seed)
[    7.352686] procd: - early -
[    7.355921] procd: - watchdog -
[    8.040761] procd: - watchdog -
[    8.044463] procd: - ubus -
[    8.141429] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.240159] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.247253] random: ubusd: uninitialized urandom read (4 bytes read)
[    8.255057] procd: - init -
Please press Enter to activate this console.
[    9.341245] kmodloader: loading kernel modules from /etc/modules.d/*
[    9.582149] Loading modules backported from Linux version v5.4.27-0-g585e0cc08069
[    9.589755] Backport generated by backports.git v5.4.27-1-0-gf6e8852f
[    9.676053] xt_time: kernel timezone is -0000
[    9.869153] PPP generic driver version 2.4.2
[    9.888176] NET: Registered protocol family 24
[   10.120059] ieee80211 phy0: Atheros AR9100 MAC/BB Rev:7 AR2133 RF Rev:a2 mem=0xb80c0000, irq=2
[   10.304449] urngd: v1.0.2 started.
[   10.393493] kmodloader: done loading kernel modules from /etc/modules.d/*
[   10.953734] random: crng init done
[   10.957210] random: 6 urandom warning(s) missed due to ratelimiting
[   60.808840] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[   60.830300] jffs2_build_filesystem(): unlocking the mtd device...
[   60.830311] done.
[   60.838554] jffs2_build_filesystem(): erasing all blocks after the end marker...
[   61.025248] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   61.064605] br-lan: port 1(eth0.1) entered blocking state
[   61.070125] br-lan: port 1(eth0.1) entered disabled state
[   61.076071] device eth0.1 entered promiscuous mode
[   61.080953] device eth0 entered promiscuous mode
[   61.119000] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   61.198078] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[   62.047600] eth0: link up (1000Mbps/Full duplex)
[   62.066838] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   62.092929] br-lan: port 1(eth0.1) entered blocking state
[   62.098450] br-lan: port 1(eth0.1) entered forwarding state
[   62.129210] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   64.256340] eth1: link up (1000Mbps/Full duplex)
[   64.270678] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready

BusyBox v1.31.1 () built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 OpenWrt SNAPSHOT, r13090-4209d17c0b
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.

After this I am able to access internet etc, but mount_root just keeps muching on at CPU 100%

Is there a way to configure squashfs/jffs2 somehow? I am thinkg I will be pointing a finger in that direction now. Is there something board/device specific that should be done in the base files?

And is the device entry in image/generic.mk all right?

define Device/buffalo_wzr-hp-g300nh
  SOC := ar9132
  DEVICE_VENDOR := Buffalo
  DEVICE_PACKAGES := kmod-usb-core kmod-usb2 kmod-usb-ledtrig-usbport \
  BLOCKSIZE := 128k
  IMAGE_SIZE := 32128k
  IMAGES += factory.bin tftp.bin
  IMAGE/default := append-kernel | append-rootfs | pad-rootfs | check-size
  IMAGE/factory.bin := $$(IMAGE/default) | buffalo-enc WZR-HP-G300NH 1.99 | \
  buffalo-tag WZR-HP-G300NH 1
  IMAGE/sysupgrade.bin := $$(IMAGE/default) | append-metadata
  IMAGE/tftp.bin := $$(IMAGE/default) | buffalo-tftp-header
  SUPPORTED_DEVICES += wzr-hp-g300nh
TARGET_DEVICES += buffalo_wzr-hp-g300nh

The found end address looks very confusing. Never seen a address of 0x0 before.
Is there any other device with "cfi-flash"?
Does your device boots normally after it stated that everything after 0x0 gets erased?

I assumed it standard behaviour as I purged the old config. JFFS2 portion (rootfs_data) is being prepared. The log 19.07 gives me this:

[ 46.051197] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[ 46.058186] jffs2_build_filesystem(): unlocking the mtd device...
[ 46.058193] done.
[ 166.097389] jffs2: notice: (1242) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[ 166.915966] overlayfs: upper fs does not support tmpfile.

My new one behaves similary but does not get to the end.

Looks like there a plenty of them, just not under 'ath79'. Cannot notice them doing anything differently.

In 19.07 it does. In my own it does not.

Looks like the values do not get set in ath79, but are set by that old routine in ar71xx. Below are current examples of both.

 OpenWrt SNAPSHOT, r13068-71d5a0d92b   (ath79)
root@router2:~# cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_mask
root@router2:~# cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_val
 OpenWrt SNAPSHOT, r13125-d9ff499671   (ar71xx)
root@router2:~# cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_mask
root@router2:~# cat /sys/kernel/debug/ieee80211/phy*/ath9k/gpio_val

Have you seen suitable examples of proprietary device tree wifi properties recently?

I tried two years ago to introduce one for the MAC address tweaking in the 3700 series, but that was disapproved by the devs as they (or at least the reviewer) seemed to frown upon new OpenWrt-specific device tree properties.

I returned to the antenna subject two years after porting the device, as I saw some comments where some users complain about the wndr3800 wifi in ath79:

1 Like

A ugly workaround could be to write this values with echo into debugfs with a script like rc.local...

Sorry no and I haven't a bullet proof suggestion too.
Probably you can ask this on the openwrt or linux mailing list.

As gpio_mask and gpio_val are configurable through platform code, there is also a requirement to add this to the of/dt initialization code.
This shouldn't be openwrt specific, so there are a good chance to get this into the mainline linux, too.

Currently there is only qca,no-eeprom which i know only for ath9k defined:

Probably this can be one little starting point...

A small update on the wzr-hp-g300nh issue. It appears mount_root hangs at this line in overlay.c. It never returns.

ret = mount(v->blk, "/rom/overlay", "jffs2", MS_NOATIME, NULL);

'v->blk' there evaluates to '/dev/mtdblock5'

Trying to mount the same thing at console hangs indefinitely too. The mount process hog all cpu and renders the device almost inoperable. There are problems loading the Luci interface etc. But it connects to internet, though.

Are there known issues with CFI flash and JFFS2?

What puzzles me how it works in ar71xx then. At the end of the day, the ath79 version works other than that it cannot mount the overylay filesystem.

This was the key. I brought over a patch from ar71xx side for cfi cmd set and it's all working now. I read somewhere saying that the said patch was made obsolete by fixing the root cause but apparently not.

That leaves me with the issue of fail safe getting caught every time. How do I configure that? That is, can I configure somehow that pressing only a certain key gets me to failsafe?

The gpio/key with the linux code KEY_RESTART is used for triggering failsave.

If you comment this line, you have disabled the failsave trigger...

The problem was buttons like 'BTN_4' causing the failsafe. But it should be only the KEY_RESTART? That said, which branch is better basis for testing things, master or 19.07?

I made an attempt with PR to add support for wzr-hp-g300nh in 19.07 branch but it was shot down insisting that new devices should go to master. Should this ar71xx-ath79 porting work go to master really?

Yes. All new stuff goes to master.

(19.07 is the stable branch, and not for experimental stuff. New developments, like ath79 support for some device, go to master first. Later they might be backported to the stable branch, but they are first tested in master.)


Is there something different how keys are handled between master and 19.07 branch? When using gpio-keys-polled in 19.07 I get expected results: keys just work and I can enter failsafe by pressing reset key at appropriate point during the boot.

On top of master, with the same change set, I end up in failsafe always.

I was suggested to use gpio-keys instead of gpio-keys-polled but that fails with messages as below.

[ 3.498802] gpio-keys keys: failed to get irq for gpio:504
[ 3.504409] gpio-keys keys: failed to get irq for gpio:505
[ 3.509944] gpio-keys keys: failed to get irq for gpio:506
[ 3.515479] gpio-keys keys: failed to get irq for gpio:507
[ 3.521017] gpio-keys keys: failed to get irq for gpio:509
[ 3.526554] gpio-keys keys: failed to get irq for gpio:510
[ 3.532091] gpio-keys keys: failed to get irq for gpio:511

WZR-HP_G300NH has an gpio expander that does not provide irq interrupts and it must be polled as far as I understood correctly. I was dubious about the change proposal in the first place but I gave it a go just to eliminate possible non-working solutions.

Regarding the WNDR3700v1/v2/3800 wifi antenna gpio values, the issue was extensively debugged in the last few days, and a dts solution was committed as

I mention the commit and the bug report with debugging discussion as reference in case somebody runs into similar needs regarding gpio values.


1 Like

I am trying to compile support for a new device, but am getting an error about missing the .dtb file. It looks like it is not generating it for some reason. On ipq4019 there was a patch file that added the target to the list, is there something like that for ath79? From what I can tell, there is nothing unusual about my code that stands out from the other recent ath79 commits.

mips-openwrt-linux-musl-cpp -nostdinc -x assembler-with-cpp -I/home/nick/Code/nickberry_openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-4.19.123/arch/mips/boot/dts -I/home/nick/Code/nickberry_openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-4.19.123/arch/mips/boot/dts/include -I/home/nick/Code/nickberry_openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/linux-4.19.123/include/ -undef -D__DTS__  -o /home/nick/Code/nickberry_openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/image-_telco_t1.dtb.tmp ../dts/_telco_t1.dts
mips-openwrt-linux-musl-cpp: error: ../dts/_telco_t1.dts: No such file or directory
mips-openwrt-linux-musl-cpp: warning: '-x assembler-with-cpp' after last input file has no effect
mips-openwrt-linux-musl-cpp: fatal error: no input files
compilation terminated.
make[5]: *** [Makefile:83: /home/nick/Code/nickberry_openwrt/openwrt/build_dir/target-mips_24kc_musl/linux-ath79_generic/image-_telco_t1.dtb] Error 1
make[5]: Leaving directory '/home/nick/Code/nickberry_openwrt/openwrt/target/linux/ath79/image'
make[4]: *** [Makefile:20: install] Error 2
make[4]: Leaving directory '/home/nick/Code/nickberry_openwrt/openwrt/target/linux/ath79'
make[3]: *** [Makefile:13: install] Error 2
make[3]: Leaving directory '/home/nick/Code/nickberry_openwrt/openwrt/target/linux'

The dts name is build from your set vars in the image Makefile.


Hope this helps.

1 Like

Yes thank you, I had misnamed the SOC variable in the generic.mk file in the old style as ATH_SOC

Guys please tell me, is that I came across?

I'm looking at ath79 for DIR-825 B1 routers as I need the "fat" images.

Have a question around MAC addresses.

DIR-825 B1, DIR-825 C1 and DIR-835 A1 exhibit behaviour below. Challenge is MAC addresses is in caldata in a non-standard (ASCII) format.

When in boot cycle is the eth0 MAC set, and where should it be adjusted if need be?
/etc/ board.d/02_network?

In ar71xx the eth0 interface is set up with a valid MAC. Like this:

root@OpenWrt:/etc/board.d# ifconfig -a | grep HW
br-lan    Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
eth0      Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
eth0.1    Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
eth1      Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B9  
wlan0     Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
wlan1     Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:BA  

In ath79:

root@OpenWrt:/etc/board.d# ifconfig -a | grep HW
br-lan    Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
eth0      Link encap:Ethernet  HWaddr E6:56:EF:7E:DF:DE  
eth0.1    Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
eth1      Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B9  
wlan0     Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:B8  
wlan1     Link encap:Ethernet  HWaddr 84:C9:B2:6A:2D:BA  

This may just be cosmetic as router works. I'd rather fix it.

Someone posted above or another thread a fix. I don't think this is the way to go, or if so where to put it:

root@OpenWrt:/etc/board.d# ifconfig eth0 down
root@OpenWrt:/etc/board.d# ifconfig eth0 hw ether 84:C9:B2:6A:2D:B8
root@OpenWrt:/etc/board.d# ifconfig eth0 up
root@OpenWrt:/etc/board.d# /etc/init.d/network restart

Any pointers please?