[OpenWrt-Devel] [PATCH 9/9] sunxi: sysupgrade: add support for pine64 lts spi flash

Oskari Lemmela oskari at lemmela.net
Mon Jan 14 12:54:29 EST 2019


Add support for updating SPI flash device firmware.

U-boot has to be programmed to spi flash device /dev/mtd0
manually before switching from sdcard to SPI flash device.

Running sysupgrade with sysupgrade.bin will write firmware
partition and copy configuration files from sdcard.

Signed-off-by: Oskari Lemmela <oskari at lemmela.net>
---
 .../sunxi/base-files/lib/upgrade/platform.sh  | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/target/linux/sunxi/base-files/lib/upgrade/platform.sh b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
index 88ef4790e9..436e4d8517 100644
--- a/target/linux/sunxi/base-files/lib/upgrade/platform.sh
+++ b/target/linux/sunxi/base-files/lib/upgrade/platform.sh
@@ -1,5 +1,17 @@
+PART_NAME=firmware
+
 platform_check_image() {
 	local diskdev partdev diff
+	local firmware_mtd=$(find_mtd_part firmware)
+	local image_magic="$(get_magic_long "$1")"
+
+	if [ -n "$firmware_mtd" ] && [ "$image_magic" != "00000000" ]; then
+		REQUIRE_IMAGE_METADATA=1
+		if ! $(fwtool_check_image $@); then
+			return 1
+		fi
+		return 0
+	fi
 
 	export_bootdevice && export_partdevice diskdev -2 || {
 		echo "Unable to determine upgrade device"
@@ -35,7 +47,7 @@ platform_copy_config() {
 	fi
 }
 
-platform_do_upgrade() {
+platform_do_upgrade_mmc() {
 	local diskdev partdev diff
 
 	export_bootdevice && export_partdevice diskdev -2 || {
@@ -87,3 +99,19 @@ platform_do_upgrade() {
 	echo "Writing new UUID to /dev/$diskdev..."
 	get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync
 }
+
+platform_do_upgrade() {
+	local board=$(board_name)
+	local image_magic="$(get_magic_long "$1")"
+
+	if [ "$image_magic" != "00000000" ]; then
+		case "$board" in
+		pine64,pine64-lts)
+			default_do_upgrade "$ARGV"
+			;;
+		esac
+	else
+		platform_do_upgrade_mmc "$ARGV"
+	fi
+
+}
-- 
2.17.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