[][OpenWrt Dev][Add support for u-boot env-tools for emmc devices]
[Description]
Add support for u-boot env-tools for emmc devices
[Release-log]
N/A
Change-Id: I86459f608e113a9dbe2fb69eea9494d7504195ff
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/5664321
diff --git a/package/boot/uboot-envtools/files/mediatek b/package/boot/uboot-envtools/files/mediatek
new file mode 100644
index 0000000..7a0507a
--- /dev/null
+++ b/package/boot/uboot-envtools/files/mediatek
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Copyright (C) 2011-2012 OpenWrt.org
+#
+
+[ -e /etc/config/ubootenv ] && exit 0
+
+touch /etc/config/ubootenv
+
+. /lib/uboot-envtools.sh
+. /lib/functions.sh
+
+block_dev_path() {
+ local dev_path
+
+ case "$1" in
+ /dev/mmcblk*)
+ dev_path="$1"
+ ;;
+ PARTLABEL=* | PARTUUID=*)
+ dev_path=$(blkid -t "$1" -o device)
+ [ -z "${dev_path}" -o $? -ne 0 ] && return 1
+ ;;
+ *)
+ return 1;
+ ;;
+ esac
+
+ echo "${dev_path}"
+ return 0
+}
+
+board=$(board_name)
+
+case "$board" in
+mediatek,*-emmc-rfb)
+ env_dev=$(cat /sys/module/boot_param/parameters/env_part 2>/dev/null)
+ [ -n "$env_dev" ] && env_dev=$(block_dev_path "${env_dev}")
+ [ -z "$env_dev" ] && env_dev=$(block_dev_path "PARTLABEL=u-boot-env")
+ [ -n "$env_dev" ] && \
+ ubootenv_add_uci_config "$env_dev" "0" "0x80000"
+ ;;
+esac
+
+config_load ubootenv
+config_foreach ubootenv_add_app_config ubootenv
+
+exit 0