[OpenWrt-Devel,8/9] uboot-envtools: sunxi: add support for the pine64 lts
diff mbox series

Message ID 20190114175429.7320-9-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 reading and writing environment stored in
SPI flash device.

Signed-off-by: Oskari Lemmela <oskari@lemmela.net>
---
 package/boot/uboot-envtools/files/sunxi | 33 +++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 package/boot/uboot-envtools/files/sunxi

Patch
diff mbox series

diff --git a/package/boot/uboot-envtools/files/sunxi b/package/boot/uboot-envtools/files/sunxi
new file mode 100644
index 0000000000..7d6c1d4912
--- /dev/null
+++ b/package/boot/uboot-envtools/files/sunxi
@@ -0,0 +1,33 @@ 
+#!/bin/sh
+#
+# Copyright (C) 2018 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+board=$(board_name)
+
+ubootenv_mtdinfo () {
+	UBOOTENV_PART=$(cat /proc/mtd | grep u-boot-env)
+	mtd_dev=$(echo $UBOOTENV_PART | awk '{print $1}' | sed 's/:$//')
+	mtd_size=$(echo $UBOOTENV_PART | awk '{print "0x"$2}')
+	mtd_erase=$(echo $UBOOTENV_PART | awk '{print "0x"$3}')
+	sectors=$(( $mtd_size / $mtd_erase ))
+	echo /dev/$mtd_dev 0x0 $mtd_size $mtd_erase $sectors
+}
+
+case "$board" in
+pine64,pine64-lts)
+	ubootenv_add_uci_config $(ubootenv_mtdinfo)
+	;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0