[ath79] DTB update mechanism

I have modded tplink mr3220-v1 device with 128Mbit flash while living happy with ar71xx target.
Than ath79 comes. Okay. I say welcome and installed but. It doesn't recognize partition tables. I learn that I need to update it since it doesn't automatically detect at all. (Why drop that feature? I don't know)

Okay, I changed required sections at DTS file, rebuild image with image builder and... Nothing happen. After I realize that image builder doesn't care DTS, or DTB files!

So I need to compile kernel. That's okay also. Downloaded SDK, try to compile but. Got some weird errors. Building from source process is REALLY SICK! This and that make process buggy. (like Cryptographically sign package lists option doesn't allow compilation and generate errors. So why that option is there? ) Even if you are able to compile... Hey, where is the kernel file? It is no where. Wiki pages are old and commands doesn't work proper. Even you follow some commands, compiler produce error and complain some packet while compiling (ruby?)...

Now, trying to produce kernel file with updated dtb/dts for ath79 target for 2 days without any success.

Why it's so hard to generate new DTB files from source while building with Image Builder?

Could you please tell me how could I produce firmware with updated dts files at least for ath79 target ?
Specially for mr3220-v1

This really makes me mad.

https://openwrt.org/docs/guide-developer/build-system/install-buildsystem
https://openwrt.org/docs/guide-developer/build-system/use-buildsystem

I tried this multiple times. Something is wrong. Don't know what is the real issue. :confused:

So I decide replace dtb at image builder kernel image.
But patch-dtb can't be found DTB section on provided kernel at image-builder vmlinux file..

Here is a some users able to do it but it doesn't work now. DTS support in imagebuilder:. DTS support in imagebuilder

Edit: Fixed crazy forum behaviour...

Here is another easy hack to give you the full flash size on 128Mbit (16MByte)

  1. Download image builder openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64.tar.xz
  2. Extract it: tar xf openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64.tar.xz
  3. Change working dir into it: cd openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64
  4. Change line 35 in target/linux/ath79/image/tiny-tp-link.mk from $(Device/tplink-4m) to $(Device/tplink-16m)
  5. Install device-tree-compiler: sudo apt-get install device-tree-compiler
  6. Put new size for firmware partition into compiled dtb file: fdtput -t x ./build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb /ahb/spi@1f000000/flash@0/partitions/partition@20000/ reg 20000 fd0000
  7. Put new offset for art partition into dtb: fdtput -t x ./build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb /ahb/spi@1f000000/flash@0/partitions/partition@3f0000/ reg ff0000 10000
  8. Build hacked/fixed image: make image PROFILE="tplink_tl-mr3220-v1"
  9. Flash it :slight_smile: and have fun
3 Likes

Oh! That's sound good. Thank you for showing how to patch binary dts patching directly.
But do you believe that if its work? I think not.

There are some errors on this for proper solution.

  1. 3ff0000 makes 64MB. For 16MB Flash, I use 0xff0000 instead 0x3ff0000
  2. /ahb/spi@1f000000/flash@0/partitions/partition@ 3f 0000/ points reg ff 0000 now? Does this ok? Looks like an error to me.
  3. Are you sure about if DTB files are used when building image? I ask because even if I delete all dtb files, image compiles without any single error. Means DTBs are not used at all on image building. I think tplink_tl-mr3220-v1-kernel.bin file is used directly. So don't we also need to update kernel.bin with this DTB file?
    Thank you.

Sorry wrong calculation... You are right... Have changed it in my step by step guide.

partition@3f0000 is only a name and can be named as you like, but if you want to rename it then you have to drop the node and add it with completely new with all properties.
So let it as it are as it isn´t important!

Test it and you will see...

Hi, I gotta brick here :smiley:

...
Autobooting in 1 seconds
## Booting image at 9f020000 ...
   Uncompressing Kernel Image ... Error: Bad gzipped data
GUNZIP ERROR - must RESET board to recover

Resetting...

Issue popup due step 4 at your guide, $(Device/tplink-16m) responsible from brick.
God, thanks for being HW guy, this doesn't a problem for me. I have got 4-5 spare TTL RS232-USB adapter for MCUs.:slight_smile:

Correct setting is $(Device/tplink-8m) . Which works without any issue. Is I understand 16m is 16mlzma indeed. Also factory image doesn't created with tplink-16m setting... Just sysupgrade file built. Anyway...

DTB patching works? Nope. As I suspected and said before, still same partition table detected via kernel. Here is dmesg

...
[    0.446235] Creating 3 MTD partitions on "spi0.0":
[    0.451091] 0x000000000000-0x000000020000 : "u-boot"
[    0.457322] 0x000000020000-0x0000003f0000 : "firmware"
[    0.463924] 2 tplink-fw partitions found on MTD device firmware
[    0.469965] Creating 2 MTD partitions on "firmware":
[    0.474987] 0x000000000000-0x00000015dd51 : "kernel"
[    0.481127] 0x00000015dd54-0x0000003d0000 : "rootfs"
[    0.487229] mtd: device 3 (rootfs) set to be root filesystem
[    0.493053] 1 squashfs-split partitions found on MTD device rootfs
[    0.499298] 0x0000003a0000-0x0000003d0000 : "rootfs_data"
[    0.505844] 0x0000003f0000-0x000000400000 : "art"
...

I believe we also need to patch kernel.bin for add new dtb

Ah step 7, last address need to be 100000. (one zero is missing at your guide.)

1 Like

Seems so...

kernel-bin = vmlinux
append-dtb = image-ar7241_tplink_tl-mr3220-v1.dtb
lzma = ./staging_dir/host/bin/lzma e -lc1 -lp2 -pb2
uImage = ./staging_dir/host/bin/mkimage -A mips -O linux -T kernel -C lzma -a 0x80060000 -e 0x80060000 -n "OpenWRT Linux" -M 0x4f4b4c49 -d
loader-okli = loader-tplink_tl-mr3220-v1.gz

So try something like:

$ cd path/to/image-builder-root/
$ mv build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin.org
$ cat build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb > build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb
$ ./staging_dir/host/bin/lzma e -lc1 -lp2 -pb2 build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.lzma
$ dd if=build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz bs=7680 conv=sync of=build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz.padded
$ ./staging_dir/host/bin/mkimage -A mips -O linux -T kernel -C lzma -a 0x80060000 -e 0x80060000 -n "OpenWRT Linux" -M 0x4f4b4c49 -d build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.lzma build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.uImage
$ cat build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz.padded build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.uImage > build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin

Don´t forget to fix dtb before this!

It does produce the same output with binwalk:

$ binwalk build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin.org

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             gzip compressed data, maximum compression, from Unix, last modified: 1970-01-01 00:00:00 (null date)
7744          0x1E40          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 4454620 bytes
$ binwalk build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             gzip compressed data, maximum compression, from Unix, last modified: 1970-01-01 00:00:00 (null date)
7744          0x1E40          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 4454620 bytes

EDIT: Updated step with mkimage

And its work!
Thank you for support.
FYI: compile from source doesn't work due I use SDK file to compile it...

All steps in one;

  • Change line 35 in target/linux/ath79/image/tiny-tp-link.mk from $(Device/tplink-4m) to $(Device/tplink-8m)
  • Install device-tree-compiler: sudo apt-get install device-tree-compiler
  • Put new size for firmware partition into compiled dtb file: fdtput -t x ./build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb /ahb/spi@1f000000/flash@0/partitions/partition@20000/ reg 20000 fd0000
  • Put new offset for art partition into dtb: fdtput -t x ./build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb /ahb/spi@1f000000/flash@0/partitions/partition@3f0000/ reg ff0000 10000
  • Upgrade new flash speed from 25Mhz to 104Mhz: fdtput -t x ./build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb /ahb/spi@1f000000/flash@0/ spi-max-frequency 0x632ea00
  • $ mv build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin.org
  • $ cat build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb > build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb
  • $ ./staging_dir/host/bin/lzma e -lc1 -lp2 -pb2 build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.lzma
  • $ dd if=build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz bs=7680 conv=sync of=build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz.padded
  • $ ./staging_dir/host/bin/mkimage -A mips -O linux -T kernel -C lzma -a 0x80060000 -e 0x80060000 -n "OpenWRT Linux" -M 0x4f4b4c49 -d build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.lzma build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.uImage
  • $ cat build_dir/target-mips_24kc_musl/linux-ath79_tiny/loader-tplink_tl-mr3220-v1.gz.padded build_dir/target-mips_24kc_musl/linux-ath79_tiny/vmlinux-with-dtb.uImage > build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-mr3220-v1-kernel.bin
  • Build hacked/fixed image: make image PROFILE="tplink_tl-mr3220-v1" PACKAGES="uhttpd luci"

Thanks!

2 Likes

Again, I have a problem.
Now, the wireless doesn't work at all.
I also verify that my art partition has proper MD5.
I insall pciutils and found the device:

root@OpenWrt:/etc/config# lspci
00:00.0 Ethernet controller: Qualcomm Atheros AR5008 Wireless Network Adapter (rev 01)

Here is dmesg output.
Comparing with my old dmeg log, it doesn't show any line for ath.
What it could be the problem?

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.162 (builder@buildhost) (gcc version 7.5.0 (OpenWrt GCC 7.5.0 r10860-a3ffeb413b)) #0 Mon Jan 6 16:47:09 2020
[    0.000000] bootconsole [early0] enabled
[    0.000000] CPU0 revision is: 00019374 (MIPS 24Kc)
[    0.000000] MIPS: machine is TP-Link TL-MR3220 v1
[    0.000000] SoC: Atheros AR7241 rev 1
[    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 0x804776ec with crng_init=0
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 16256
[    0.000000] Kernel command line: console=ttyS0,115200 rootfstype=squashfs,jffs2
[    0.000000] PID hash table entries: 256 (order: -2, 1024 bytes)
[    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: 58924K/65536K available (3544K kernel code, 144K rwdata, 492K rodata, 1188K init, 203K bss, 6612K 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.007919] Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)
[    0.094168] pid_max: default: 32768 minimum: 301
[    0.099097] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.105700] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.118912] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.128790] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.134995] pinctrl core: initialized pinctrl subsystem
[    0.143670] NET: Registered protocol family 16
[    0.152059] PCI host bridge /ahb/apb/pcie-controller@180c0000 ranges:
[    0.158512]  MEM 0x0000000010000000..0x0000000013ffffff
[    0.163791]   IO 0x0000000000000000..0x0000000000000000
[    0.194459] PCI host bridge to bus 0000:00
[    0.198577] pci_bus 0000:00: root bus resource [mem 0x10000000-0x13ffffff]
[    0.205482] pci_bus 0000:00: root bus resource [io  0x0000]
[    0.211042] pci_bus 0000:00: root bus resource [??? 0x00000000 flags 0x0]
[    0.217828] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff]
[    0.226433] pci 0000:00:00.0: BAR 0: assigned [mem 0x10000000-0x1000ffff 64bit]
[    0.237956] clocksource: Switched to clocksource MIPS
[    0.244636] NET: Registered protocol family 2
[    0.250363] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.257347] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.263776] TCP: Hash tables configured (established 1024 bind 1024)
[    0.270360] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.276215] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.282870] NET: Registered protocol family 1
[    0.291675] Crashlog allocated RAM at address 0x3f00000
[    0.298887] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.313876] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.319760] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.343697] io scheduler noop registered
[    0.347624] io scheduler deadline registered (default)
[    0.353318] ar7200-usb-phy usb-phy: phy reset is missing
[    0.359340] pinctrl-single 18040028.pinmux: 64 pins at pa b8040028 size 8
[    0.366807] gpio-export gpio-export: 1 gpio(s) exported
[    0.373206] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.383392] console [ttyS0] disabled
[    0.387027] 18020000.uart: ttyS0 at MMIO 0x18020000 (irq = 9, base_baud = 12500000) is a 16550A
[    0.395783] console [ttyS0] enabled
[    0.395783] console [ttyS0] enabled
[    0.402809] bootconsole [early0] disabled
[    0.402809] bootconsole [early0] disabled
[    0.435061] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.439893] 3 fixed-partitions partitions found on MTD device spi0.0
[    0.446280] Creating 3 MTD partitions on "spi0.0":
[    0.451135] 0x000000000000-0x000000020000 : "u-boot"
[    0.457365] 0x000000020000-0x000000ff0000 : "firmware"
[    0.463968] 2 tplink-fw partitions found on MTD device firmware
[    0.470009] Creating 2 MTD partitions on "firmware":
[    0.475030] 0x000000000000-0x00000015dd52 : "kernel"
[    0.481171] 0x00000015dd54-0x000000fd0000 : "rootfs"
[    0.487272] mtd: device 3 (rootfs) set to be root filesystem
[    0.493095] 1 squashfs-split partitions found on MTD device rootfs
[    0.499342] 0x0000003a0000-0x000000fd0000 : "rootfs_data"
[    0.505887] 0x000000ff0000-0x000001000000 : "art"
[    0.512826] libphy: Fixed MDIO Bus: probed
[    0.517694] ag71xx 19000000.eth: invalid MAC address, using random address
[    0.859094] ag71xx 19000000.eth: Could not connect to PHY device. Deferring probe.
[    0.867095] ag71xx 1a000000.eth: invalid MAC address, using random address
[    1.548401] libphy: ag71xx_mdio: probed
[    1.553285] libphy: ar8xxx-mdio: probed
[    1.560162] switch0: Atheros AR724X/AR933X built-in rev. 2 switch registered on mdio-bus.0
[    1.613898] ag71xx 1a000000.eth: connected to PHY at fixed-0:00 [uid=00000000, driver=Generic PHY]
[    1.623958] eth0: Atheros AG71xx at 0xba000000, irq 5, mode: gmii
[    1.633467] NET: Registered protocol family 10
[    1.645110] Segment Routing with IPv6
[    1.649027] NET: Registered protocol family 17
[    1.653565] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    1.667425] 8021q: 802.1Q VLAN Support v1.8
[    1.674228] ag71xx 19000000.eth: invalid MAC address, using random address
[    2.019679] ag71xx 19000000.eth: connected to PHY at mdio-bus.0:1f:04 [uid=004dd041, driver=Generic PHY]
[    2.030638] eth1: Atheros AG71xx at 0xb9000000, irq 4, mode: mii
[    2.045915] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    2.062809] Freeing unused kernel memory: 1188K
[    2.067371] This architecture does not have kernel memory protection.
[    2.547971] random: fast init done
[    3.743553] init: Console is alive
[    3.747281] init: - watchdog -
[    5.609360] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    5.951703] usbcore: registered new interface driver usbfs
[    5.957333] usbcore: registered new interface driver hub
[    5.962899] usbcore: registered new device driver usb
[    5.976241] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    5.985230] ehci-platform: EHCI generic platform driver
[    5.990916] ehci-platform 1b000000.usb: EHCI Host Controller
[    5.996704] ehci-platform 1b000000.usb: new USB bus registered, assigned bus number 1
[    6.004812] ehci-platform 1b000000.usb: irq 3, io mem 0x1b000000
[    6.038013] ehci-platform 1b000000.usb: USB 2.0 started, EHCI 1.00
[    6.045511] hub 1-0:1.0: USB hub found
[    6.049866] hub 1-0:1.0: 1 port detected
[    6.055921] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    6.066025] init: - preinit -
[    7.534783] random: jshn: uninitialized urandom read (4 bytes read)
[    7.985057] random: jshn: uninitialized urandom read (4 bytes read)
[    8.233795] random: jshn: uninitialized urandom read (4 bytes read)
[    8.629604] urandom_read: 3 callbacks suppressed
[    8.629616] random: jshn: uninitialized urandom read (4 bytes read)
[   10.004499] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   10.010573] IPv6: ADDRCONF(NETDEV_UP): eth0.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
[   10.116171] random: procd: uninitialized urandom read (4 bytes read)
[   11.069130] eth0: link up (1000Mbps/Full duplex)
[   11.073823] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   11.080916] IPv6: ADDRCONF(NETDEV_CHANGE): eth0.1: link becomes ready
[   14.067642] mount_root: jffs2 not ready yet, using temporary tmpfs overlay
[   14.111015] urandom-seed: Seed file not found (/etc/urandom.seed)
[   14.154022] eth0: link down
[   14.184921] procd: - early -
[   14.189053] procd: - watchdog -
[   15.109964] procd: - watchdog -
[   15.113554] procd: - ubus -
[   16.051509] random: ubusd: uninitialized urandom read (4 bytes read)
[   16.378519] random: ubusd: uninitialized urandom read (4 bytes read)
[   16.386964] procd: - init -
Please press Enter to activate this console.
[   17.510298] kmodloader: loading kernel modules from /etc/modules.d/*
[   17.541634] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   17.582218] Loading modules backported from Linux version v4.19.85-0-gc63ee2939dc1
[   17.589916] Backport generated by backports.git v4.19.85-1-0-g8a8be258
[   17.611436] ip_tables: (C) 2000-2006 Netfilter Core Team
[   17.639550] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[   17.706679] urngd: v1.0.0 started.
[   17.812779] xt_time: kernel timezone is -0000
[   17.965367] PPP generic driver version 2.4.2
[   17.989347] NET: Registered protocol family 24
[   18.088624] kmodloader: done loading kernel modules from /etc/modules.d/*
[   18.223751] random: crng init done
[   52.653436] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[   52.673882] jffs2_build_filesystem(): unlocking the mtd device... 
[   52.673963] done.
[   52.682202] jffs2_build_filesystem(): erasing all blocks after the end marker... 
[   53.858555] IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
[   53.873216] eth0: link up (1000Mbps/Full duplex)
[   53.877881] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   53.929106] br-lan: port 1(eth0.1) entered blocking state
[   53.934559] br-lan: port 1(eth0.1) entered disabled state
[   53.940536] device eth0.1 entered promiscuous mode
[   53.945364] device eth0 entered promiscuous mode
[   54.025796] br-lan: port 1(eth0.1) entered blocking state
[   54.031317] br-lan: port 1(eth0.1) entered forwarding state
[   54.037238] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   54.173323] IPv6: ADDRCONF(NETDEV_UP): eth1: link is not ready
[   54.908909] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready

Can you post the ouput of
$ fdtdump build_dir/target-mips_24kc_musl/linux-ath79_tiny/image-ar7241_tplink_tl-mr3220-v1.dtb
from inside the image builder path?
I wanna like to see a dump of your modified dtb.

Here it is:

**** fdtdump is a low-level debugging tool, not meant for general use.
**** If you want to decompile a dtb, you probably want
****     dtc -I dtb -O dts <filename>

/dts-v1/;
// magic:		0xd00dfeed
// totalsize:		0x1b98 (7064)
// off_dt_struct:	0x38
// off_dt_strings:	0x17c0
// off_mem_rsvmap:	0x28
// version:		17
// last_comp_version:	16
// boot_cpuid_phys:	0x0
// size_dt_strings:	0x3d8
// size_dt_struct:	0x1788

/ {
    #address-cells = <0x00000001>;
    #size-cells = <0x00000001>;
    compatible = "tplink,tl-mr3220-v1", "qca,ar7241";
    model = "TP-Link TL-MR3220 v1";
    interrupt-controller {
        compatible = "qca,ar7100-cpu-intc";
        interrupt-controller;
        #interrupt-cells = <0x00000001>;
        qca,ddr-wb-channel-interrupts = <0x00000002 0x00000003 0x00000004 0x00000005>;
        qca,ddr-wb-channels = <0x00000001 0x00000003 0x00000001 0x00000002 0x00000001 0x00000000 0x00000001 0x00000001>;
        linux,phandle = <0x00000002>;
        phandle = <0x00000002>;
    };
    ahb {
        compatible = "simple-bus";
        ranges;
        #address-cells = <0x00000001>;
        #size-cells = <0x00000001>;
        interrupt-parent = <0x00000002>;
        apb {
            compatible = "simple-bus";
            ranges;
            #address-cells = <0x00000001>;
            #size-cells = <0x00000001>;
            interrupt-parent = <0x00000003>;
            interrupt-controller@18060010 {
                compatible = "qca,ar7240-misc-intc";
                reg = <0x18060010 0x00000004>;
                interrupt-parent = <0x00000002>;
                interrupts = <0x00000006>;
                interrupt-controller;
                #interrupt-cells = <0x00000001>;
                linux,phandle = <0x00000003>;
                phandle = <0x00000003>;
            };
            memory-controller@18000000 {
                compatible = "qca,ar9132-ddr-controller", "qca,ar7240-ddr-controller";
                reg = <0x18000000 0x00000100>;
                #qca,ddr-wb-channel-cells = <0x00000001>;
                linux,phandle = <0x00000001>;
                phandle = <0x00000001>;
            };
            uart@18020000 {
                compatible = "ns16550a";
                reg = <0x18020000 0x00000020>;
                interrupts = <0x00000003>;
                clocks = <0x00000004 0x00000002>;
                clock-names = "uart";
                reg-io-width = <0x00000004>;
                reg-shift = <0x00000002>;
                no-loopback-test;
                status = "okay";
            };
            gpio@18040000 {
                compatible = "qca,ar7240-gpio", "qca,ar7100-gpio";
                reg = <0x18040000 0x00000030>;
                interrupts = <0x00000002>;
                ngpios = <0x00000014>;
                gpio-controller;
                #gpio-cells = <0x00000002>;
                interrupt-controller;
                #interrupt-cells = <0x00000002>;
                status = "okay";
                linux,phandle = <0x0000000c>;
                phandle = <0x0000000c>;
            };
            pinmux@18040028 {
                compatible = "pinctrl-single";
                reg = <0x18040028 0x00000008>;
                pinctrl-single,bit-per-mux;
                pinctrl-single,register-width = <0x00000020>;
                pinctrl-single,function-mask = <0x00000001>;
                #pinctrl-cells = <0x00000002>;
                pinmux_jtag_disable_pins {
                    pinctrl-single,bits = <0x00000000 0x00000001 0x00000001>;
                };
            };
            pll-controller@18050000 {
                compatible = "qca,ar7240-pll", "syscon";
                reg = <0x18050000 0x0000003c>;
                clock-names = "ref";
                #clock-cells = <0x00000001>;
                clock-output-names = "cpu", "ddr", "ahb";
                linux,phandle = <0x00000004>;
                phandle = <0x00000004>;
            };
            wdt@18060008 {
                compatible = "qca,ar7130-wdt";
                reg = <0x18060008 0x00000008>;
                interrupts = <0x00000004>;
                clocks = <0x00000004 0x00000002>;
                clock-names = "wdt";
            };
            reset-controller@1806001c {
                compatible = "qca,ar7240-reset", "qca,ar7100-reset";
                reg = <0x1806001c 0x00000004>;
                #reset-cells = <0x00000001>;
                linux,phandle = <0x00000007>;
                phandle = <0x00000007>;
            };
            pcie-controller@180c0000 {
                compatible = "qcom,ar7240-pci";
                #address-cells = <0x00000003>;
                #size-cells = <0x00000002>;
                bus-range = <0x00000000 0x00000000>;
                reg = <0x180c0000 0x00001000 0x180f0000 0x00000100 0x14000000 0x00001000>;
                reg-names = "crp_base", "ctrl_base", "cfg_base";
                ranges = <0x02000000 0x00000000 0x10000000 0x10000000 0x00000000 0x04000000 0x01000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000001>;
                interrupt-parent = <0x00000002>;
                interrupts = <0x00000002>;
                interrupt-controller;
                #interrupt-cells = <0x00000001>;
                interrupt-map-mask = <0x00000000 0x00000000 0x00000000 0x00000001>;
                interrupt-map = <0x00000000 0x00000000 0x00000000 0x00000000 0x00000005 0x00000000>;
                status = "okay";
                linux,phandle = <0x00000005>;
                phandle = <0x00000005>;
                wifi@0,0 {
                    reg = <0x00000000 0x00000000 0x00000000 0x00000000 0x00000000>;
                    #gpio-cells = <0x00000002>;
                    gpio-controller;
                    qca,no-eeprom;
                    mtd-mac-address = <0x00000006 0x0001fc00>;
                    linux,phandle = <0x0000000e>;
                    phandle = <0x0000000e>;
                };
            };
        };
        eth@19000000 {
            status = "okay";
            compatible = "qca,ar7241-eth", "syscon";
            reg = <0x19000000 0x00000200>;
            interrupts = <0x00000004>;
            phy-mode = "mii";
            pll-data = <0x00110000 0x00001099 0x00991099>;
            resets = <0x00000007 0x00000009>;
            reset-names = "mac";
            phy-handle = <0x00000008>;
            mtd-mac-address = <0x00000006 0x0001fc00>;
            mtd-mac-address-increment = <0xffffffff>;
            linux,phandle = <0x00000009>;
            phandle = <0x00000009>;
            mdio-bus {
                status = "disabled";
                compatible = "qca,ath79-mdio";
                #address-cells = <0x00000001>;
                #size-cells = <0x00000000>;
                regmap = <0x00000009>;
                clocks = <0x00000004 0x00000004>;
                clock-names = "ref";
            };
        };
        eth@1a000000 {
            status = "okay";
            compatible = "qca,ar7241-eth", "syscon";
            reg = <0x1a000000 0x00000200>;
            interrupts = <0x00000005>;
            phy-mode = "gmii";
            pll-data = <0x00110000 0x00001099 0x00991099>;
            resets = <0x00000007 0x0000000d>;
            reset-names = "mac";
            mtd-mac-address = <0x00000006 0x0001fc00>;
            mtd-mac-address-increment = <0x00000001>;
            linux,phandle = <0x0000000a>;
            phandle = <0x0000000a>;
            mdio-bus {
                status = "okay";
                compatible = "qca,ath79-mdio";
                #address-cells = <0x00000001>;
                #size-cells = <0x00000000>;
                regmap = <0x0000000a>;
                clocks = <0x00000004 0x00000004>;
                clock-names = "ref";
                resets = <0x00000007 0x00000017>;
                reset-names = "mdio";
                builtin-switch;
                switch0@1f {
                    compatible = "qca,ar7240sw";
                    reg = <0x0000001f>;
                    resets = <0x00000007 0x00000008>;
                    reset-names = "switch";
                    qca,mib-poll-interval = <0x000001f4>;
                    mdio-bus {
                        #address-cells = <0x00000001>;
                        #size-cells = <0x00000000>;
                        ethernet-phy@4 {
                            reg = <0x00000004>;
                            phy-mode = "mii";
                            linux,phandle = <0x00000008>;
                            phandle = <0x00000008>;
                        };
                    };
                };
            };
            fixed-link {
                speed = <0x000003e8>;
                full-duplex;
            };
        };
        spi@1f000000 {
            compatible = "qca,ar7240-spi", "qca,ar7100-spi";
            reg = <0x1f000000 0x00000010>;
            clocks = <0x00000004 0x00000002>;
            clock-names = "ahb";
            status = "okay";
            #address-cells = <0x00000001>;
            #size-cells = <0x00000000>;
            num-cs = <0x00000001>;
            flash@0 {
                compatible = "jedec,spi-nor";
                reg = <0x00000000>;
                spi-max-frequency = <0x017d7840>;
                partitions {
                    compatible = "fixed-partitions";
                    #address-cells = <0x00000001>;
                    #size-cells = <0x00000001>;
                    partition@0 {
                        reg = <0x00000000 0x00020000>;
                        label = "u-boot";
                        read-only;
                        linux,phandle = <0x00000006>;
                        phandle = <0x00000006>;
                    };
                    partition@20000 {
                        compatible = "tplink,firmware";
                        reg = <0x00020000 0x00fd0000>;
                        label = "firmware";
                    };
                    partition@3f0000 {
                        reg = <0x00ff0000 0x00010000>;
                        label = "art";
                        read-only;
                    };
                };
            };
        };
        usb@1b000000 {
            compatible = "generic-ehci";
            reg = <0x1b000000 0x00001000>;
            interrupts = <0x00000003>;
            resets = <0x00000007 0x00000005>;
            reset-names = "usb-host";
            has-transaction-translator;
            caps-offset = <0x00000100>;
            phy-names = "usb-phy";
            phys = <0x0000000b>;
            status = "okay";
            #address-cells = <0x00000001>;
            #size-cells = <0x00000000>;
            port@1 {
                reg = <0x00000001>;
                #trigger-source-cells = <0x00000000>;
                linux,phandle = <0x0000000d>;
                phandle = <0x0000000d>;
            };
        };
    };
    chosen {
        bootargs = "console=ttyS0,115200";
    };
    cpus {
        #address-cells = <0x00000001>;
        #size-cells = <0x00000000>;
        cpu@0 {
            device_type = "cpu";
            compatible = "mips,mips24Kc";
            clocks = <0x00000004 0x00000000>;
            reg = <0x00000000>;
        };
    };
    usb-phy {
        compatible = "qca,ar7200-usb-phy";
        reset-names = "usb-phy", "usb-suspend-override";
        resets = <0x00000007 0x00000004 0x00000007 0x00000003>;
        #phy-cells = <0x00000000>;
        status = "okay";
        linux,phandle = <0x0000000b>;
        phandle = <0x0000000b>;
    };
    aliases {
        led-boot = "/gpio-leds/system";
        led-failsafe = "/gpio-leds/system";
        led-running = "/gpio-leds/system";
        led-upgrade = "/gpio-leds/system";
    };
    keys {
        compatible = "gpio-keys-polled";
        poll-interval = <0x00000014>;
        reset {
            label = "reset";
            linux,code = <0x00000198>;
            gpios = <0x0000000c 0x0000000b 0x00000001>;
            debounce-interval = <0x0000003c>;
        };
        qss {
            label = "qss";
            linux,code = <0x00000211>;
            gpios = <0x0000000c 0x0000000c 0x00000001>;
            debounce-interval = <0x0000003c>;
        };
    };
    gpio-leds {
        compatible = "gpio-leds";
        system {
            label = "tp-link:green:system";
            gpios = <0x0000000c 0x00000001 0x00000001>;
        };
        qss {
            label = "tp-link:green:qss";
            gpios = <0x0000000c 0x00000000 0x00000001>;
        };
        led3g {
            label = "tp-link:green:3g";
            gpios = <0x0000000c 0x00000008 0x00000001>;
            trigger-sources = <0x0000000d>;
            linux,default-trigger = "usbport";
        };
    };
    gpio-export {
        compatible = "gpio-export";
        #size-cells = <0x00000000>;
        gpio_usb_power {
            gpio-export,name = "tp-link:power:usb";
            gpio-export,output = <0x00000001>;
            gpios = <0x0000000c 0x00000006 0x00000000>;
        };
    };
    ath9k-leds {
        compatible = "gpio-leds";
        wlan {
            label = "tp-link:green:wlan";
            gpios = <0x0000000e 0x00000001 0x00000001>;
            linux,default-trigger = "phy0tpt";
        };
    };
};

Seems not good . The node wifi@0,0 is missing the compatible property.
Try to start with a clean dtb file.

2 Likes

Generating a "official" kernel image with modded dtb is key.

I met the same problem as reported in this thread on my wdr4900v2 modded with a 16MiB rom, and I managed to achieve above goal by making use of both image builder and the source tree:

  1. Modify the dts file for the target. (It had better be made a local commit in its own branch, as it can be cherry-picked upon future revisions)
  2. Build a minimalist custom build for the target (which is unlikely to fail, as it is minimalist), to build all the prerequests. The resulted image could even be flashed, in order to confirm the modified device tree works well.
  3. Replace the stripped vmlinux file generated in step 2 (e.g. ${OPENWRT_SRC}/build_dir/target-mips_24kc_musl/linux-ath79_generic/vmlinux ) with the one shipped with image builder ( ${IMGBUILDER}/build_dir/target-mips_24kc_musl/linux-ath79_generic/vmlinux ).
  4. Invoke cd ${OPENWRT_SRC}; make target/install or even make -C ${OPENWRT_SRC} target/install , letting the build system to generate a valid kernel.bin upon the "official" kernel shipped with image builder.
  5. Use image builder to build the flashable image as described above with kernel.bin generated in step 4 ( use ${OPENWRT_SRC}/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wdr4900-v2-initramfs-kernel.bin to replace ${IMGBUILDER}/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_tl-wdr4900-v2-kernel.bin in my case )

This method should be less error-prone, for it uses the original build system to generate kernel.bin, rather than by hand.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.