@@ -58,12 +58,6 @@ MAKE_FLAGS += \
no-dot-config-targets=envtools \
envtools
-define Package/uboot-envtools/conffiles
-/etc/config/ubootenv
-/etc/fw_env.config
-/etc/fw_sys.config
-endef
-
define Package/uboot-envtools/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/env/fw_printenv $(1)/usr/sbin
@@ -1,4 +1,4 @@
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -9,17 +9,19 @@ board=$(board_name)
case "$board" in
meraki,mr24)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000" "4"
ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x4000" "4"
;;
meraki,mx60)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" "4"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000" "4"
;;
netgear,wndap620|\
netgear,wndap660)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000" "4"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000" "4"
;;
wd,mybooklive)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000" "1"
ubootenv_add_uci_config "/dev/mtd1" "0x1000" "0x1000" "0x1000" "1"
;;
@@ -2,7 +2,7 @@
# Copyright (C) 2011-2014 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -77,17 +77,17 @@ yuncore,xd3200|\
yuncore,xd4200|\
ziking,cpe46b|\
zyxel,nbg6616)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
;;
buffalo,wzr-hp-ag300h)
- ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd3" "0x0" "0x10000" "0x10000"
;;
buffalo,wzr-hp-g300nh-rb|\
buffalo,wzr-hp-g300nh-s)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
domywifi,dw33d)
- ubootenv_add_uci_config "/dev/mtd4" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd4" "0x0" "0x10000" "0x10000"
;;
dongwon,dw02-412h-64m|\
dongwon,dw02-412h-128m|\
@@ -95,24 +95,25 @@ glinet,gl-ar300m-lite|\
glinet,gl-ar300m-nand|\
glinet,gl-ar300m-nor|\
glinet,gl-ar300m16)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
;;
glinet,gl-ar150)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x8000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x8000" "0x10000"
;;
netgear,wndr3700|\
netgear,wndr3700-v2|\
netgear,wndrmac-v1)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x10000"
;;
netgear,pgzng1|\
netgear,wndr3700-v4|\
netgear,wndr4300|\
netgear,wndr4300tn|\
netgear,wndr4300sw)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
;;
openmesh,om2p-v1|\
openmesh,om2p-v2|\
@@ -124,29 +125,29 @@ openmesh,om2p-hs-v4|\
openmesh,om2p-lc|\
plasmacloud,pa300|\
plasmacloud,pa300e)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x40000" "0x40000"
;;
qihoo,c301)
- ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd9" "0x0" "0x10000" "0x10000"
;;
ruckus,zf7321|\
ruckus,zf7372)
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x40000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x40000" "0x10000"
;;
sophos,ap15|\
sophos,ap55|\
sophos,ap55c|\
sophos,ap100|\
sophos,ap100c)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
;;
wallys,dr531)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0xf800" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0xf800" "0x10000"
;;
zte,mf286|\
zte,mf286a|\
zte,mf286r)
- ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd7" "0x0" "0x20000" "0x10000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2013 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -16,7 +16,7 @@ laguna)
# Laguna uboot env size/erasesize vary depending on NOR vs SPI FLASH
size=$(grep mtd1 /proc/mtd | awk '{print $2}')
erasesize=$(grep mtd1 /proc/mtd | awk '{print $3}')
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x$size" "0x$erasesize"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x$size" "0x$erasesize"
;;
esac
@@ -1,4 +1,4 @@
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -9,7 +9,7 @@ board=$(board_name)
case "$board" in
technexion,imx7d-pico-pi)
- ubootenv_add_uci_config "/dev/mmcblk2" "0xc0000" "0x2000" "0x2000"
+ ubootenv_set_uci_config "/dev/mmcblk2" "0xc0000" "0x2000" "0x2000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2013-2014 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -38,6 +38,7 @@ gw,imx6q-gw5907|\
gw,imx6q-gw5910|\
gw,imx6q-gw5912|\
gw,imx6q-gw5913)
+ ubootenv_clear_uci_config
if [ -c /dev/mtd1 ]; then
# board boots from NAND
ubootenv_add_uci_config /dev/mtd1 0x0 0x20000 0x40000
@@ -51,10 +52,10 @@ gw,imx6q-gw5913)
toradex,apalis_imx6q-eval|\
toradex,apalis_imx6q-ixora|\
toradex,apalis_imx6q-ixora-v1.1)
- ubootenv_add_uci_config $(bootdev_from_uuid)boot0 -0x2200 0x2000 0x200 10
+ ubootenv_set_uci_config $(bootdev_from_uuid)boot0 -0x2200 0x2000 0x200 10
;;
wand,imx6dl-wandboard)
- ubootenv_add_uci_config "/dev/mmcblk0" "0x60000" "0x2000" "0x2000"
+ ubootenv_set_uci_config "/dev/mmcblk0" "0x60000" "0x2000" "0x2000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2016 LEDE
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -44,29 +44,29 @@ openmesh,a62|\
pakedge,wr-1|\
plasmacloud,pa1200|\
plasmacloud,pa2200)
- ubootenv_add_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd5" "0x0" "0x10000" "0x10000"
;;
aruba,ap-303)
- ubootenv_add_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd13" "0x0" "0x10000" "0x10000"
;;
aruba,ap-365)
- ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd8" "0x0" "0x10000" "0x10000"
;;
buffalo,wtr-m2133hp)
- ubootenv_add_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd8" "0x0" "0x40000" "0x20000"
;;
linksys,ea6350v3)
- ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd7" "0x0" "0x20000" "0x20000"
;;
linksys,ea8300|\
linksys,mr8300)
- ubootenv_add_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd7" "0x0" "0x40000" "0x20000"
;;
linksys,whw01-v1)
- ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd6" "0x0" "0x40000" "0x10000"
;;
zyxel,nbg6617)
- ubootenv_add_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd6" "0x0" "0x10000" "0x10000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2016 LEDE
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -33,25 +33,25 @@ ubootenv_mtdinfo () {
case "$board" in
arris,tr4400-v2|\
askey,rt4230w-rev6)
- ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd9" "0x0" "0x40000" "0x20000"
;;
edgecore,ecw5410)
- ubootenv_add_uci_config "/dev/mtd11" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd11" "0x0" "0x10000" "0x10000"
;;
linksys,ea7500-v1|\
linksys,ea8500)
- ubootenv_add_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd10" "0x0" "0x20000" "0x20000"
;;
netgear,r7800)
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x040000" "0x20000"
;;
qcom,ipq8064-ap148|\
qcom,ipq8064-db149)
- ubootenv_add_uci_config $(ubootenv_mtdinfo)
+ ubootenv_set_uci_config $(ubootenv_mtdinfo)
;;
ubnt,unifi-ac-hd|\
zyxel,nbg6817)
- ubootenv_add_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtdblock9" "0x0" "0x10000" "0x10000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2012-2014 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -25,10 +25,10 @@ seagate,dockstar|\
zyxel,nsa310b|\
zyxel,nsa310s|\
zyxel,nsa325)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
linksys,ea3500)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x4000" "0x4000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2012 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -13,18 +13,19 @@ board=$(board_name)
case "$board" in
bt,homehub-v2b)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
;;
bt,homehub-v3a)
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x4000" "1"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x4000" "0x4000" "1"
;;
siemens,gigaset-sx76x)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000" "1"
;;
zyxel,p-2812hnu-f1)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x2000" "0x20000" "1"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x2000" "0x20000" "1"
;;
buffalo,wbmr-300hpd)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x2000" "0x1000" "2"
@@ -2,7 +2,7 @@
# Copyright (C) 2016 LEDE
#
-[ -f /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -14,7 +14,7 @@ board=$(board_name)
case "$board" in
traverse,ls1043v|\
traverse,ls1043s)
- ubootenv_add_uci_config "/dev/mtd1" "0x40000" "0x2000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x40000" "0x2000" "0x20000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2021 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -19,11 +19,13 @@ bananapi,bpi-r3)
case "$rootdev" in
mmc*)
local envdev=$(find_mmc_part "ubootenv" $rootdev)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "$envdev" "0x0" "0x40000" "0x40000" "1"
ubootenv_add_uci_config "$envdev" "0x40000" "0x40000" "0x40000" "1"
;;
mtd*)
local envdev=/dev/mtd$(find_mtd_index "u-boot-env")
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "$envdev" "0x0" "0x20000" "0x20000" "1"
ubootenv_add_uci_config "$envdev" "0x20000" "0x20000" "0x20000" "1"
;;
@@ -32,6 +34,7 @@ bananapi,bpi-r3)
local envubi=$(nand_find_ubi ubi)
local envdev=/dev/$(nand_find_volume $envubi ubootenv)
local envdev2=/dev/$(nand_find_volume $envubi ubootenv2)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "$envdev" "0x0" "0x1f000" "0x1f000" "1"
ubootenv_add_uci_config "$envdev2" "0x0" "0x1f000" "0x1f000" "1"
;;
@@ -2,7 +2,7 @@
# Copyright (C) 2021 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -13,6 +13,7 @@ board=$(board_name)
case "$board" in
linksys,e8450-ubi)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1"
ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1"
;;
@@ -23,26 +24,28 @@ bananapi,bpi-r64)
case "$rootdev" in
mmc*)
local envdev=$(find_mmc_part "ubootenv" $rootdev)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "$envdev" "0x0" "0x80000" "0x80000" "1"
ubootenv_add_uci_config "$envdev" "0x80000" "0x80000" "0x80000" "1"
;;
*)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/ubi0_0" "0x0" "0x1f000" "0x1f000" "1"
ubootenv_add_uci_config "/dev/ubi0_1" "0x0" "0x1f000" "0x1f000" "1"
;;
esac
;;
buffalo,wsr-2533dhp2)
- ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x1000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd3" "0x0" "0x1000" "0x20000"
;;
ruijie,rg-ew3200gx-pro)
- ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd3" "0x0" "0x20000" "0x20000"
;;
ubnt,unifi-6-lr-ubootmod)
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x4000" "0x1000"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x4000" "0x1000"
;;
xiaomi,redmi-router-ax6s)
- ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000" "0x40000"
+ ubootenv_set_uci_config "/dev/mtd3" "0x0" "0x10000" "0x40000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2021 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -16,10 +16,10 @@ bananapi,bpi-r2)
. /lib/upgrade/common.sh
export_bootdevice
export_partdevice ubootpart 1
- ubootenv_add_uci_config "/dev/$ubootpart" "0xb0000" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/$ubootpart" "0xb0000" "0x10000" "0x10000" "1"
;;
unielec,u7623-02)
- ubootenv_add_uci_config "/dev/mmcblk0p1" "0xc0000" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mmcblk0p1" "0xc0000" "0x10000" "0x10000" "1"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2021 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -13,7 +13,7 @@ board=$(board_name)
case "$board" in
iptime,a6004mx)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000"
;;
esac
@@ -1,4 +1,4 @@
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -9,15 +9,15 @@ board=$(board_name)
case "$board" in
extreme-networks,ws-ap3825i)
- ubootenv_add_uci_config "$(find_mtd_part 'cfg1')" "0x0" "0x10000" "0x20000"
- ubootenv_add_uci_config "$(find_mtd_part 'cfg2')" "0x0" "0x10000" "0x20000"
+ ubootenv_set_uci_config "$(find_mtd_part 'cfg1')" "0x0" "0x10000" "0x20000"
+ ubootenv_set_uci_config "$(find_mtd_part 'cfg2')" "0x0" "0x10000" "0x20000"
;;
ocedo,panda)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000"
;;
aerohive,hiveap-330)
- ubootenv_add_uci_config "$(find_mtd_part 'u-boot-env')" "0x0" "0x20000" "0x10000"
+ ubootenv_set_uci_config "$(find_mtd_part 'u-boot-env')" "0x0" "0x20000" "0x10000"
;;
esac
@@ -3,7 +3,7 @@
# Copyright (C) 2016 LEDE-Project.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -14,20 +14,20 @@ board=$(board_name)
case "$board" in
buffalo,ls421de)
- ubootenv_add_uci_config "/dev/mtd3" "0x0" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd3" "0x0" "0x10000"
;;
cznic,turris-omnia)
idx="$(find_mtd_index u-boot-env)"
if [ -n "$idx" ]; then
- ubootenv_add_uci_config "/dev/mtd${idx}" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd${idx}" "0x0" "0x10000" "0x10000"
elif grep -q 'U-Boot 2015.10-rc2' /dev/mtd0; then
- ubootenv_add_uci_config "/dev/mtd0" "0xc0000" "0x10000" "0x40000"
+ ubootenv_set_uci_config "/dev/mtd0" "0xc0000" "0x10000" "0x40000"
else
- ubootenv_add_uci_config "/dev/mtd0" "0xf0000" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd0" "0xf0000" "0x10000" "0x10000"
fi
;;
glinet,gl-mv1000)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x8000" "0x8000" "1"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x8000" "0x8000" "1"
;;
globalscale,espressobin|\
globalscale,espressobin-emmc|\
@@ -37,34 +37,34 @@ globalscale,espressobin-v7-emmc|\
globalscale,mochabin)
idx="$(find_mtd_index u-boot-env)"
if [ -n "$idx" ]; then
- ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" "1"
else
- ubootenv_add_uci_config "/dev/mtd0" "0x3f0000" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd0" "0x3f0000" "0x10000" "0x10000" "1"
fi
;;
marvell,armada8040-mcbin-doubleshot|\
marvell,armada8040-mcbin-singleshot)
- ubootenv_add_uci_config "/dev/mtd0" "0x3f0000" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd0" "0x3f0000" "0x10000" "0x10000" "1"
;;
linksys,wrt1200ac|\
linksys,wrt1900ac-v2|\
linksys,wrt1900acs)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x40000"
;;
linksys,wrt1900ac-v1)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x40000" "0x20000"
;;
linksys,wrt3200acm|\
linksys,wrt32x)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
methode,udpu|\
methode,edpu)
idx="$(find_mtd_index u-boot-env)"
if [ -n "$idx" ]; then
- ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" "1"
+ ubootenv_set_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000" "1"
else
- ubootenv_add_uci_config "/dev/mtd0" "0x180000" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd0" "0x180000" "0x10000" "0x10000"
fi
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2013 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -13,11 +13,12 @@ board=$(board_name)
case "$board" in
i2se,duckbill)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/mmcblk0" "0x20000" "0x20000"
ubootenv_add_uci_config "/dev/mmcblk0" "0x40000" "0x20000"
;;
olimex,imx23-olinuxino)
- ubootenv_add_uci_config "/dev/mmcblk0" "0x40000" "0x4000"
+ ubootenv_set_uci_config "/dev/mmcblk0" "0x40000" "0x4000"
;;
esac
@@ -2,7 +2,7 @@
# Copyright (C) 2013 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -14,10 +14,10 @@ board=$(board_name)
case "$board" in
"cloudengines,pogoplug"*|\
"shuttle,kd20")
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x2000" "0x20000" "1"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x2000" "0x20000" "1"
;;
"mitrastar,stg-212")
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x20000" "0x20000" "1"
;;
esac
@@ -5,7 +5,7 @@
# See /LICENSE for more information.
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -16,7 +16,7 @@ board=$(board_name)
case "$board" in
img,pistachio-marduk)
- ubootenv_add_uci_config "/dev/mtd2" "0x0" "0x2000" "0x1000"
+ ubootenv_set_uci_config "/dev/mtd2" "0x0" "0x2000" "0x1000"
;;
esac
@@ -1,4 +1,4 @@
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
touch /etc/config/ubootenv
@@ -9,7 +9,7 @@ board=$(board_name)
case "$board" in
watchguard,firebox-m300)
- ubootenv_add_uci_config "/dev/mtd9" "0x0" "0x2000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd9" "0x0" "0x2000" "0x10000"
;;
esac
@@ -2,7 +2,8 @@
# Copyright (C) 2011-2012 OpenWrt.org
#
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
+rm -f /etc/fw_sys.config
touch /etc/config/ubootenv
@@ -19,21 +20,21 @@ alfa-network,r36m-e4g|\
alfa-network,tube-e4g|\
engenius,esr600h|\
sitecom,wlr-4100-v1-002)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x1000"
;;
allnet,all0256n-4m|\
allnet,all0256n-8m|\
allnet,all5002|\
yuncore,ax820)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x10000" "0x10000"
;;
ampedwireless,ally-00x19k|\
ampedwireless,ally-r1900k)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" "4"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000" "4"
;;
beeline,smartbox-giga|\
beeline,smartbox-turbo)
- ubootenv_add_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd0" "0x80000" "0x1000" "0x20000"
;;
buffalo,wsr-1166dhp|\
buffalo,wsr-600dhp|\
@@ -45,7 +46,7 @@ xiaomi,mi-router-4c|\
xiaomi,miwifi-nano|\
zbtlink,zbt-wg2626|\
zte,mf283plus)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
;;
belkin,rt1800|\
h3c,tx1800-plus|\
@@ -54,10 +55,11 @@ h3c,tx1806|\
jcg,q20|\
linksys,e7350|\
netgear,wax202)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x20000" "0x20000"
;;
hootoo,ht-tm05|\
ravpower,rp-wd03)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x4000" "0x1000" "0x1000"
@@ -70,11 +72,12 @@ linksys,ea7500-v2|\
linksys,ea8100-v1|\
linksys,ea8100-v2|\
mts,wg430223)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000"
;;
xiaomi,mi-router-3g-v2|\
xiaomi,mi-router-4a-gigabit|\
xiaomi,miwifi-3c)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x10000"
ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x4000" "0x10000"
;;
@@ -83,13 +86,15 @@ xiaomi,mi-router-3-pro|\
xiaomi,mi-router-4|\
xiaomi,mi-router-ac2100|\
xiaomi,redmi-router-ac2100)
+ ubootenv_clear_uci_config
ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x20000"
ubootenv_add_uci_sys_config "/dev/mtd2" "0x0" "0x4000" "0x20000"
;;
zyxel,lte3301-plus)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x1000" "0x80000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x1000" "0x80000"
;;
zyxel,nr7101)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index Config)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x1000" "0x80000"
@@ -98,7 +103,7 @@ bolt,arion|\
xiaomi,mi-router-cr6606|\
xiaomi,mi-router-cr6608|\
xiaomi,mi-router-cr6609)
- ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
+ ubootenv_set_uci_config "/dev/mtd1" "0x0" "0x10000" "0x20000"
;;
esac
@@ -1,4 +1,5 @@
-[ -e /etc/config/ubootenv ] && exit 0
+rm -f /etc/fw_env.config
+rm -f /etc/fw_sys.config
touch /etc/config/ubootenv
@@ -22,6 +23,7 @@ zyxel,gs1900-24-v1|\
zyxel,gs1900-24e|\
zyxel,gs1900-24hp-v1|\
zyxel,gs1900-24hp-v2)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x400" "0x10000"
@@ -32,11 +34,13 @@ zyxel,gs1900-24hp-v2)
tplink,sg2008p-v1|\
tplink,sg2210p-v3|\
tplink,sg2452p-v4)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x20000" "0x10000"
;;
iodata,bsh-g24mb)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
@@ -45,6 +49,7 @@ iodata,bsh-g24mb)
ubootenv_add_uci_sys_config "/dev/mtd$idx2" "0x0" "0x3800" "0x10000"
;;
*)
+ ubootenv_clear_uci_config
idx="$(find_mtd_index u-boot-env)"
[ -n "$idx" ] && \
ubootenv_add_uci_config "/dev/mtd$idx" "0x0" "0x10000" "0x10000"
@@ -21,10 +21,20 @@ EOF
uci commit ubootenv
}
+ubootenv_clear_uci_config() {
+ rm -f /etc/config/ubootenv
+ touch /etc/config/ubootenv
+}
+
ubootenv_add_uci_config() {
_ubootenv_add_uci_config "ubootenv" "$@"
}
+ubootenv_set_uci_config() {
+ ubootenv_clear_uci_config
+ _ubootenv_add_uci_config "ubootenv" "$@"
+}
+
ubootenv_add_uci_sys_config() {
_ubootenv_add_uci_config "ubootsys" "$@"
}
For devices with a NAND and a NOR chip, it was noticed that the order of initialization can be different between various kernel versions (4.4 vs. 5.4). As result, the mtd index changes for the u-boot-env partition - but the uboot-envtool still kept the old partition index. And since some devices write (for example during sysupgrade) to the u-boot-env, a unrelated partition would be overwritten. This would often brick the device. For example, a device with dualboot_datachk upgrade procedure with kernel A (first intializes NOR and then NAND) which is upgrade to kernel B (first initializes NAND and then NOR) would end up in a bricket state because the device: 1. kernel A is (factory) installed on device 2. firstboot scripts initialize /etc/fw_env.config to point to mtd6 3. kernel B is installed on device via sysupgrade (no extra options) * during upgrade some information is written to mtd6 (u-boot-env) 4. firstboot script will not do anything when kernel B booted -> /etc/fw_env.config still points to mtd6 (now the "0:RPM" partition) 5. sysupgrade is started again * some information should be written to u-boot-env but the upgrade script will now overwrite some important information of "0:RPM" (mtd6) 6. boot fails because the secondary bootload is unable to load the iamge from 0:RPM. u-boot will then never be started because the SBL caused a panic before it was event tried to load it. This scenario cannot happen when the /etc/fw_env.config is not preserved and instead autogenerated after each firmware installation. There might still be a good reason to restore the values from uci in case there is no code to auto-generate the settings. Fixes: 7f00e5ffc671 ("uboot-envtools: update to 2012.04.01") Signed-off-by: Sven Eckelmann <sven@narfation.org> --- The safest method to reproduce the problem without killing your system is to use a board which usually doesn't use fw_setenv but has an accessible u-boot-env. 1. flash the device with your test firmware 2. check that fw_printenv works 3. write bogus values in your u-boot-env configuration: echo '/dev/mtd99 0x0 0x00010000 0x00010000 1' > /etc/fw_env.config uci set ubootenv.@ubootenv[0].dev='/dev/mtd6' uci commit ubootenv 4. sysupgrade the device 5. check if fw_printenv works again