This patch enables the convenient sysupgrade feature for WD's Wi-Fi Range Extender.
The procedure is pretty much SOP. However, there is one small trick to it: The customized u-boot loader verifies the image's CRC32 against a reference each time the device boots. Now, In case of a jffs2-root filesystem the reference checksum would have to be updated every time something on the fs changes... Obviously, this wouldn't be very practial. Luckily, the bootloader check can be defeated by modifying the TRX header after the flash. Signed-off-by: Christian Lamparter <chunk...@googlemail.com> --- It seems the wrt160nl suffers from a similar issue. At least there's an open ticket #8960 https://dev.openwrt.org/ticket/8960. As far as I can tell, the current sysupgrade code already tries to fix the TRX header (even on my Archer C7?!) but it fails: Writing from <stdin> to firmware ... Appending jffs2 data from /tmp/sysupgrade.tgz to firmware... TRX header not found Error fixing up TRX header. This is because the current sysupgrade code doesn't know that the TRX header has a offset (32 bytes from the beginning). --- .../ar71xx/base-files/lib/upgrade/mynet-rext.sh | 26 ++++++++++++++++++++++ .../ar71xx/base-files/lib/upgrade/platform.sh | 6 +++++ target/linux/ar71xx/image/Makefile | 3 +++ 3 files changed, 35 insertions(+) create mode 100644 target/linux/ar71xx/base-files/lib/upgrade/mynet-rext.sh diff --git a/target/linux/ar71xx/base-files/lib/upgrade/mynet-rext.sh b/target/linux/ar71xx/base-files/lib/upgrade/mynet-rext.sh new file mode 100644 index 0000000..ea4eddd --- /dev/null +++ b/target/linux/ar71xx/base-files/lib/upgrade/mynet-rext.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +. /lib/functions.sh +. /lib/ar71xx.sh + +get_image_magic() { + local mtddev=$1 + dd bs=8 count=1 skip=0 if=$mtddev 2>/dev/null | hexdump -v -n 8 -e '1/1 "%02x"' +} + +mynet_rext_check_image() { + local magic="$(get_magic_long "$1")" + local fw_magic=$(get_magic_long "`find_mtd_part \"firmware\"`") + + [ "$fw_magic" != "$magic" ] && { + echo "Invalid image, ID mismatch, got:$magic, but need:$fw_magic" + return 1 + } + + return 0; +} + +platform_do_upgrade_mynet_rext() { + default_do_upgrade "$ARGV" + mtd -o 32 fixtrx firmware +} diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh index ae04a8c..7932e76 100755 --- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh +++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh @@ -169,6 +169,9 @@ platform_check_image() { return 0; ;; + mynet-rext) + mynet_rext_check_image "$1" && return 0 + ;; mr600 | \ mr600v2 | \ om2p | \ @@ -318,6 +321,9 @@ platform_do_upgrade() { tew-673gru) platform_do_upgrade_dir825b "$ARGV" ;; + mynet-rext) + platform_do_upgrade_mynet_rext "$ARGV" + ;; mr600 | \ mr600v2 | \ om2p | \ diff --git a/target/linux/ar71xx/image/Makefile b/target/linux/ar71xx/image/Makefile index 897aab9..ac9d7ed 100644 --- a/target/linux/ar71xx/image/Makefile +++ b/target/linux/ar71xx/image/Makefile @@ -683,6 +683,9 @@ Image/Build/CyberTANLZMA/buildkernel=$(call MkuImageLzma,$(2),$(3) $(4)) define Image/Build/CyberTANLZMA $(STAGING_DIR_HOST)/bin/trx -o $(KDIR)/image.tmp -f $(KDIR_TMP)/vmlinux-$(2).uImage \ -x 32 -a 0x10000 -x -32 -f $(KDIR)/root.$(1) + -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) \ + -i $(KDIR)/image.tmp \ + -o $(call sysupname,$(1),$(2)) -$(STAGING_DIR_HOST)/bin/addpattern -B $(2) -v v$(5) -g \ -i $(KDIR)/image.tmp \ -o $(call factoryname,$(1),$(2)) -- 1.8.4.2 _______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel