wlan-ap-Telecominfraproject/feeds/qca-wifi-7/ipq53xx/base-files/etc/uci-defaults/30_uboot-envtools
wingate5678 b8484ff023 WIFI-14997 Multi BDF support for Sonicfi series
Signed-off-by: wingate5678 <wingate.chi@cybertan.com.tw>
2025-08-28 09:23:20 +00:00

54 lines
1.5 KiB
Plaintext

[ -e /etc/config/ubootenv ] && rm /etc/config/ubootenv
touch /etc/config/ubootenv
. /lib/uboot-envtools.sh
. /lib/functions.sh
board=$(board_name)
ubootenv_mtdinfo () {
UBOOTENV_PART=$(cat /proc/mtd | grep APPSBLENV)
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}')
nor_flash=$(find /sys/bus/spi/devices/*/mtd -name ${mtd_dev})
found_emmc=0
if [ -z "$UBOOTENV_PART" ]; then
mtd_dev=$(echo $(find_mmc_part "0:APPSBLENV") | sed 's/^.\{5\}//')
if [ -n "$mtd_dev" ]; then
EMMC_UBOOTENV_PART=$(cat /proc/partitions | grep $mtd_dev)
#convert block to bytes
emmc_ubootenv_size=`expr $(echo $EMMC_UBOOTENV_PART | awk '{print $3}') \* 1024`
ubootenv_size=0x`printf "%x" $emmc_ubootenv_size`
found_emmc=1
fi
mtd_erase=""
elif [ -n "$nor_flash" ]; then
ubootenv_size=$mtd_size
else
# size is fixed to 0x40000 in u-boot
ubootenv_size=0x40000
fi
if [ $found_emmc -eq 0 ]; then
sectors=$(printf '0x%x' $(( $ubootenv_size / $mtd_erase )))
echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
else
echo /dev/$mtd_dev 0x0 $ubootenv_size
fi
}
case "$board" in
*)
ubootenv_add_uci_config $(ubootenv_mtdinfo)
;;
esac
config_load ubootenv
config_foreach ubootenv_add_app_config ubootenv
exit 0