immortalwrt/tools
Bjørn Mork 4c16daabbb
firmware-utils: zytrx: Add util for ZyXEL specific header
The ZyXEL NR7101 prepend an additional header to U-Boot images. This
header use the TRX magic 0x30524448 (HDR0), but is incompatible with
TRX images.

This code is reverse-engineered based on matching 32 bit numbers
found in the header with lengths and different checksum
calculations of the vendor images found on the device.  The result
was matched against the validation output produced by the
bootloader to name the associated header fields.

Example bootloader validation output:

 Zyxel TRX Image 1 --> Found!  Header Checksum OK
 ============ZyXEL header information==================
         chipId             : MT7621A
         boardId            : NR7101
         modelId            : 07 01 00 01
         kernel_len         : (14177560)
         kernelChksum       : (0x8DD31F69)
         swVersionInt       : 1.00(ABUV.0)D1
         swVersionExt       : 1.00(ABUV.0)D1

 Zyxel TRX Image 2 --> Found!  Header Checksum OK
 ============ZyXEL header information==================
         chipId             : MT7621A
         boardId            : NR7101
         modelId            : 07 01 00 01
         kernel_len         : (14176660)
         kernelChksum       : (0x951A7637)
         swVersionInt       : 1.00(ABUV.0)D0
         swVersionExt       : 1.00(ABUV.0)D0

 =================================================
 Check image validation:
 Image1 Header Magic Number --> OK
 Image2 Header Magic Number --> OK
 Image1 Header Checksum --> OK
 Image2 Header Checksum --> OK
 Image1 Data Checksum --> OK
 Image2 Data Checksum --> OK
 Image1 Stable Flag --> Stable
 Image1 Try Counter --> 0
 Image1: OK
 Image2: OK

The coverage and algorithm for the kernelChksum field is unknown.
This field is not validated by the bootloader or the OEM firmware
upgrade tool. It is therefore set to a static value for now.

The swVersion fields contain free form string values.  The OEM firmware
use ZyXEL structured version numbers as shown above.  The strings are
not interpreted or validated on boot, so they can be repurposed for
anything we want the bootloader to display to the user.  But the OEM
web GUI fails to flash images with freeform strings.

The purpose of the other strings in the header is not known.  The
values appear to be static.  We assume they are fixed for now, until
we have other examples.  One of these strings is the platform name,
which is taken as an input parameter for support other members of
the device family.

Signed-off-by: Bjørn Mork <bjorn@mork.no>
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
2021-05-09 20:53:39 +08:00
..
autoconf tools: fix permission 2019-09-07 15:36:23 +08:00
autoconf-archive tools: add autoconf-archive 2020-05-23 19:20:29 +08:00
automake Merge Lean's source 2019-12-14 12:18:29 +08:00
b43-tools tools: update 2019-10-26 10:01:37 +08:00
bc tools/bc: use autoreconf to fix build failure on macOS with recent Xcode versions 2020-11-21 17:41:58 +08:00
bison tools/bison: update to 3.7.1 2020-08-23 23:38:07 +08:00
cbootimage treewide: update email address of Tomasz Maciej Nowak 2020-11-24 23:28:39 +08:00
cbootimage-configs treewide: update email address of Tomasz Maciej Nowak 2020-11-24 23:28:39 +08:00
ccache ccache: update to 4.2.1 2021-04-25 23:13:24 +08:00
cmake tools/cmake: always use non-ccache CC and CXX variables 2021-01-08 16:08:33 +08:00
coreutils tools/coreutils: update to 8.32 2020-08-31 11:10:51 +08:00
cpio tools: add cpio 2021-03-01 12:08:11 +08:00
dosfstools tools: fix permission 2019-09-07 15:36:23 +08:00
e2fsprogs tools/e2fsprogs: fix build under macos 2020-04-10 20:04:56 +08:00
elftosb tools: fix permission 2019-09-07 15:36:23 +08:00
expat tools/expat: change package source to GitHub 2019-11-30 19:24:19 +08:00
fakeroot download: add mirror alias for Debian 2021-02-27 12:11:33 +08:00
findutils tools/findutils: Update to 4.7.0 2020-04-10 09:17:04 +08:00
firmware-utils firmware-utils: zytrx: Add util for ZyXEL specific header 2021-05-09 20:53:39 +08:00
flex tools: fix permission 2019-09-07 15:36:23 +08:00
flock tools/flock: add PKG_{VERSION,RELEASE} 2020-07-23 22:45:21 +08:00
genext2fs tools: fix permission 2019-09-07 15:36:23 +08:00
gengetopt tools: update 2019-10-26 10:01:37 +08:00
gmp tools/gmp: Remove obsolete options 2020-02-20 03:02:36 +08:00
include tools: fix permission 2019-09-07 15:36:23 +08:00
isl tools: update 2019-10-26 10:01:37 +08:00
kernel2minor tools: fix permission 2019-09-07 15:36:23 +08:00
libressl ccache: update to 4.1 2020-12-31 17:50:39 +08:00
libtool tools: fix permission 2019-09-07 15:36:23 +08:00
lzma treewide: unify OpenWrt hosted source via @OPENWRT 2021-02-08 12:11:32 +08:00
lzma-old treewide: unify OpenWrt hosted source via @OPENWRT 2021-02-08 12:11:32 +08:00
m4 tools: fix permission 2019-09-07 15:36:23 +08:00
make-ext4fs make_ext4fs: Update to version 2020-01-05 2020-01-15 02:06:24 +08:00
missing-macros treewide: remove empty default cases 2020-09-18 16:37:37 +08:00
mkimage tools: mkimage: add patches for 64-bit MediaTek BootROM 2021-03-12 12:00:34 +08:00
mklibs download: add mirror alias for Debian 2021-02-27 12:11:33 +08:00
mm-macros tools/mm-macros: Update to 1.0.0 2020-04-10 09:18:12 +08:00
mpc tools/mpc: update to 1.2.0 2020-08-28 09:26:04 +08:00
mpfr tools/mpfr: update to 4.1.0 2020-08-24 11:34:03 +08:00
mtd-utils tools: mtd-utils: Update to version 2.1.2 2020-08-27 12:02:57 +08:00
mtools tools/mtools: Update to 4.0.24 2020-04-10 09:17:20 +08:00
padjffs2 tools: drop PKG_VERSION for purely local packages 2020-07-23 22:44:05 +08:00
patch tools/patch: apply upstream patch for cve-2019-13638 2019-08-16 13:59:06 +08:00
patch-image tools/patch-image: add PKG_RELEASE 2020-07-23 22:44:24 +08:00
patchelf tools/patchelf: bump to use latest master 2021-02-16 12:08:21 +08:00
pkg-config ccache: update to 4.1 2020-12-31 17:50:39 +08:00
qemu luci-app-ssr-plus: fix v2ray Netflix unlock 2020-03-17 10:42:17 +08:00
quilt tools/quilt: update to 0.66 2019-11-30 19:24:57 +08:00
sdimage tools: fix permission 2019-09-07 15:36:23 +08:00
sed tools/sed: Update to 4.8 2020-02-20 03:02:22 +08:00
sparse tools/sparse: update to version 0.6.3 2021-03-20 11:22:37 +08:00
squashfs squashfs: Fix compile with GCC 10 2020-06-19 17:09:24 +08:00
squashfskit4 tools/squashfskit4: fix build on non-linux systems 2020-09-02 11:32:04 +08:00
sstrip tools/sstrip: update to latest version 2020-11-28 19:05:31 +08:00
tar tools: update 2019-10-26 10:01:37 +08:00
ucl ucl: fix CLEAN 2020-04-23 01:44:28 +08:00
upx upx: fix host build (#3339) 2020-03-01 14:05:09 +08:00
xxd tools/xxd: fix source URL 2021-03-02 12:07:04 +08:00
xz tools/xz: Update to 5.2.5 2020-04-10 09:17:36 +08:00
zip ramips: mt7621: add support for Netgear R6800 2019-12-13 08:25:54 -08:00
zlib tools: fix permission 2019-09-07 15:36:23 +08:00
zstd tools/zstd: compile with cmake 2021-01-31 22:18:38 +08:00
Makefile Merge Mainline 2021-03-14 23:47:44 +08:00