[OpenWrt-Devel] [PATCH v2] gemini: Support sysupgrade on DIR-685

Linus Walleij linus.walleij at linaro.org
Sun May 12 15:13:17 EDT 2019


This makes sysupgrade work on the D-Link DIR-685 after
initial factory install.

We create the platform.sh script to support sysupgrade
on more targets as we move on with sysupgrade support.

Cc: Petr Štetiar <ynezz at true.cz>
Signed-off-by: Linus Walleij <linus.walleij at linaro.org>
---
ChangeLog v1->v2:
- Append metadata to sysupgrade image
- Require metadata in platform.sh
- Strip comments
---
 .../gemini/base-files/lib/upgrade/platform.sh | 50 +++++++++++++++++++
 target/linux/gemini/image/Makefile            |  5 +-
 2 files changed, 54 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/gemini/base-files/lib/upgrade/platform.sh

diff --git a/target/linux/gemini/base-files/lib/upgrade/platform.sh b/target/linux/gemini/base-files/lib/upgrade/platform.sh
new file mode 100644
index 000000000000..5f7a2117cb3b
--- /dev/null
+++ b/target/linux/gemini/base-files/lib/upgrade/platform.sh
@@ -0,0 +1,50 @@
+REQUIRE_IMAGE_METADATA=1
+
+wrgg_get_image_magic() {
+	get_image "$@" | dd bs=4 count=1 skip=8 2>/dev/null | hexdump -v -n 4 -e '1/1 "%02x"'
+}
+
+platform_find_part_size() {
+	local first dev size erasesize name
+	while read dev size erasesize name; do
+		name=${name#'"'}; name=${name%'"'}
+		[ "$name" = "$1" ] && {
+			echo "$size"
+			break
+		}
+	done < /proc/mtd
+}
+
+platform_check_image() {
+	local board=$(board_name)
+
+	case "$board" in
+	dlink,dir-685 )
+		local magic=$(wrgg_get_image_magic "$1")
+		[ "$magic" != "21030820" ] && {
+			echo "Invalid image. Bad magic for DIR-685."
+			return 1
+		}
+		echo "Image looks OK"
+		return 0
+		;;
+	esac
+
+	echo "Sysupgrade is not yet supported on $board."
+	return 1
+}
+
+platform_do_upgrade() {
+	local board=$(board_name)
+
+	v "board=$board"
+	case "$board" in
+	dlink,dir-685 )
+		PART_NAME=firmware
+		default_do_upgrade "$ARGV"
+		;;
+	*)
+
+		;;
+	esac
+}
diff --git a/target/linux/gemini/image/Makefile b/target/linux/gemini/image/Makefile
index 8fec250f186a..3339cd2467a9 100644
--- a/target/linux/gemini/image/Makefile
+++ b/target/linux/gemini/image/Makefile
@@ -115,6 +115,7 @@ define Device/Default
 	KERNEL_NAME := zImage
 	KERNEL := kernel-bin | append-dtb
 	BLOCKSIZE := 128k
+	SUPPORTED_DEVICES := $(subst _,$(comma),$(1))
 endef
 
 # A reasonable set of default packages handling the NAS type
@@ -143,9 +144,11 @@ define Device/dlink_dir-685
 	DEVICE_PACKAGES := $(GEMINI_NAS_PACKAGES) \
 			kmod-switch-rtl8366rb swconfig \
 			kmod-rt2800-pci
-	IMAGES := factory.bin
+	IMAGES := factory.bin sysupgrade.bin
 	# Pad to 128k erase blocks with 160 bytes WRGG header
 	IMAGE/factory.bin := append-kernel | pad-offset 128k 160 | append-rootfs | dir685-pad-rootfs | dir685-image
+	IMAGE/sysupgrade.bin := append-kernel | pad-offset 128k 160 | dir685-image | append-rootfs | dir685-pad-rootfs | append-metadata
+	SUPPORTED_DEVICES += dlink,dir-685
 endef
 TARGET_DEVICES += dlink_dir-685
 
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list