Help porting ZBT WE826-Q to ath79 target?

Hi, there.
I've been trying to port the ZBT WE826-Q router to use the ath79 build target. By default it comes with a Chaos Calmer OpenWrt image.

I have successfully been using the AP147 reference board ar71xx build which works (with a small change to take account of a hardware watchdog).

I've written the DTS here and I've also added a new device in target/linux/ath79/image/generic.mk:

define Device/zbtlink_zbt-we826q
    SOC := qca9531
    DEVICE_VENDOR := ZBT
    DEVICE_MODEL := WE826Q
    IMAGE_SIZE := 16000k
    DEVICE_PACKAGES := kmod-usb2 kmod-usb-storage
endef
TARGET_DEVICES += zbtlink_zbt-we826q

For now, any sysupgrade image that I build does not boot when I flash it on the device.

Using the default BREED bootloader that comes with the device produces:

DRAM: 128MB
Platform: Qualcomm Atheros QCA953X rev 2
Board: Letv LBA-047-CH
Clocks: CPU: 550MHz, DDR: 400MHz, AHB: 200MHz, Ref: 25MHz
Flash: Winbond W25Q128 (16MB) on ath79-spi
ag71xx-eth: MAC address is invalid, using default settings.
ag71xx-eth: Using MAC address 00:13:74:00:00:01
Waiting for auto-negotiation complete ... OK
eth0: Atheros AR8228/AR8229 rev 1

Network started on eth0, inet addr 192.168.1.1, netmask 255.255.255.0

Press any key to interrupt autoboot ... 0

Unable to locate firmware.

Starting breed built-in shell

breed>

I've tried a couple of other images, and the device completely boots with a TP-Link MR6400 v1 ath79 snapshot image.
If I also use the tplink image commands as below, the kernel is able to boot but experiences a kernel panic when mounting rootfs:

define Device/zbtlink_zbt-we826q
        $(Device/tplink-16mlzma)
        SOC := qca9531
        DEVICE_VENDOR := ZBT
        DEVICE_MODEL := WE826Q
        IMAGE_SIZE := 16000k
        DEVICE_PACKAGES := kmod-usb2 kmod-usb-storage
        SUPPORTED_DEVICES += zbt-we826q
endef

With the above device, I change the dts spi section to:

partition@50000 {
        compatible = "tplink,firmware";
        label = "firmware";
        reg = <0x050000 0xfa0000>;
};

which produces the following boot log: https://paste.debian.net/hidden/43e4827c/

Here's the boot log from the device with its original firmware: https://paste.debian.net/hidden/ec3a7029/

Is there something I'm missing to make this device work on ath79?

Your kernel don't recognize "firmware" partition format and don't spilt it into "kernel", "rootfs" and "rootfs_data".

  1. You configure breed to start firmware at flash offset 0x20000
Trying to boot firmware from 0x9f020000 ...
TP-LINK firmware image header detected.
    Image Name:   00000000
    Data Size:    2148245 Bytes
    Load Address: 80060000
    Entry Point:  80060000
Uncompressing data (LZMA) ... done.

but in your dts-file firmware start at offset 0x50000

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x050000 0xfa0000>;

So correct this setting (reg = <0x20000 0xfa0000>).
2. You don't need explicitly create partitions "kernel" and "rootfs".
Just check that your kernel build config contain at least

CONFIG_MTD_SPLIT=y
CONFIG_MTD_SPLIT_SUPPORT=y
CONFIG_MTD_SPLIT_SQUASHFS_ROOT=y
CONFIG_MTD_SPLIT_TPLINK_FW=y

and corresponding mtdsplitter do this job itself. In other case (if you want vendors like flash partitioning:

[    0.730000] 0x000000000000-0x000000040000 : "u-boot"
[    0.740000] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.750000] 0x000000050000-0x000000e80000 : "rootfs"
[    0.750000] mtd: partition "rootfs" set to be root filesystem
[    0.760000] mtd: partition "rootfs_data" created automatically, ofs=B40000, len=340000
[    0.770000] 0x000000b40000-0x000000e80000 : "rootfs_data"
[    0.770000] 0x000000e80000-0x000000ff0000 : "kernel"
[    0.780000] 0x000000ff0000-0x000001000000 : "art"
[    0.790000] 0x000000050000-0x000000ff0000 : "firmware"

) you have to describe your own rules for building firmware image file too.

Thanks for your reply.
I see what you're saying about the offset, but I've modified the dts to:

uboot: partition@0 {
        label = "u-boot";
        reg = <0x000000 0x020000>;
        read-only;
};
partition@20000 {
        compatible = "denx,uimage";
        label = "firmware";
        reg = <0x020000 0xfd0000>;
};

but I still get the unable to locate firmware message.

From the original ar71xx image the partitions I got were:

[    0.730000] Creating 6 MTD partitions on "spi0.0":
[    0.730000] 0x000000000000-0x000000040000 : "u-boot"
[    0.740000] 0x000000040000-0x000000050000 : "u-boot-env"
[    0.750000] 0x000000050000-0x000000e80000 : "rootfs"
[    0.750000] mtd: partition "rootfs" set to be root filesystem
[    0.760000] mtd: partition "rootfs_data" created automatically, ofs=B40000, len=340000
[    0.770000] 0x000000b40000-0x000000e80000 : "rootfs_data"
[    0.770000] 0x000000e80000-0x000000ff0000 : "kernel"
[    0.780000] 0x000000ff0000-0x000001000000 : "art"
[    0.790000] 0x000000050000-0x000000ff0000 : "firmware"

which is what I was using originally.

I have those kernel options selected, so I'm not sure what else I can try?

Can you show dts-file and bootlog after modification? Does your breed support both tplinkfw and uimage format of firwmare?

So currently, it'll only boot with the tplinkfw, if I use compatible = "denx,uimage"; for the firmware partition it results in:

Network started on eth0, inet addr 192.168.1.1, netmask 255.255.255.0

Press any key to interrupt autoboot ... 0   

Unable to locate firmware.

Starting breed built-in shell

breed> 

After creating an image using compatible = tplink,firmware, with your modifications it has booted successfully.
This is the partition table that has successfully booted: https://github.com/wambu-i/openwrt/blob/e5cb6f31bc047c9506ebcb6c87aba69ea7dc11e9/target/linux/ath79/dts/qca9531_zbtlink_zbt-we826q.dts#L101
Is there a way to know which format it supports?
Also, this is the image command I've used:

define Device/zbtlink_zbt-we826q
$(Device/tplink-16mlzma)
  SOC := qca9531
  DEVICE_VENDOR := ZBT
  DEVICE_MODEL := WE826Q
  IMAGE_SIZE := 16000k
  DEVICE_PACKAGES := kmod-usb2 kmod-usb-storage
  SUPPORTED_DEVICES += zbt-we826q
endef
TARGET_DEVICES += zbtlink_zbt-we826q

Does that look odd to you? Not sure why it succeeds using the tplink image commands when it's not one?

Ask author? :slight_smile:

You totally removed original bootloader and changed flash partitioning so why not? :slight_smile:
But if you intend to send patch to openwrt you have to use original bootloader.

It's only format of firmware file. And at least this format is supported by your breed bootloader.

Oh, sure.
I wasn't sure if that's something we can tell from the operating system. This bootloader comes with the device from the manufacturer and as far as I can tell is closed-source.

Does this mean using the original partitions with the original firmware as described above?

I mean that official openwrt firmware must be intstalled without modification of original device. So at least factory.bin image must support installation with only software method.

Okay.
Thanks for the help - I'll continue working on the image as it successfully boots now.

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