[OpenWrt-Devel,9/9] sunxi: sysupgrade: add support for pine64 lts spi flash
diff mbox series

Message ID 20190114175429.7320-10-oskari@lemmela.net
State New
Delegated to: Hauke Mehrtens
Headers show
Series
  • sunxi: add support for pine64-lts
Related show

Commit Message

Oskari Lemmelä Jan. 14, 2019, 5:54 p.m. UTC
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@lemmela.net>
---
 .../sunxi/base-files/lib/upgrade/platform.sh  | 30 ++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

Patch
diff mbox series

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
+
+}