mirror of
https://github.com/Telecominfraproject/wlan-ap.git
synced 2025-10-29 09:32:34 +00:00
ipq53xx: move uboot-envtool support into the platform folder
Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
[ -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
|
||||
@@ -1,73 +0,0 @@
|
||||
From 17a5d31e89f00f8590967d85466f3cdb69601772 Mon Sep 17 00:00:00 2001
|
||||
From: John Crispin <john@phrozen.org>
|
||||
Date: Sat, 20 Apr 2024 11:40:41 +0200
|
||||
Subject: [PATCH] uboot-envtools: add ipq53xx support
|
||||
|
||||
Signed-off-by: John Crispin <john@phrozen.org>
|
||||
---
|
||||
package/boot/uboot-envtools/files/ipq53xx | 53 +++++++++++++++++++++++
|
||||
1 file changed, 53 insertions(+)
|
||||
create mode 100644 package/boot/uboot-envtools/files/ipq53xx
|
||||
|
||||
diff --git a/package/boot/uboot-envtools/files/ipq53xx b/package/boot/uboot-envtools/files/ipq53xx
|
||||
new file mode 100644
|
||||
index 0000000000..8863df4225
|
||||
--- /dev/null
|
||||
+++ b/package/boot/uboot-envtools/files/ipq53xx
|
||||
@@ -0,0 +1,53 @@
|
||||
+[ -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
|
||||
--
|
||||
2.34.1
|
||||
|
||||
Reference in New Issue
Block a user