Determining build source files for a specific target (ar71xx/ath79)

Hi all,

I'm rather new to the OpenWrt build system and in kernel dev as a whole, so still the learning curve is steep.

As a vehicle, I chose to upgrade a WR940NDv1.2 (that's the label on the router itself).


Looking into the forums and documentation, this board matches the WR941NDv4 so, I thought makes sense to configure build using that.

At some stage I wanted to experiment touching source files during kernel boot just for the sake of hello world experience. I tried adding printk() and pr_info() calls in arch/mips/ath79/tl-wr941nd.c files but whatever I did was not reflected in the bootlog. After some trials I noticed that the log file actually says board image is actually WR741ND!

OpenWrt kernel loader for AR7XXX/AR9XXX
Copyright (C) 2011 Gabor Juhos juhosg@openwrt.org
Looking for OpenWrt image... found at 0xbf022000
Decompressing kernel... done!
Starting kernel at 80060000...

[    0.000000] Linux version 4.14.180 () (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r11063-85e04e9f46)) #0 Sat May 16 18:32:20 2020
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] SoC: Atheros AR7240 rev 2
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 02000000 @ 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-0x0000000001ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] random: get_random_bytes called from 0x8042f6ec with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 8128
[    0.000000] Kernel command line: board=**TL-WR741ND**  console=ttyS0,115200 rootfstype=squashfs noinitrd
[    0.000000] PID hash table entries: 128 (order: -3, 512 bytes)
[    0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 27744K/32768K available (3280K kernel code, 168K rwdata, 444K rodata, 196K init, 199K bss, 5024K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS: 51

Of course, when I modified the mach-tl-wr741nd.c file the changes were reflected in the log file as expected. So my question is why would there be a mismatch between menuconfig and the actual build and how could one predetermine which files are going to be built for a specific image?

Thanks,
Dimitar

But it looks like you are trying with the deprecated (= to be removed) ar71xx target, instead of the current ath79 target.

Kernel 4.14 support and ar71xx is to be removed soon.

1 Like

Thanks for the tip, indeed ath79 offers wr941nd-v4 build.
However, I am trying to find board-specific setup code for this router under /target/linux/ath79, like previously when I was using the the linux/ar71xx/files/arch/mips/ath79/mach-tl-wr941nd.c . Any ideas where could that be located?

It is now in the DTS definition... "Devicetree"

Device tl-wr941-v4:
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/dts/ar7240_tplink_tl-wr941-v4.dts;h=c8fe835e7eb22d824ad9846fc7acf1db68d001de;hb=HEAD

Included family "ar7240_tplink_tl-wr":
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/dts/ar7240_tplink_tl-wr.dtsi;h=5ceada8375622675f9b1e0b02960715da0d73a09;hb=HEAD

Included upper family "ar7240_tplink":
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/dts/ar7240_tplink.dtsi;h=de0b36bbf8ea6bd7a2955d8ff494d8daf612ea63;hb=HEAD

Included chip "ar7240":
https://git.openwrt.org/?p=openwrt/openwrt.git;a=blob;f=target/linux/ath79/dts/ar7240.dtsi;h=730c509d7bdf625e61bf8937ab7034e6b11881ee;hb=HEAD

As you see from those, you can piggyback on the common things, and only have a small file where the device-specific differences are.

Example of recent devices:

"TP-Link TL-WR710N v2.1"
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=eb531337a779a48a2d17bc66f0d222325d6c1563

"TP-Link TL-WA801ND v3/v4"
https://git.openwrt.org/?p=openwrt/openwrt.git;a=commitdiff;h=9a477b833ab2aea96b9eee55acb5f9e7b01b36d8;hp=583b3e40254076693eb5227a9d9ae49eb2b0bcbf

You might read the discussions in the ar71xx-->ath79 porting guide thread:

1 Like

I guess that's exactly what I was looking for, thanks for the flash response!

So I've reached the point in migrating the WR941NDv4 to ath79 where I'm a bit stuck. You see, for this board I have replaced the flash chip with 8M and attached USB receptacle, where I was able to mount external usb stick and use it as storage.

For what I understood, in the ath79 platform I need to touch the spi0 section to accomodate larger flash and adjust art partition location and also enable the usb.
So to ar7240_tplink_tl-wr941-v4.dts I added

&spi {
	flash@0 {
		partitions {
			firmware: partition@20000 {
				reg = <0x20000 0x7d0000>;
			};
			art: partition@3f0000 {
				reg = <0x7f0000 0x10000>;
			};
		};
	};
};

and also modified the status field in ar7240.dtsi

/ {
	usb_phy: usb-phy {
....
		status = "enabled";
	};
};

&ahb {
	usb: usb@1b000000 {
....
		status = "enabled";
	};
};

Now, the router boots up, the kernel log shows that USB drivers are loaded, but there is no activity on the usb stick and no device appears as /dev/sd*.

From the menuconfig I've added usb-core, usb2, storage and some filesystem support, but no matter the device I plug in there is no driver response. In the ar71xx I used to register the usb driver via ath79_register_usb() call, but this now should be avoided by use of dts, right?

Has someone had similar issues?

To enable usb you should only reference the node which you wanna modify like:

&usb {
    status = "okay";
};

&usb_phy {
    status = "okay";
};

And there is no "enabled", this is achieved by setting it to "okay".

For further assistance, please post your bootlog from the dmesg command...

Hi,

USB drivers do get registered now

U-Boot 1.1.4 (Mar  8 2010 - 10:35:18)

AP93 (ar7240) U-boot
DRAM:
sri
#### TAP VALUE 1 = 7, 2 = 8
32 MB
id read 0x100000ff
flash size 4194304, sector count = 64
Flash:  4 MB
Using default environment

In:    serial
Out:   serial
Err:   serial
Net:   ag7240_enet_initialize...
No valid address in Flash. Using fixed address
: cfg1 0xf cfg2 0x7014
eth0: 00:03:7f:09:0b:ad
eth0 up
No valid address in Flash. Using fixed address
: cfg1 0xf cfg2 0x7214
eth1: 00:03:7f:09:0b:ad
ATHRS26: resetting s26
ATHRS26: s26 reset done
eth1 up
eth0, eth1
Autobooting in 1 seconds
## Booting image at 9f020000 ...
   Uncompressing Kernel Image ... OK

Starting kernel ...



OpenWrt kernel loader for AR7XXX/AR9XXX
Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>
Looking for OpenWrt image... found at 0xbf022000
Decompressing kernel... done!
Starting kernel at 80060000...

[    0.000000] Linux version 4.14.180 () (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r11063-85e04e9f46)) #0 Sat May 16 18:32:20 2020
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] MIPS: machine is TP-Link TL-WR941N/ND v4
[    0.000000] SoC: Atheros AR7240 rev 2
[    0.000000] Determined physical RAM map:
[    0.000000]  memory: 02000000 @ 00000000 (usable)
[    0.000000] Initrd not found or empty - disabling initrd
[    0.000000] Printing from dt init call
[    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-0x0000000001ffffff]
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000000000000-0x0000000001ffffff]
[    0.000000] random: get_random_bytes called from 0x804456ec with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 8128
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 128 (order: -3, 512 bytes)
[    0.000000] Dentry cache hash table entries: 4096 (order: 2, 16384 bytes)
[    0.000000] Inode-cache hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Writing ErrCtl register=00000000
[    0.000000] Readback ErrCtl register=00000000
[    0.000000] Memory: 26636K/32768K available (3371K kernel code, 133K rwdata, 476K rodata, 1196K init, 195K bss, 6132K 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.000014] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[    0.007908] Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)
[    0.094159] pid_max: default: 32768 minimum: 301
[    0.099074] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.105683] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.118827] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.128699] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.134895] pinctrl core: initialized pinctrl subsystem
[    0.141520] NET: Registered protocol family 16
[    0.149745] PCI host bridge /ahb/apb/pcie-controller@180c0000 ranges:
[    0.156259]  MEM 0x0000000010000000..0x0000000013ffffff
[    0.161473]   IO 0x0000000000000000..0x0000000000000000
[    0.192622] PCI host bridge to bus 0000:00
[    0.196736] pci_bus 0000:00: root bus resource [mem 0x10000000-0x13ffffff]
[    0.203657] pci_bus 0000:00: root bus resource [io  0x0000]
[    0.209218] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    0.215995] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.224640] pci 0000:00:00.0: BAR 0: assigned [mem 0x10000000-0x1000ffff 64bit]
[    0.232892] clocksource: Switched to clocksource MIPS
[    0.239504] NET: Registered protocol family 2
[    0.245105] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.252082] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.258506] TCP: Hash tables configured (established 1024 bind 1024)
[    0.265078] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.270937] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.277593] NET: Registered protocol family 1
[    0.288715] Crashlog allocated RAM at address 0x1f00000
[    0.295936] workingset: timestamp_bits=30 max_order=13 bucket_order=0
[    0.310638] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.316512] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.339989] io scheduler noop registered
[    0.343981] io scheduler deadline registered (default)
[    0.349607] ar7200-usb-phy usb-phy: phy reset is missing
[    0.355600] pinctrl-single 18040028.pinmux: 64 pins at pa b8040028 size 8
[    0.363852] Serial: 8250/16550 driver, 1 ports, IRQ sharing disabled
[    0.371184] console [ttyS0] disabled
[    0.374882] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 9, base_baud = 12500000) is a 16550A
[    0.383602] console [ttyS0] enabled
[    0.383602] console [ttyS0] enabled
[    0.390609] bootconsole [early0] disabled
[    0.390609] bootconsole [early0] disabled
[    0.416632] m25p80 spi0.0: s25fl064k (8192 Kbytes)
[    0.421513] 3 fixed-partitions partitions found on MTD device spi0.0
[    0.427926] Creating 3 MTD partitions on "spi0.0":
[    0.432764] 0x000000000000-0x000000020000 : "u-boot"
[    0.439019] 0x000000020000-0x0000007f0000 : "firmware"
[    0.445614] 2 tplink-fw partitions found on MTD device firmware
[    0.451580] Creating 2 MTD partitions on "firmware":
[    0.456649] 0x000000000000-0x00000014e364 : "kernel"
[    0.462739] 0x00000014e364-0x0000007d0000 : "rootfs"
[    0.468889] mtd: device 3 (rootfs) set to be root filesystem
[    0.474693] 1 squashfs-split partitions found on MTD device rootfs
[    0.480924] 0x000000420000-0x0000007d0000 : "rootfs_data"
[    0.487494] 0x0000007f0000-0x000000800000 : "art"
[    0.494402] libphy: Fixed MDIO Bus: probed
[    0.834897] libphy: ag71xx_mdio: probed
[    0.839738] libphy: ar8xxx-mdio: probed
[    0.846798] switch0: Atheros AR724X/AR933X built-in rev. 2 switch registered on mdio-bus.0
[    0.898344] ag71xx 19000000.eth: connected to PHY at mdio-bus.0:1f:04 [uid=004dd041, driver=Generic PHY]
[    0.908944] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: mii
[    1.254815] ag71xx 1a000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    1.264830] eth1: Atheros AG71xx at 0xba000000, irq 5, mode: gmii
[    1.275056] NET: Registered protocol family 10
[    1.287349] Segment Routing with IPv6
[    1.291180] NET: Registered protocol family 17
[    1.296606] 8021q: 802.1Q VLAN Support v1.8
[    1.310586] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.327739] Freeing unused kernel memory: 1196K
[    1.332299] This architecture does not have kernel memory protection.
[    2.562915] random: fast init done
[    3.997861] init: Console is alive
[    4.001593] init: - watchdog -
[    6.170286] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    6.562444] usbcore: registered new interface driver usbfs
[    6.568176] usbcore: registered new interface driver hub
[    6.573699] usbcore: registered new device driver usb
[    6.623068] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    6.641596] SCSI subsystem initialized
[    6.652164] ehci-platform: EHCI generic platform driver
[    6.660075] ehci-pci: EHCI PCI platform driver
[    6.668322] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[    6.676456] ohci-platform: OHCI generic platform driver
[    6.682029] ohci-platform 1b000000.usb: Generic Platform OHCI controller
[    6.688897] ohci-platform 1b000000.usb: new USB bus registered, assigned bus number 1
[    6.696911] ohci-platform 1b000000.usb: irq 3, io mem 0x1b000000
[    6.778111] hub 1-0:1.0: USB hub found
[    6.782392] hub 1-0:1.0: 1 port detected
[    6.790567] uhci_hcd: USB Universal Host Controller Interface driver
[    6.799612] ohci-pci: OHCI PCI platform driver
[    6.810086] usbcore: registered new interface driver usb-storage
[    6.819700] usbcore: registered new interface driver uas
[    6.825802] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    6.843729] init: - preinit -
[    9.196700] random: jshn: uninitialized urandom read (4 bytes read)
[    9.657164] random: jshn: uninitialized urandom read (4 bytes read)
[    9.978254] random: jshn: uninitialized urandom read (4 bytes read)
[   10.245767] urandom_read: 1 callbacks suppressed
[   10.245779] random: jshn: uninitialized urandom read (4 bytes read)
[   10.341491] random: jshn: uninitialized urandom read (4 bytes read)
[   10.530252] random: jshn: uninitialized urandom read (4 bytes read)
[   11.243856] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[   11.249830] IPv6: ADDRCONF(NETDEV_UP): eth1.1: link is not ready
Press the [f] key and hit [enter] to enter failsafe mode
Press the [1], [2], [3] or [4] key and hit [enter] to select the debug level
[   12.274069] eth1: link up (1000Mbps/Full duplex)
[   12.278767] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[   12.285852] IPv6: ADDRCONF(NETDEV_CHANGE): eth1.1: link becomes ready
[   14.931251] jffs2: notice: (436) jffs2_build_xattr_subsystem: complete building xattr subsystem, 8 of xdatum (2 unchecked, 6 orphan) and 96 of xref (6 dead, 0 orphan) found.
[   14.949694] mount_root: switching to jffs2 overlay
[   14.999714] overlayfs: upper fs does not support tmpfile.
[   15.014580] urandom-seed: Seeding with /etc/urandom.seed
[   15.479886] eth1: link down
[   15.511795] procd: - early -
[   15.514932] procd: - watchdog -
[   16.412965] procd: - watchdog -
[   16.416556] procd: - ubus -
[   16.699573] urandom_read: 1 callbacks suppressed
[   16.699585] random: ubusd: uninitialized urandom read (4 bytes read)
[   16.712446] random: ubusd: uninitialized urandom read (4 bytes read)
[   16.720797] procd: - init -
Please press Enter to activate this console.
[   18.501283] kmodloader: loading kernel modules from /etc/modules.d/*
[   18.526015] ntfs: driver 2.1.32 [Flags: R/O MODULE].
[   18.552369] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   18.570773] Loading modules backported from Linux version v4.19.120-0-gfdc072324f3c
[   18.578563] Backport generated by backports.git v4.19.120-1-0-g60c3a249
[   18.589697] ip_tables: (C) 2000-2006 Netfilter Core Team
[   18.608236] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[   18.707493] xt_time: kernel timezone is -0000
[   18.795837] PPP generic driver version 2.4.2
[   18.803922] NET: Registered protocol family 24
[   18.918182] ath: phy0: Ignoring endianness difference in EEPROM magic bytes.
[   18.948494] ieee80211 phy0: Atheros AR9280 Rev:2 mem=0xb0000000, irq=12
[   19.413515] kmodloader: done loading kernel modules from /etc/modules.d/*
[   20.708398] urngd: v1.0.2 started.
[   21.446474] random: crng init done
[   44.386041] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[   44.393131] eth1: link up (1000Mbps/Full duplex)
[   44.398383] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
[   44.438570] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   47.998750] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[   52.174777] wlan0: authenticate with 00:27:19:d2:dc:c2
[   52.195342] wlan0: send auth to 00:27:19:d2:dc:c2 (try 1/3)
[   52.213267] wlan0: authenticated
[   52.243007] wlan0: associate with 00:27:19:d2:dc:c2 (try 1/3)
[   52.253333] wlan0: RX AssocResp from 00:27:19:d2:dc:c2 (capab=0x431 status=0 aid=3)
[   52.261505] wlan0: associated
[   52.283670] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
[   58.698338] eth0: link up (10Mbps/Full duplex)
[   58.702963] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes

but when I plug in the USB stick I get the following event:

[   66.042927] usb 1-1: new full-speed USB device number 2 using ohci-platform
[   66.332908] ohci-platform 1b000000.usb: frame counter not updating; disabled
[   66.340023] ohci-platform 1b000000.usb: HC died; cleaning up
[   71.073062] usb usb1-port1: attempt power cycle

I've tried adding/removing kmod-usb* modules, but nothing really changed. What could I be missing?

I must admit after a week of tuning attempts I could not resolve this issue. For the time being, I switched back to ar71xx build. The USB driver seems to be stable there.