[openwrt/openwrt] mediatek: mt7622: improve fixup of trx for Buffalo devices

LEDE Commits lede-commits at lists.infradead.org
Sat Jan 4 09:56:23 PST 2025


hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/5d0f61e957ff19a7f6ad0b733c8b422f965525c5

commit 5d0f61e957ff19a7f6ad0b733c8b422f965525c5
Author: INAGAKI Hiroshi <musashino.open at gmail.com>
AuthorDate: Sat Dec 28 17:38:11 2024 +0900

    mediatek: mt7622: improve fixup of trx for Buffalo devices
    
    Unify the common part to the function and don't fixup trx when booting
    with initramfs image.
    
    Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
    Link: https://github.com/openwrt/openwrt/pull/17408
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 .../mt7622/base-files/etc/uci-defaults/09_fix_crc      | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/09_fix_crc b/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/09_fix_crc
index 59b00a6e69..25c8a0359b 100644
--- a/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/09_fix_crc
+++ b/target/linux/mediatek/mt7622/base-files/etc/uci-defaults/09_fix_crc
@@ -1,14 +1,22 @@
 . /lib/functions.sh
 
-kernel_size=$(sed -n 's/mtd[0-9]*: \([0-9a-f]*\).*"\(kernel\|linux\)".*/\1/p' /proc/mtd)
+# don't modify FW data when booting with initramfs image
+fstype="$(/bin/mount | awk '($3 ~ /^\/$/) && ($5 !~ /rootfs/) { print $5 }')"
+[ "$fstype" = "tmpfs" ] && \
+	exit 0
+
+fixup_trx_crc() {
+	local trx_magic="$1"
+	local kernel_size=$(sed -n 's/mtd[0-9]*: \([0-9a-f]*\).*"\(kernel\|linux\)".*/\1/p' /proc/mtd)
+
+	mtd -M $trx_magic ${kernel_size:+-c 0x$kernel_size} fixtrx firmware
+}
 
 case "$(board_name)" in
 buffalo,wsr-2533dhp2)
-	mtd -M 0x44485032 ${kernel_size:+-c 0x$kernel_size} fixtrx firmware && exit 0
-	exit 1
+	fixup_trx_crc 0x44485032
 	;;
 buffalo,wsr-3200ax4s)
-	mtd -M 0x44485033 ${kernel_size:+-c 0x$kernel_size} fixtrx firmware && exit 0
-	exit 1
+	fixup_trx_crc 0x44485033
 	;;
 esac




More information about the lede-commits mailing list