mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-12-16 17:01:37 +00:00
54 lines
1.5 KiB
Plaintext
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
|