Files
wlan-ap/patches/ipq807x/0008-Add-fw_printenv-support-for-EMMC.patch
Ken 43fa167f14 ipq807x: Add WF-660a support
Fixes: WIFI-12280
Signed-off-by: Ken <xshi@actiontec.com>
2023-02-22 10:03:05 +01:00

79 lines
2.7 KiB
Diff

From 3353a474f9cda9a61101c7f57cec2b991503c73e Mon Sep 17 00:00:00 2001
From: Ken <xshi@actiontec.com>
Date: Tue, 7 Feb 2023 14:39:52 +0800
Subject: [PATCH] Add fw_printenv support for EMMC
---
package/base-files/files/lib/functions.sh | 13 ++++++++++++
package/boot/uboot-envtools/files/ipq807x | 24 +++++++++++++++++++----
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 2bad45324f..415e0763ed 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -32,6 +32,19 @@ xor() {
printf "%0${retlen}x" "$ret"
}
+find_mmc_part() {
+ local DEVNAME PARTNAME
+ if grep -q "$1" /proc/mtd; then
+ echo "" && return 0
+ fi
+
+ for DEVNAME in /sys/block/mmcblk*/mmcblk*p*; do
+ PARTNAME=$(grep PARTNAME ${DEVNAME}/uevent | cut -f2 -d'=')
+ [ "$PARTNAME" = "$1" ] && echo "/dev/$(basename $DEVNAME)" && return 0
+ done
+}
+
+
append() {
local var="$1"
local value="$2"
diff --git a/package/boot/uboot-envtools/files/ipq807x b/package/boot/uboot-envtools/files/ipq807x
index 84ed73f288..539cafb3fd 100644
--- a/package/boot/uboot-envtools/files/ipq807x
+++ b/package/boot/uboot-envtools/files/ipq807x
@@ -13,16 +13,32 @@ ubootenv_mtdinfo () {
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})
-
- if [ -n "$nor_flash" ]; then
+ 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
- sectors=$(printf '0x%x' $(( $ubootenv_size / $mtd_erase )))
- echo /dev/$mtd_dev 0x0 $ubootenv_size $mtd_erase $sectors
}
case "$board" in
--
2.34.1