mediatek: mt7622: convert BPi-R64 to all-UBI layout and fitblk
[openwrt/staging/jow.git] / package / boot / uboot-envtools / files / mediatek_mt7622
index fdf0d331fc569bb80ff8eec3e29e6d8b8bfb0083..732f7d5a0e5f8d466d530251fb706546e8220bc4 100644 (file)
@@ -9,6 +9,21 @@ touch /etc/config/ubootenv
 . /lib/uboot-envtools.sh
 . /lib/functions.sh
 
+ubootenv_add_mmc_default() {
+       local envdev="$(find_mmc_part "ubootenv" "${1:-mmcblk0}")"
+       ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1"
+       ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1"
+}
+
+ubootenv_add_ubi_default() {
+       . /lib/upgrade/nand.sh
+       local envubi=$(nand_find_ubi ubi)
+       local envdev=/dev/$(nand_find_volume $envubi ubootenv)
+       local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
+       ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
+       ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
+}
+
 board=$(board_name)
 
 case "$board" in
@@ -17,22 +32,17 @@ dlink,eagle-pro-ai-r32-a1)
        ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x2000" "0x2000"
        ;;
 linksys,e8450-ubi)
-       ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1"
-       ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1"
+       ubootenv_add_ubi_default
        ;;
 bananapi,bpi-r64)
-       rootdev="$(cmdline_get_var root)"
-       rootdev="${rootdev##*/}"
-       rootdev="${rootdev%%p[0-9]*}"
-       case "$rootdev" in
+       . /lib/upgrade/platform.sh
+       bootdev="$(platform_get_bootdev)"
+       case "$bootdev" in
        mmc*)
-               local envdev=$(find_mmc_part "ubootenv" $rootdev)
-               ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1"
-               ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1"
+               ubootenv_add_mmc_default "${bootdev%p[0-9]*}"
                ;;
        ubi*)
-               ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1"
-               ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1"
+               ubootenv_add_ubi_default
                ;;
        esac
        ;;