CPE610 v1: sysupgrade.bin missing / too big

Freshly added device, but only initramfs is being built; sysupgrade.bin is missing.

Buildlog:

/builder/ath79_generic/build/staging_dir/host/bin/tplink-safeloader -B CPE610V1 -V r10353-3f68cffd27 -k /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_cpe610-v1-kernel.bin -r /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin -o /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.new -j  -S && mv /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.new /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin || rm -f /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin
cp /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_archer-d50-v1-initramfs-kernel.bin /builder/ath79_generic/build/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_archer-d50-v1-initramfs-kernel.bin
os-image partition too big (more than 1835008 bytes): Success
echo '{  "metadata_version": "1.0", "supported_devices":["tplink,cpe610-v1"], "version": { "dist": "OpenWrt", "version": "SNAPSHOT", "revision": "r10353-3f68cffd27", "target": "ath79/generic", "board": "tplink_cpe610-v1" } }' | fwtool -I - /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin
Failed to open firmware file
Makefile:82: recipe for target '/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin' failed
make[4]: [/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin] Error 1 (ignored)
[ ! -s "/builder/ath79_generic/build/key-build" -o ! -s "/builder/ath79_generic/build/key-build.ucert" -o ! -s "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin" ] || { cp "/builder/ath79_generic/build/key-build.ucert" "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.ucert" ; usign -S -m "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin" -s "/builder/ath79_generic/build/key-build" -x "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.sig" ; ucert -A -c "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.ucert" -x "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.sig" ; fwtool -S "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin.ucert" "/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin" ; }
cp /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_re350k-v1-initramfs-kernel.bin /builder/ath79_generic/build/bin/targets/ath79/generic/openwrt-ath79-generic-tplink_re350k-v1-initramfs-kernel.bin
os-image partition too big (more than 1835008 bytes): Success
[ -f /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_archer-d50-v1-kernel.bin -a -f /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/root.squashfs+pkg=833ed9c3 ]
[ -f /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tplink_re350k-v1-kernel.bin -a -f /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/root.squashfs+pkg=0f3ad530 ]
stat: cannot stat '/builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin': No such file or directory
bash: line 0: [: : integer expression expected
WARNING: Image file /builder/ath79_generic/build/build_dir/target-mips_24kc_musl/linux-ath79_generic/tmp/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin is too big

Temporary glitch or permanent error (which would question the "supported" status)?

Build from master pull of this morning

jeff@deb-devel:~/devel/openwrt$ ls -l bin/targets/ath79/generic/
total 11248
-rw-r--r-- 1 jeff jeff   15847 Jun 27 06:01 config.seed
-rw-r--r-- 1 jeff jeff    2226 Jun 27 06:04 openwrt-ath79-generic-device-tplink-cpe610-v1.manifest
-rw-r--r-- 1 jeff jeff 3653817 Jun 27 06:04 openwrt-ath79-generic-tplink_cpe610-v1-initramfs-kernel.bin
-rw-r--r-- 1 jeff jeff 3845021 Jun 27 06:04 openwrt-ath79-generic-tplink_cpe610-v1-squashfs-factory.bin
-rw-r--r-- 1 jeff jeff 7804051 Jun 27 06:04 openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin
drwxr-xr-x 2 jeff jeff      46 Jun 27 06:04 packages
-rw-r--r-- 1 jeff jeff     580 Jun 27 06:04 sha256sums

Sorry, I first misunderstood that the images have been built in the meantime, but that doesn't seem to be the case.

No problem, it's locally buildable, so likely a build-system glitch.

image partition too big (more than 1835008 bytes) seems rather strange for any "rational" ath79 device on a "bare" build..

is actually quite revealing (from tools/firmware-utils/src/tplink-safeloader.c).

	{
		.id     = "CPE610V1",
		.vendor = "CPE610(TP-LINK|UN|N300-5|00000000):1.0\r\n",
[...]
		.partitions = {
			{"fs-uboot", 0x00000, 0x20000},
			{"partition-table", 0x20000, 0x02000},
			{"default-mac", 0x30000, 0x00020},
			{"product-info", 0x31100, 0x00100},
			{"signature", 0x32000, 0x00400},
			{"os-image", 0x40000, 0x1c0000},
			{"file-system", 0x200000, 0x5b0000},
			{"soft-version", 0x7b0000, 0x00100},
			{"support-list", 0x7b1000, 0x00400},
			{"user-config", 0x7c0000, 0x10000},
			{"default-config", 0x7d0000, 0x10000},
			{"log", 0x7e0000, 0x10000},
			{"radio", 0x7f0000, 0x10000},
			{NULL, 0, 0}
		},
[...]
	},

os-image := kernel
file-system := rootfs

0x1c0000 = 1'835'008 bytes

Taking a current snapshot as example (https://downloads.openwrt.org/snapshots/targets/ath79/generic/openwrt-ath79-generic-tplink_tl-wr1043nd-v1-squashfs-factory.bin):

$ binwalk openwrt-ath79-generic-tplink_tl-wr1043nd-v1-squashfs-factory.bin

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
512           0x200           gzip compressed data, maximum compression, from Unix, last modified: 1970-01-01 00:00:00 (null date)
8256          0x2040          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 6045946 bytes
1894768       0x1CE970        Squashfs filesystem, little endian, version 4.0, compression:xz, size: 2117646 bytes, 822 inodes, blocksize: 262144 bytes, created: 2019-06-27 15:15:37

0x1CE970 - 0x2040 = 0x1CC930
0x1CC930 = 1'886'512 bytes

In other words, the kernel is too big for the limited size of the kernel partition, probably since ath79 got switched from kernel 4.14 to 4.19. If this can be rectified by extending os-image at the expense of file-system, or by merging both into a single firmware partition and using mtdsplit from there on (more flexible) needs to be checked by someone who has that device on their desk[0]. The partitions are in the correct order (kernel --> rootfs) for that to work, but it still depends on if the bootloader is flexible enough to read the kernel beyond its original partitioning limit and if the bootloader tftp and OEM factory upgrade (OEM webinterface) implementations can cope with a modified partitioning.

--
[0] mature recovery mechanism required, ideally serial console, but at least something like push-button tftp. full backup of all partitions strongly required (radio/ ART in particular), means to reflash the spi-nor chip externally would be advisable.

1 Like

Interesting, looks like this board is "on the edge".

From my local build of this morning

jeff@deb-devel:~/devel/openwrt$ binwalk bin/targets/ath79/generic/openwrt-ath79-generic-tplink_cpe610-v1-squashfs-sysupgrade.bin 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             ELF, 32-bit MSB MIPS-I executable, MIPS, version 1 (SYSV)
9564          0x255C          Copyright string: "Copyright (C) 2011 Gabor Juhos <juhosg@openwrt.org>"
9772          0x262C          LZMA compressed data, properties: 0x6D, dictionary size: 8388608 bytes, uncompressed size: 5743577 bytes
1835008       0x1C0000        Squashfs filesystem, little endian, version 4.0, compression:xz, size: 2014668 bytes, 793 inodes, blocksize: 262144 bytes, created: 2019-06-27 12:16:32

based on 1ffca55456 uqmi: bump to latest git HEAD

echo $(( 0x1C0000 ))
1835008
-rwxr-xr-x  1 jeff jeff  1804772 Jun 27 06:04 tplink_cpe610-v1-kernel.bin

You probably (indirectly, via dependencies) enable less kernel options than the buildbot configs.

1 Like

You might need to do some similar kernel partition enlargement (taking space from "file-system") that was done for R7800 and several other ipq806x devices by @slh in May 2018. He already referenced that above, but this is the link to the actual change done. Somethings similar might help you:

Sadly these tplink-safeloader based TP-Link devices are handled slightly differently (and, warning, there are different safeloader versions, with different pecularities), examples would be:

ar71xx:

or ath79:


(the later option is better, as it allows a dynamic mtdsplit - meaning the kernel can grow dynamically)

The change itself is trivial, but confirming that it doesn't break anything (tftp-pushbutton recovery and installing from the OEM webinterface) or recovering in case it does brick the device isn't. {"partition-table", 0x20000, 0x02000}, worries me a bit as well, as I'm not familiar enough with the recent safeloader variants to confirm if this needs any changes (or is updated by tplink-safeloader implicitly).

WARNING: the DTS needs to synced up with the safeloader changes (similar to the r7800 changes referenced by hnyman) as well, see

I Will create a PR in the next few days to fix this.
We tried using the MD Splitter but it does not work with these devices so I will probably need to switch back to the OKLI loader solution as @NeoRaider said

"Well, the commit message of 0c0bb62 basically explains the situation. Old OpenWrt installations with a too small kernel partition ("os-image") in the TP-Link partition table exist in the field, so the bootloader would fail to load the whole compressed kernel into the RAM. The OKLI loader is a workaround for this: The TP-Link bootloader only loads the tiny OKLI loader, and the OKLI loader will then read the actual kernel from the flash.
While this is only an issue for old installations, and installing a new OpenWrt factory image from the stock firmware will result in a "fixed" partition layout (with bigger os-image), 1. we can't easily upgrade old devices (as explained in the referenced commit message, such an upgrade would need to happen before sysupgrade), and 2. the OKLI loader solution is more robust in case we ever need to increase kernel partition size again. Therefore, I would propose to keep the OKLI loader for ath79 as well."

2 Likes

I have created https://github.com/openwrt/openwrt/pull/2187 to resolve this issue.
Once it is merged this device will build under the buildbot

3 Likes

factory and sysupgrade image have been built now after https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=d5a38725f84f52618a7c4cb17e8bfac40a17854a

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