Using release ATH79 19.07.0 kernel and packages on hardware modded TP-Link WR703N (16Mb/64Mb) without SNAPSHOT compilation

I've patched official OpenWrt release 19.07.0 kernel for TP-Link WR703N with resized DTS partition structure to have ability to use release packages without any SNAPSHOT compilation.
With patched kernel you can build any packages configuration with Image Builder. It will be helpfull for owners of hardware moded routers with similar hardware.

You can use precompilled image by link below or build your own package configuration.

Images and kernels for 16Mb flash moded TP-Link WR703N device:
patched_kernel_19.07.0
tp-link_wr703n_19.07.0_images

patched_kernel_19.07.1
tp-link_wr703n_19.07.1_images

If you want to use precompilled image just download and flash it. It includes Luci and USB ASIX network adapter support.

If you want to modify kernel patcher for example 8Mb flash and compile your own build please follow next steps, if no just put patched kernel file into Image Builder and pass stage with python script execution:

Download and unpack image builder

wget https://downloads.openwrt.org/releases/19.07.0/targets/ath79/tiny/openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64.tar.xz
tar xvf openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64.tar.xz
cd openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64

Increase image size

vim ~/openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64/target/linux/ath79/image/tiny-tp-link.mk

define Device/tplink_tl-wr703n
-  $(Device/tplink-4mlzma)
+  $(Device/tplink-16mlzma)
  ATH_SOC := ar9331
  DEVICE_TITLE := TP-Link TL-WR703N
  DEVICE_PACKAGES := kmod-usb-chipidea2
  TPLINK_HWID := 0x07030101
  SUPPORTED_DEVICES += tl-wr703n
endef
TARGET_DEVICES += tplink_tl-wr703n

Put script file 'kernel_patcher.py' into Image Builder folder

#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = "Taras Gavrylenko"
__copyright__ = "Copyright 2020, The OpenWrt Project"
__version__ = "0.9"
__email__ = "gavrylenko.taras@gmail.com"
__status__ = "Beta"

"""
OpenWrt TP-Link WR703N kernel DTS patcher allows to use release 19.07 kernel
and packages on hardware modded devices with increased flash chip size.

Set environment variable $LZMA_UTIL_PATH with path to LZMA utility
Recommended LZMA 4.65 : Igor Pavlov : Public domain : 2009-02-03
from Openwrt originals

Be sure you have Python interpreter 3.8 or higher
Run: python3.8 kernel_patcher.py <path_to_kernel_file>

Script stages:
1. Rename original kernel to *.bak
2. Unpack original kernel
3. Patch DTS partition table
4. Pack new kernel
"""

import argparse
import logging
import os
import subprocess

from pathlib import Path

logging.basicConfig(
    format='%(asctime)s %(levelname)s %(message)s',
    level=logging.INFO)
logger = logging.getLogger(__name__)


def run_command(cmd: str):
    return subprocess.call(cmd, shell=True)


def compress_lzma(lzma_util: str, raw_path: Path, lzma_path: Path) -> int:
    cmd = f'{lzma_util} e {raw_path} {lzma_path} -lc1 -lp2'
    status = run_command(cmd)
    if status != 0:
        raise RuntimeError(f'Failed to compress {raw_path}')
    return lzma_path.stat().st_size


def decompress_lzma(lzma_util: str, lzma_path: Path, raw_path: Path) -> int:
    cmd = f'{lzma_util} d {lzma_path} {raw_path}'
    status = run_command(cmd)
    if status != 0:
        raise RuntimeError(f'Failed to decompress {lzma_path}')
    return raw_path.stat().st_size


def resize_kernel_dts(krnl_path: Path):
    chunk_num = 0
    chunk_size = 64 * 1024
    with krnl_path.open(mode='rb+') as f_out:
        while data := f_out.read(chunk_size):
            if (offset := data.find(b'partition@20000')) > 0:
                ofs_part = chunk_num * chunk_size + offset
                logger.info('Found DTS partition table at: '
                            f'0x{ofs_part:08x}')
                break
            chunk_num += 1
        else:
            raise RuntimeError('Could not find DTS partition table')
        f_out.seek(ofs_part)
        data = bytearray(f_out.read(0x100))
        if (offset := data.find(b'\xaa\0\x02\0\0\0\x3d\0\0')) > 0:
            data[offset+6] |= 0xc0
        else:
            raise RuntimeError('Partition pattern not found')
        if (offset := data.find(b'partition@3f0000')) > 0:
            data[offset+10] = ord('f')
        else:
            raise RuntimeError('Partition pattern not found')
        if (offset := data.find(b'\xaa\0\x3f\0\0\0\x01\0\0')) > 0:
            data[offset+2] |= 0xc0
        else:
            raise RuntimeError('Partition pattern not found')
        f_out.seek(ofs_part)
        f_out.write(data)


def main():
    logger.info('OpenWrt TP-Link WR703N kernel DTS patcher v0.9')

    lzma_util_path = os.getenv('LZMA_UTIL_PATH')
    if lzma_util_path is None:
        logger.error('Compressor utility path is not set: LZMA_UTIL_PATH')
        exit(1)

    parser = argparse.ArgumentParser()
    parser.add_argument('image', help='OpenWrt kernel image file')
    args = parser.parse_args()

    krnl_path = Path(args.image)
    if krnl_path.is_file() is False:
        logger.error(f'Kernel image file does not exist: {krnl_path}')
        exit(1)
    krnl_size = krnl_path.stat().st_size
    logger.info(f'Processing kernel image file: {krnl_path}')
    logger.info(f'Origin kernel size: 0x{krnl_size:08x}')
    kernel_raw_path = Path(krnl_path.with_suffix('.raw'))
    logger.info('Decompressing kernel...')
    krnl_raw_size = decompress_lzma(
        lzma_util_path, krnl_path, kernel_raw_path)
    logger.info(f'Decompressed kernel size: 0x{krnl_raw_size:08x}')
    logger.info('Resizing kernel DTS...')
    resize_kernel_dts(kernel_raw_path)
    krnl_path.rename(krnl_path.with_suffix('.bak'))
    logger.info('Compressing kernel...')
    krnl_lzma_size = compress_lzma(
        lzma_util_path, kernel_raw_path, krnl_path)
    logger.info(f'Compressed kernel size: 0x{krnl_lzma_size:08x}')
    if krnl_lzma_size > krnl_size:
        logger.warning('Re-compressed kernel is bigger than original.')
    logger.info('Done')


if __name__ == '__main__':
    main()

Set environment variable $LZMA_UTIL_PATH with path to LZMA utility

Recommended LZMA 4.65 : Igor Pavlov : Public domain : 2009-02-03 from Openwrt originals

Run script. Be sure you have Python interpreter version >= 3.8

python3.8 kernel_patcher.py ~/openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ath79_tiny/tplink_tl-wr703n-kernel.bin

If there is no error on previous step, build new image

make image PROFILE=tplink_tl-wr703n PACKAGES="uhttpd luci luci-ssl kmod-usb-net-asix kmod-usb-storage"

...
[mktplinkfw] rootfs offset aligned to 0x1424964
[mktplinkfw] firmware file "~/openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ath79_tiny/tmp/openwrt-19.07.0-ath79-tiny-tplink_tl-wr703n-squashfs-sysupgrade.bin.new" completed
5067+1 records in
5067+1 records out
2594796 bytes (2.6 MB, 2.5 MiB) copied, 0.0184814 s, 140 MB/s
[mktplinkfw] rootfs offset aligned to 0x1424964
[mktplinkfw] firmware file "~/openwrt-imagebuilder-19.07.0-ath79-tiny.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ath79_tiny/tmp/openwrt-19.07.0-ath79-tiny-tplink_tl-wr703n-squashfs-factory.bin.new" completed

Flash appropriate image into your router and have fun. Forget to save SNAPSHOT compiled packages :wink:

***************************************
*     U-Boot 1.1.4-7a540a78-clean     *
*          Build: 2018-02-23          *
***************************************

** Warning: bad env CRC, using default,
   use 'saveenv' to save it in FLASH

  BOARD: TP-Link TL-WR703N v1
    SOC: AR9330 rev. 1
    CPU: MIPS 24Kc
    RAM: 64 MB DDR1 16-bit CL3-3-3-8
  FLASH: 16 MB Winbond W25Q128
    MAC: 14:CF:92:BA:A2:7F
 CLOCKS: CPU/RAM/AHB/SPI/REF
         400/400/200/ 25/ 25 MHz

Hit any key to stop booting:  0

Booting image from 0x9F020000...

   Vendor/image name:    OpenWrt r10860-a3ffeb413b
   Hardware ID:          0x7030101
   Whole image size:     7.8 MB (8126464 bytes)
   Kernel size:          1.4 MB (1424449 bytes)
   Rootfs size:          2.5 MB (2594808 bytes)
   Kernel load address:  0x80060000
   Kernel entry point:   0x80060000

   Header CRC...  skipped
   Data CRC...    skipped

Stopping network... OK!
Uncompressing Kernel... OK!
Starting kernel...

[    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-WR703N
[    0.000000] SoC: Atheros AR9330 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=ttyATH0,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.000014] sched_clock: 32 bits at 200MHz, resolution 5ns, wraps every 10737418237ns
[    0.007914] Calibrating delay loop... 265.42 BogoMIPS (lpj=1327104)
[    0.092720] pid_max: default: 32768 minimum: 301
[    0.097654] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.103979] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.116931] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.125382] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.131538] pinctrl core: initialized pinctrl subsystem
[    0.140169] NET: Registered protocol family 16
[    0.175968] clocksource: Switched to clocksource MIPS
[    0.181211] NET: Registered protocol family 2
[    0.185470] TCP established hash table entries: 1024 (order: 0, 4096 bytes)
[    0.191170] TCP bind hash table entries: 1024 (order: 0, 4096 bytes)
[    0.197492] TCP: Hash tables configured (established 1024 bind 1024)
[    0.204010] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.209694] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.216250] NET: Registered protocol family 1
[    0.225949] Crashlog allocated RAM at address 0x3f00000
[    0.231733] workingset: timestamp_bits=30 max_order=14 bucket_order=0
[    0.245164] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.249618] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.273681] io scheduler noop registered
[    0.276226] io scheduler deadline registered (default)
[    0.281811] ar7200-usb-phy usb-phy: phy reset is missing
[    0.287326] pinctrl-single 18040028.pinmux: 64 pins at pa b8040028 size 8
[    0.294823] Serial: 8250/16550 driver, 16 ports, IRQ sharing enabled
[    0.303691] 18020000.uart: ttyATH0 at MMIO 0x18020000 (irq = 9, base_baud = 1562500) is a AR933X UART
[    0.311956] console [ttyATH0] enabled
[    0.311956] console [ttyATH0] enabled
[    0.318778] bootconsole [early0] disabled
[    0.318778] bootconsole [early0] disabled
[    0.349961] m25p80 spi0.0: w25q128 (16384 Kbytes)
[    0.353275] 3 fixed-partitions partitions found on MTD device spi0.0
[    0.359589] Creating 3 MTD partitions on "spi0.0":
[    0.364345] 0x000000000000-0x000000020000 : "u-boot"
[    0.370581] 0x000000020000-0x000000ff0000 : "firmware"
[    0.375771] 2 tplink-fw partitions found on MTD device firmware
[    0.380386] Creating 2 MTD partitions on "firmware":
[    0.385265] 0x000000000000-0x00000015be41 : "kernel"
[    0.391346] 0x00000015be44-0x000000fd0000 : "rootfs"
[    0.396279] mtd: device 3 (rootfs) set to be root filesystem
[    0.400828] 1 squashfs-split partitions found on MTD device rootfs
[    0.407023] 0x0000003e0000-0x000000fd0000 : "rootfs_data"
[    0.413520] 0x000000ff0000-0x000001000000 : "art"
[    0.419280] libphy: Fixed MDIO Bus: probed
[    0.756451] libphy: ag71xx_mdio: probed
[    0.759838] libphy: ar8xxx-mdio: probed
[    0.765326] switch0: Atheros AR724X/AR933X built-in rev. 2 switch registered on mdio-bus.0
[    1.147720] ag71xx 19000000.eth: connected to PHY at mdio-bus.0:1f:04 [uid=004dd041, driver=Generic PHY]
[    1.156791] eth0: Atheros AG71xx at 0xb9000000, irq 4, mode: mii
[    1.164743] NET: Registered protocol family 10
[    1.174090] Segment Routing with IPv6
[    1.176551] NET: Registered protocol family 17
[    1.180811] bridge: filtering via arp/ip/ip6tables is no longer available by default. Update your scripts to load br_netfilter if you need this.
[    1.194583] 8021q: 802.1Q VLAN Support v1.8
[    1.201548] usb_vbus: disabling
[    1.212067] VFS: Mounted root (squashfs filesystem) readonly on device 31:3.
[    1.226915] Freeing unused kernel memory: 1188K
[    1.229983] This architecture does not have kernel memory protection.
[    2.555986] random: fast init done
[    3.931778] init: Console is alive
[    3.934064] init: - watchdog -
[    5.792046] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    6.136381] usbcore: registered new interface driver usbfs
[    6.140546] usbcore: registered new interface driver hub
[    6.145835] usbcore: registered new device driver usb
[    6.161636] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[    6.174905] ci_hdrc ci_hdrc.0: EHCI Host Controller
[    6.178455] ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
[    6.205990] ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
[    6.211197] hub 1-0:1.0: USB hub found
[    6.214183] hub 1-0:1.0: 1 port detected
[    6.230302] SCSI subsystem initialized
[    6.243616] usbcore: registered new interface driver usb-storage
[    6.249542] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    6.258913] init: - preinit -
[    7.584085] random: jshn: uninitialized urandom read (4 bytes read)
[    8.044837] random: jshn: uninitialized urandom read (4 bytes read)
[    8.101201] random: jshn: uninitialized urandom read (4 bytes read)
[    8.397010] IPv6: ADDRCONF(NETDEV_UP): eth0: 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.497896] eth0: link up (100Mbps/Full duplex)
[   10.501016] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
[   12.056534] mount_root: jffs2 not ready yet, using temporary tmpfs overlay
[   12.104682] urandom-seed: Seed file not found (/etc/urandom.seed)
[   12.546448] eth0: link down
[   12.566726] procd: - early -
[   12.568297] procd: - watchdog -
[   13.494501] procd: - watchdog -
[   13.496780] procd: - ubus -
[   13.928219] urandom_read: 5 callbacks suppressed
[   13.928232] random: ubusd: uninitialized urandom read (4 bytes read)
[   13.942235] random: ubusd: uninitialized urandom read (4 bytes read)
[   13.949430] procd: - init -
Please press Enter to activate this console.
[   15.406367] kmodloader: loading kernel modules from /etc/modules.d/*
[   15.433106] ip6_tables: (C) 2000-2006 Netfilter Core Team
[   15.468704] Loading modules backported from Linux version v4.19.85-0-gc63ee2939dc1
[   15.474826] Backport generated by backports.git v4.19.85-1-0-g8a8be258
[   15.499676] ip_tables: (C) 2000-2006 Netfilter Core Team
[   15.526972] nf_conntrack version 0.5.0 (1024 buckets, 4096 max)
[   15.719100] xt_time: kernel timezone is -0000
[   15.729456] usbcore: registered new interface driver asix
[   15.894010] PPP generic driver version 2.4.2
[   15.907545] NET: Registered protocol family 24
[   16.042810] ieee80211 phy0: Atheros AR9330 Rev:1 mem=0xb8100000, irq=2
[   16.146582] kmodloader: done loading kernel modules from /etc/modules.d/*
[   16.357454] urngd: v1.0.2 started.
[   17.450356] random: crng init done
[   66.170530] br-lan: port 1(eth0) entered blocking state
[   66.174316] br-lan: port 1(eth0) entered disabled state
[   66.180094] device eth0 entered promiscuous mode
[   66.226238] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready
[   68.258012] eth0: link up (10Mbps/Full duplex)
[   68.261066] br-lan: port 1(eth0) entered blocking state
[   68.266286] br-lan: port 1(eth0) entered forwarding state
[   68.316112] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready
[   71.536683] eth0: link down
[   71.538971] br-lan: port 1(eth0) entered disabled state
[   73.617998] eth0: link up (100Mbps/Full duplex)
[   73.621143] br-lan: port 1(eth0) entered blocking state
[   73.626359] br-lan: port 1(eth0) entered forwarding state
[   81.547922] jffs2_scan_eraseblock(): End of filesystem marker found at 0x0
[   81.553402] jffs2_build_filesystem(): unlocking the mtd device...
[   81.556566] done.
[   81.563210] jffs2_build_filesystem(): erasing all blocks after the end marker...
[  120.756026] done.
[  120.764023] jffs2: notice: (1429) jffs2_build_xattr_subsystem: complete building xattr subsystem, 0 of xdatum (0 unchecked, 0 orphan) and 0 of xref (0 dead, 0 orphan) found.
[  121.080236] overlayfs: upper fs does not support tmpfile.


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

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt 19.07.0, r10860-a3ffeb413b
 -----------------------------------------------------
=== 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.
--------------------------------------------------
root@OpenWrt:/# cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00020000 00010000 "u-boot"
mtd1: 00fd0000 00010000 "firmware"
mtd2: 0015be41 00010000 "kernel"
mtd3: 00e741bc 00010000 "rootfs"
mtd4: 00bf0000 00010000 "rootfs_data"
mtd5: 00010000 00010000 "art"
root@OpenWrt:/# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 3.0M      3.0M         0 100% /rom
tmpfs                    29.4M     56.0K     29.3M   0% /tmp
tmpfs                    29.4M     64.0K     29.3M   0% /tmp/root
tmpfs                   512.0K         0    512.0K   0% /dev
/dev/mtdblock4           11.9M    488.0K     11.5M   4% /overlay
overlayfs:/overlay       11.9M    488.0K     11.5M   4% /
root@OpenWrt:/#
1 Like

Dear Tarask1n,

I have TL-WR1043ND v1 modded to 16Mb Flash (and 64MB ram).
As "ar71xx uses dynamic partition table in case of your device which is no longer available in ath79 target".

Can your "kernel_patcher.py" script file to be used with my device?

What I found:
1043nd is by default: $(Device/tplink-8m), no lzma
i can make a $(Device/tplink-16m) definition and use it in the .mk configuration, but
i "think" this way the script is not compatible.

Or can i set to $(Device/tplink-16mlzma) ?

Thank You!

Dear @keleticsaba,

In case of your router it is not so simply as in case with WR703N. Your router has precompilled loader in kernel module + OpenWrt kernel packed with lzma. You should not replace 16m with 16mlzma and vice versa, because it is a different technology of forming kernel module. If you familiar with restore the bricked router I will spend some time to analyze how the kernel module is packed and write other script for your model.

1 Like

Dear Tarask1n!
I have a tl866ii plus universal programer, so i can re-flash bricked unit offline.
Thank you for your help!

Ps, also have a usb-ttl converter ... somewhere.

  1. Download ImageBuilder_19.07.1
  2. Unpack ImageBuilder - tar xvf openwrt-imagebuilder-19.07.1-ath79-generic.Linux-x86_64.tar.xz
  3. Download, rename and replace kernel image (~/openwrt-imagebuilder-19.07.1-ath79-generic.Linux-x86_64/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_tl-wr1043nd-v1-kernel.bin)
    tplink_tl-wr1043nd-v1-kernel_19.07.1_16mb
  4. Replace $(Device/tplink-8m) with $(Device/tplink-16m) in image definition file
  5. Build your own image make image PROFILE=tplink_tl-wr1043nd-v1

Crossfingers

P.S. I've got no factory image was built when I replaced $(Device/tplink-8m) with $(Device/tplink-16m).
But if I leave default $(Device/tplink-8m) I successfully build an image. Try it anyway.

taras@taras-VirtualBox:~/openwrt-imagebuilder-19.07.1-ath79-generic.Linux-x86_64$ ls -la build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/
total 11612
drwxr-xr-x 2 taras taras    4096 feb  3 22:26 .
drwxr-xr-x 4 taras taras   20480 feb  3 22:20 ..
-rw-r--r-- 1 taras taras 8126464 feb  3 22:26 openwrt-19.07.1-ath79-generic-tplink_tl-wr1043nd-v1-squashfs-factory.bin
-rw-r--r-- 1 taras taras 3735822 feb  3 22:26 openwrt-19.07.1-ath79-generic-tplink_tl-wr1043nd-v1-squashfs-sysupgrade.bin
1 Like

It is done.
This thing is working. (I think, even the ART partition was came back, i have wifi.)

Made a few changes in the generic and common tp-link definition file. (added 16M definition).
Factory image was built. (Not tested by me.)
Sysupgrade image was bulit. (Personaly i used this, after a "failed" openwrt-ath97-sysupgrade.)

http://s000.tinyupload.com/index.php?file_id=63999568473426190687

Thank you!

Had one problem:
In the definition file i added luci, but it was compiled without it (?why?), had to add trought ssh.

I'm glad that all works fine for you. Not all definition files are used during ImageBuilder work. You should add required packages through command line. Example

make image PROFILE=tplink_tl-wr1043nd-v1 PACKAGES="luci luci-ssl"

Put Like to topic post, if you wish.

1 Like

Dear Tarask1n,

I am planing to refresh https://openwrt.org/toh/tp-link/tl-wr1043nd "Flash Mod" section regarding the new ATH79 target informations. (no overlay autoresize, ATH79 build instructions, ect)

My question is:
When new/updated openwrt version came out to the device (1043NDv1/ATH79), how can the user get/produce the 16M modified kernel?

@keleticsaba, I'll write the similar 'kernel_patcher' script for 1043ND devices on weekend. Great that you could confirm what that method works for other devices. I'm thinking about some universal solution script, but I'm not sure that we will have big enough amount of volunteers who can test that approach on other devices.

1 Like

I have discovered a much universal way to generate kernel with modified device tree as described here.

@Tarask1n, could you scriptify this rather than making your script device specific?

@Hirsupp The way you proposed requires linux kernel re-compilation. It requires much more resources. My way is much more simpler just patch kernel without any compilation.

@keleticsaba As I promised the script for TP-Link wr1043nd v1:
tl_wr1043nd_v1_kernel_patcher

taras@taras-VirtualBox:~/openwrt_extender$ python3.8 wr1043v1_kernel_patcher.py tplink_tl-wr1043nd-v1-kernel.bin 
2020-02-08 08:32:23,446 INFO TP-Link WR1043 v1 Openwrt kernel DTS partition resizer v 0.9
2020-02-08 08:32:23,449 INFO Processing kernel image file: tplink_tl-wr1043nd-v1-kernel.bin
2020-02-08 08:32:23,449 INFO Build info:  MIPS OpenWrt Linux-4.14.167
2020-02-08 08:32:23,449 INFO Kernel ofs:  0x00001e40
2020-02-08 08:32:23,449 INFO Kernel size: 0x00185868
2020-02-08 08:32:23,449 INFO Extracting kernel...
2020-02-08 08:32:23,455 INFO Decompressing kernel...
2020-02-08 08:32:23,619 INFO Decompressed kernel size: 0x004c6d88
2020-02-08 08:32:23,619 INFO Resizing kernel DTS...
2020-02-08 08:32:23,622 INFO Found DTS partition table at: 0x004c63c4
2020-02-08 08:32:23,622 INFO Compressing kernel...
2020-02-08 08:32:26,295 INFO Compressed kernel size: 0x00185869
2020-02-08 08:32:26,296 WARNING Re-compressed kernel is bigger than original.
2020-02-08 08:32:26,296 INFO Assembling new image...
2020-02-08 08:32:26,297 INFO Done

Thank You!

I am trying to replicate the method, but (i have to confess) i am a bit of noob in linux/openwrt.
(And my goal is to make an "Avarage Joe" howto to the openwrt 1043 wiki.)
On ubuntu bionic, updated pyton3 to 3.8 using snap update ... no problemo. (evaded shity ppa's)

But i am in trouble with the recommended lzma utility "LZMA 4.65 : Igor Pavlov".
The one I found is on sourceforge/7zip (version 4.65 is popular), but it is MS .exe and source files.
Could you help a bit?

Seting the env value is not that complicated as i googled.

where is the origin dts to modify if compile from source?

@keleticsaba I suggested the LZMA SDK is used from that repository LZMA SDK 4.65 with patches from here OpenWrt LZMA SDK patches.

Originally I cloned OpenWrt current repository and make menuconfig. In this case you can find the LZMA utility by path ~/openwrt/build_dir/host/lzma-4.65/CPP/7zip/Compress/LZMA_Alone/lzma_alone/lzma

1 Like

@youxiaojie You can find DTS description at OpenWrt repository OpenWrt ath79 dts. Look for your corresponding model description file <your_router_model>.dtsi

Success!
Now, next week I can update the wiki.
The hardest part for a beginner is to compile the openwrt patched lzma utility.
... so many missing package

1 Like

19.07.2 Tplink tl-wr703n 16/64Mb

Can't get work my modded wr703n 16/64Mb. After flashing your firmware I get fast blinking led. Laptop can't get ip from router via ethernet, so I can't get connection with it. Same result with image and kernel 19.07.0, 19.07.1, 19.07.2 patched by myself or from attachments.
So I try to make my own patch for compiling from source of official repository:

diff --git a/target/linux/ath79/dts/ar9331_tplink_tl-wr703n_tl-mr10u.dtsi b/target/linux/ath79/dts/ar9331_tplink_tl-wr703n_tl-mr10u.dtsi
index 2bacd08245..e821eab264 100644
--- a/target/linux/ath79/dts/ar9331_tplink_tl-wr703n_tl-mr10u.dtsi
+++ b/target/linux/ath79/dts/ar9331_tplink_tl-wr703n_tl-mr10u.dtsi
@@ -67,12 +67,12 @@
 
 			partition@20000 {
 				compatible = "tplink,firmware";
-				reg = <0x20000 0x3d0000>;
+				reg = <0x20000 0xfd0000>;
 				label = "firmware";
 			};
 
-			art: partition@3f0000 {
-				reg = <0x3f0000 0x10000>;
+			art: partition@ff0000 {
+				reg = <0xff0000 0x10000>;
 				label = "art";
 				read-only;
 			};
diff --git a/target/linux/ath79/image/tiny-tp-link.mk b/target/linux/ath79/image/tiny-tp-link.mk
index c533de3f4c..96d6664df6 100644
--- a/target/linux/ath79/image/tiny-tp-link.mk
+++ b/target/linux/ath79/image/tiny-tp-link.mk
@@ -160,7 +160,7 @@ endef
 TARGET_DEVICES += tplink_tl-wa901nd-v2
 
 define Device/tplink_tl-wr703n
-  $(Device/tplink-4mlzma)
+  $(Device/tplink-16mlzma)
   SOC := ar9331
   DEVICE_MODEL := TL-WR703N
   DEVICE_PACKAGES := kmod-usb-chipidea2

All works great but not usb. Can't get usb flash drive or 4g modem working.. Even led on them is not blinking... Any suggestions?