Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mediatek: switch to fitblk for cmcc rax3000m #15054

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

1715173329
Copy link
Member

Use the new fitblk driver.

@github-actions github-actions bot added core packages pull request/issue for core (in-tree) packages target/mediatek pull request/issue for mediatek target labels Apr 2, 2024
@981213
Copy link
Member

981213 commented Apr 3, 2024

If this needs a u-boot update, you should also bump compat-version to prevent accidental sysupgrade from users.

@1715173329
Copy link
Member Author

If this needs a u-boot update, you should also bump compat-version to prevent accidental sysupgrade from users.

I added bootargs-override to dts so u-boot update is not necessary.

@1715173329 1715173329 force-pushed the master-mediatek-rax3000m branch 2 times, most recently from e903aa3 to 9e4bcaf Compare April 4, 2024 04:41
@1715173329 1715173329 marked this pull request as ready for review April 4, 2024 04:41
@981213
Copy link
Member

981213 commented Apr 24, 2024

Upgrading from initramfs on first flash is broken after applying this PR:

Thu Jan  1 00:01:00 UTC 1970 upgrade: Switching to ramdisk...
Thu Jan  1 00:01:01 UTC 1970 upgrade: Performing system upgrade...
Thu Jan  1 00:01:01 UTC 1970 upgrade: Upgrade completed
Thu Jan  1 00:01:02 UTC 1970 upgrade: Rebooting system...

When flashing from vendor firmware, we first wrote bl2 and u-boot to the flash, reboot and wait for it to load initramfs. In this scenario, there is no fit partition on UBI and fitblk_get_bootdev fails.

@1715173329
Copy link
Member Author

Yep, it needs more love, see #14993 (comment).

@981213
Copy link
Member

981213 commented Apr 24, 2024

Another possible workaround: In u-boot script, when the fit partition is missing, attempt to load sysupgrade.bin and write it to flash first, instead of tftpboot the recovery image directly.

@cyyself
Copy link
Contributor

cyyself commented Apr 30, 2024

Another possible workaround: In u-boot script, when the fit partition is missing, attempt to load sysupgrade.bin and write it to flash first, instead of tftpboot the recovery image directly.

I think maybe we should not do this in U-boot. Perhaps we should change the sysupgrade process when there is no fit partition.

@zcy85611
Copy link

I've patched the latest code with this pull request, wifi is not working , it seems that eeprom cannot be read correctly


Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494]
Wed May  8 08:54:42 2024 kern.info kernel: [   13.750845] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
Wed May  8 08:54:42 2024 kern.info kernel: [   13.877704] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.969098] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.975885] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.987030] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   14.046027] mt798x-wmac: probe of 18000000.wifi failed with error -12

@cyyself
Copy link
Contributor

cyyself commented May 10, 2024

I've patched the latest code with this pull request, wifi is not working , it seems that eeprom cannot be read correctly


Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494]
Wed May  8 08:54:42 2024 kern.info kernel: [   13.750845] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
Wed May  8 08:54:42 2024 kern.info kernel: [   13.877704] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.969098] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.975885] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.987030] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   14.046027] mt798x-wmac: probe of 18000000.wifi failed with error -12

Ohhh. I haven't tested it on the NAND version of rax3000m. The eMMC version is OK at that time. Maybe I can perform a test tomorrow.

@zcy85611
Copy link

I've patched the latest code with this pull request, wifi is not working , it seems that eeprom cannot be read correctly


Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
Wed May  8 08:54:42 2024 kern.info kernel: [   13.567494]
Wed May  8 08:54:42 2024 kern.info kernel: [   13.750845] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
Wed May  8 08:54:42 2024 kern.info kernel: [   13.877704] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.969098] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.975885] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
Wed May  8 08:54:42 2024 kern.warn kernel: [   13.987030] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
Wed May  8 08:54:42 2024 kern.warn kernel: [   14.046027] mt798x-wmac: probe of 18000000.wifi failed with error -12

Ohhh. I haven't tested it on the NAND version of rax3000m. The eMMC version is OK at that time. Maybe I can perform a test tomorrow.

I forgot to mention, I tested it on EMMC version

@981213
Copy link
Member

981213 commented May 11, 2024

I have the nand version and it works fine, except the initial flash problem mentioned before. (BTW this is why I haven't merged it)

@cyyself
Copy link
Contributor

cyyself commented May 11, 2024

I confirmed this on my rax3000m emmc version. I will try to figure it out.

[   13.772428] mt798x-wmac 18000000.wifi: attaching wed device 0 version 2
[   13.869103] urngd: v1.0.2 started.
[   13.898366] platform 15010000.wed: MTK WED WO Firmware Version: DEV_000000, Build Time: 20221208202138
[   13.907720] platform 15010000.wed: MTK WED WO Chip ID 00 Region 3
[   14.464906] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
[   14.464906]
[   14.652856] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
[   14.779019] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
[   14.871325] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
[   14.878124] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
[   14.889248] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
[   14.996547] mt798x-wmac: probe of 18000000.wifi failed with error -12
[   15.031570] PPP generic driver version 2.4.2
[   15.037054] NET: Registered PF_PPPOX protocol family
[   15.044192] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[   15.052115] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
[   15.064933] kmodloader: done loading kernel modules from /etc/modules.d/*
[   19.058339] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   19.075325] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[   19.084654] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[   19.101655] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
[   19.113824] br-lan: port 1(lan1) entered blocking state
[   19.119140] br-lan: port 1(lan1) entered disabled state
[   19.124399] mt7530-mdio mdio-bus:1f lan1: entered allmulticast mode
[   19.130743] mtk_soc_eth 15100000.ethernet eth0: entered allmulticast mode
[   19.141428] mt7530-mdio mdio-bus:1f lan1: entered promiscuous mode
[   19.166664] mt7530-mdio mdio-bus:1f lan2: configuring for phy/gmii link mode
[   19.179158] br-lan: port 2(lan2) entered blocking state
[   19.184395] br-lan: port 2(lan2) entered disabled state
[   19.189728] mt7530-mdio mdio-bus:1f lan2: entered allmulticast mode
[   19.199532] mt7530-mdio mdio-bus:1f lan2: entered promiscuous mode
[   19.219109] mt7530-mdio mdio-bus:1f lan3: configuring for phy/gmii link mode
[   19.231902] br-lan: port 3(lan3) entered blocking state
[   19.237222] br-lan: port 3(lan3) entered disabled state
[   19.242511] mt7530-mdio mdio-bus:1f lan3: entered allmulticast mode
[   19.252600] mt7530-mdio mdio-bus:1f lan3: entered promiscuous mode
[   19.312069] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:00] driver [MediaTek MT7981 PHY] (irq=POLL)
[   19.321717] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/gmii link mode
[   19.355898] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
[   22.483040] mt7530-mdio mdio-bus:1f lan3: Link is Up - 1Gbps/Full - flow control rx/tx
[   22.491007] br-lan: port 3(lan3) entered blocking state
[   22.496225] br-lan: port 3(lan3) entered forwarding state
[   22.546933] br-lan: entered allmulticast mode
[   23.657937] br-lan: left allmulticast mode
[   23.727177] br-lan: entered allmulticast mode
[   33.692588] br-lan: left allmulticast mode
[   33.758390] br-lan: entered allmulticast mode
root@CYY-NR:~# uname -a
Linux CYY-NR 6.6.30 #0 SMP Fri May 10 12:11:28 2024 aarch64 GNU/Linux
root@CYY-NR:~#

@1715173329
Copy link
Member Author

I got it. hotplug script needs a update.

@cyyself
Copy link
Contributor

cyyself commented May 11, 2024

I reviewed the original rax3000m support PR and found something we forgot to change. Please apply this diff:

diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 648ecb9289..8f5da0271a 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -2,6 +2,7 @@
 . /lib/functions.sh
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh

 mediatek_setup_interfaces()
 {
@@ -127,8 +128,8 @@ mediatek_setup_macs()
 		wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			wan_mac=$(mmc_get_mac_binary factory 0x2a)
 			lan_mac=$(mmc_get_mac_binary factory 0x24)
 			label_mac=$wan_mac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
index bd68ef7415..5f2949c93d 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
@@ -3,6 +3,7 @@
 [ -e /lib/firmware/$FIRMWARE ] && exit 0

 . /lib/functions/caldata.sh
+. /lib/upgrade/common.sh

 board=$(board_name)

@@ -25,8 +26,8 @@ case "$FIRMWARE" in
 "mediatek/mt7981_eeprom_mt7976_dbdc.bin")
 	case "$board" in
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			caldata_extract_mmc "factory" 0x0 0x1000
 			;;
 		esac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 75c3d25ed9..9c06d52a03 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -6,6 +6,7 @@ PHYNBR=${DEVPATH##*/phy}

 . /lib/functions.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh

 board=$(board_name)

@@ -55,8 +56,8 @@ case "$board" in
 		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			addr=$(mmc_get_mac_binary factory 0xa)
 			;;
 		*)

Now it works fine:

 ✘ cyy@Yangyus-MBP  ~  ssh root@192.168.1.1


BusyBox v1.36.1 (2024-05-10 12:11:28 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r26276-e850771b18
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# dmesg
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 6.6.30 (cyy@cyy-pc) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 13.2.0 r26276-e850771b18) 13.2.0, GNU ld (GNU Binutils) 2.42) #0 SMP Fri May 10 12:11:28 2024
[    0.000000] Machine model: CMCC RAX3000M
[    0.000000] OF: reserved mem: 0x0000000042ff0000..0x0000000042ffffff (64 KiB) map non-reusable ramoops@42ff0000
[    0.000000] OF: reserved mem: 0x0000000043000000..0x000000004302ffff (192 KiB) nomap non-reusable secmon@43000000
[    0.000000] OF: reserved mem: 0x0000000047c80000..0x0000000047d7ffff (1024 KiB) nomap non-reusable wmcpu-reserved@47c80000
[    0.000000] OF: reserved mem: 0x0000000047d80000..0x0000000047dbffff (256 KiB) nomap non-reusable wo-emi@47d80000
[    0.000000] OF: reserved mem: 0x0000000047dc0000..0x0000000047ffffff (2304 KiB) nomap non-reusable wo-data@47dc0000
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x0000000042ffffff]
[    0.000000]   node   0: [mem 0x0000000043000000-0x000000004302ffff]
[    0.000000]   node   0: [mem 0x0000000043030000-0x0000000047c7ffff]
[    0.000000]   node   0: [mem 0x0000000047c80000-0x0000000047ffffff]
[    0.000000]   node   0: [mem 0x0000000048000000-0x000000005fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.4
[    0.000000] percpu: Embedded 18 pages/cpu s34536 r8192 d31000 u73728
[    0.000000] pcpu-alloc: s34536 r8192 d31000 u73728 alloc=18*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Kernel command line: root=/dev/fit0 rootwait
[    0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129024
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: SWIOTLB bounce buffer size adjusted to 0MB
[    0.000000] software IO TLB: area num 2.
[    0.000000] software IO TLB: mapped [mem 0x000000005f540000-0x000000005f5c0000] (0MB)
[    0.000000] Memory: 496916K/524288K available (8512K kernel code, 894K rwdata, 2504K rodata, 384K init, 287K bss, 27372K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 640 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: GICv3 features: 16 PPIs
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x000000000c080000
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] arch_timer: cp15 timer(s) running at 13.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2ff89eacb, max_idle_ns: 440795202429 ns
[    0.000000] sched_clock: 56 bits at 13MHz, resolution 76ns, wraps every 4398046511101ns
[    0.000075] Calibrating delay loop (skipped), value calculated using timer frequency.. 26.00 BogoMIPS (lpj=130000)
[    0.000084] pid_max: default: 32768 minimum: 301
[    0.003002] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.003011] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.005134] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.005683] RCU Tasks Trace: Setting shift to 1 and lim to 1 rcu_task_cb_adjust=1.
[    0.005843] rcu: Hierarchical SRCU implementation.
[    0.005846] rcu:     Max phase no-delay instances is 1000.
[    0.006261] smp: Bringing up secondary CPUs ...
[    0.006641] Detected VIPT I-cache on CPU1
[    0.006688] GICv3: CPU1: found redistributor 1 region 0:0x000000000c0a0000
[    0.006719] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.006793] smp: Brought up 1 node, 2 CPUs
[    0.006799] SMP: Total of 2 processors activated.
[    0.006802] CPU features: detected: 32-bit EL0 Support
[    0.006805] CPU features: detected: CRC32 instructions
[    0.006836] CPU features: emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching
[    0.006839] CPU: All CPU(s) started at EL2
[    0.006842] alternatives: applying system-wide alternatives
[    0.010132] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.010149] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.011412] pinctrl core: initialized pinctrl subsystem
[    0.012278] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.012902] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.012934] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.012957] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.013344] thermal_sys: Registered thermal governor 'fair_share'
[    0.013349] thermal_sys: Registered thermal governor 'bang_bang'
[    0.013352] thermal_sys: Registered thermal governor 'step_wise'
[    0.013354] thermal_sys: Registered thermal governor 'user_space'
[    0.013442] ASID allocator initialised with 65536 entries
[    0.014488] pstore: Using crash dump compression: deflate
[    0.014494] pstore: Registered ramoops as persistent store backend
[    0.014496] ramoops: using 0x10000@0x42ff0000, ecc: 0
[    0.021753] Modules: 29584 pages in range for non-PLT usage
[    0.021761] Modules: 521104 pages in range for PLT usage
[    0.022783] cryptd: max_cpu_qlen set to 1000
[    0.024864] SCSI subsystem initialized
[    0.025312] libata version 3.00 loaded.
[    0.026853] clocksource: Switched to clocksource arch_sys_counter
[    0.029194] NET: Registered PF_INET protocol family
[    0.029315] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.030592] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.030609] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.030618] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.030649] TCP bind hash table entries: 4096 (order: 5, 131072 bytes, linear)
[    0.030757] TCP: Hash tables configured (established 4096 bind 4096)
[    0.030840] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.030867] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.031089] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.031119] PCI: CLS 0 bytes, default 64
[    0.032924] workingset: timestamp_bits=46 max_order=17 bucket_order=0
[    0.037751] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.037759] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.081338] Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
[    0.082685] printk: console [ttyS0] disabled
[    0.103039] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 72, base_baud = 2500000) is a ST16650V2
[    0.103083] printk: console [ttyS0] enabled
[    0.834181] loop: module loaded
[    0.968157] mtk_soc_eth 15100000.ethernet: generated random MAC address 65:74:68:25:64:00
[    0.976349] mtk_soc_eth 15100000.ethernet: generated random MAC address 65:74:68:25:64:00
[    0.999631] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc081400000, irq 74
[    1.009626] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc081400000, irq 74
[    1.019452] i2c_dev: i2c /dev entries driver
[    1.025595] mtk-wdt 1001c000.watchdog: Watchdog enabled (timeout=31 sec, nowayout=0)
[    1.034680] NET: Registered PF_INET6 protocol family
[    1.040782] Segment Routing with IPv6
[    1.044473] In-situ OAM (IOAM) with IPv6
[    1.048470] NET: Registered PF_PACKET protocol family
[    1.053682] 8021q: 802.1Q VLAN Support v1.8
[    1.085540] phy phy-soc:usb-phy@11e10000.1: type_sw - reg 0x218, index 0
[    1.145057] mt7530-mdio mdio-bus:1f: configuring for fixed/2500base-x link mode
[    1.153828] mt7530-mdio mdio-bus:1f: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    1.163125] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7531 PHY] (irq=79)
[    1.178087] mmc0: new MMC card at address 0001
[    1.183800] mmcblk0: mmc0:0001 A3A561 57.6 GiB
[    1.194229] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7531 PHY] (irq=80)
[    1.210077]  mmcblk0: p1 p2 p3 p4 p5 p6 p128
[    1.215997] mmcblk0boot0: mmc0:0001 A3A561 4.00 MiB
[    1.221713] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7531 PHY] (irq=81)
[    1.222520] mmcblk0boot1: mmc0:0001 A3A561 4.00 MiB
[    1.233817] mtk_soc_eth 15100000.ethernet eth0: entered promiscuous mode
[    1.237334] mmcblk0rpmb: mmc0:0001 A3A561 16.0 MiB, chardev (251:0)
[    1.243714] DSA: tree 0 setup
[    1.254262] FIT: Detected U-Boot 2023.07.02-OpenWrt-r23630-842932a63d
[    1.260747] FIT: Selected configuration: "config-1" (OpenWrt cmcc_rax3000m)
[    1.267720] FIT:           kernel sub-image 0x00001000..0x0055e13d "kernel-1" (ARM64 OpenWrt Linux-6.6.30)
[    1.277463] FIT:          flat_dt sub-image 0x0055f000..0x0056514f "fdt-1" (ARM64 OpenWrt cmcc_rax3000m device tree blob)
[    1.288508] FIT:          flat_dt sub-image 0x00566000..0x0056665b "fdt-mt7981b-cmcc-rax3000m-emmc" (ARM64 OpenWrt cmcc_rax3000m device tree overlay mt7981b-cmcc-rax3000m-emmc)
[    1.304324] FIT:          flat_dt sub-image 0x00567000..0x00567d0d "fdt-mt7981b-cmcc-rax3000m-nand" (ARM64 OpenWrt cmcc_rax3000m device tree overlay mt7981b-cmcc-rax3000m-nand)
[    1.320136] FIT:       filesystem sub-image 0x00568000..0x00b0afff "rootfs-1" (ARM64 OpenWrt cmcc_rax3000m rootfs)
[    1.331123] block mmcblk0p5: mapped 1 uImage.FIT filesystem sub-image as /dev/fit0
[    1.339197] block mmcblk0p5: mapped remaing space as /dev/fitrw
[    1.345319] clk: Disabling unused clocks
[    1.357806] VFS: Mounted root (squashfs filesystem) readonly on device 259:1.
[    1.365110] Freeing unused kernel memory: 384K
[    1.369627] Run /sbin/init as init process
[    1.373712]   with arguments:
[    1.376666]     /sbin/init
[    1.379367]   with environment:
[    1.382495]     HOME=/
[    1.384842]     TERM=linux
[    1.559595] init: Console is alive
[    1.563130] init: - watchdog -
[    1.982058] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.013772] usbcore: registered new interface driver usbfs
[    2.019345] usbcore: registered new interface driver hub
[    2.024700] usbcore: registered new device driver usb
[    2.030570] gpio_button_hotplug: loading out-of-tree module taints kernel.
[    2.042850] xhci-mtk 11200000.usb: supply vbus not found, using dummy regulator
[    2.051161] xhci-mtk 11200000.usb: xHCI Host Controller
[    2.056405] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 1
[    2.066835] xhci-mtk 11200000.usb: hcc params 0x01403f99 hci version 0x110 quirks 0x0000000000200010
[    2.076017] xhci-mtk 11200000.usb: irq 82, io mem 0x11200000
[    2.081809] xhci-mtk 11200000.usb: xHCI Host Controller
[    2.087067] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 2
[    2.094460] xhci-mtk 11200000.usb: Host supports USB 3.2 Enhanced SuperSpeed
[    2.102088] hub 1-0:1.0: USB hub found
[    2.105885] hub 1-0:1.0: 1 port detected
[    2.110209] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    2.118790] hub 2-0:1.0: USB hub found
[    2.122582] hub 2-0:1.0: 1 port detected
[    2.132268] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.148835] init: - preinit -
[    2.500556] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[    2.509306] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    2.522837] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
[    4.692670] mount_root: overlay filesystem in /dev/fitrw has not been formatted yet
[    7.612313] F2FS-fs (fitrw): Found nat_bits in checkpoint
[    7.641451] F2FS-fs (fitrw): Mounted with checkpoint version = 5ccce271
[    7.648902] mount_root: overlay filesystem has not been fully initialized yet
[    7.656374] mount_root: switching to f2fs overlay
[    7.661839] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off.
[    7.673188] urandom-seed: Seed file not found (/etc/urandom.seed)
[    7.726111] random: procd: uninitialized urandom read (4 bytes read)
[    7.729215] procd: - early -
[    7.735527] procd: - watchdog -
[    8.288721] procd: - watchdog -
[    8.292329] procd: - ubus -
[   13.366858] random: crng init done
[   13.379638] procd: - init -
[   13.719169] kmodloader: loading kernel modules from /etc/modules.d/*
[   13.746035] crypto-safexcel 10320000.crypto: EIP97:230(0,1,4,4)-HIA:270(0,5,5),PE:150/433(alg:7fcdfc00)/0/0/0
[   13.763735] Loading modules backported from Linux version v6.6.15-0-g51f354b815c4
[   13.771345] Backport generated by backports.git 193becf2
[   13.920271] urngd: v1.0.2 started.
[   14.161819] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
[   14.161819]
[   14.349336] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
[   14.477559] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
[   14.570010] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
[   14.576793] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
[   14.587923] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
[   14.712363] mt798x-wmac 18000000.wifi: registering led 'mt76-phy0'
[   14.721169] mt798x-wmac 18000000.wifi: registering led 'mt76-phy1'
[   14.762660] PPP generic driver version 2.4.2
[   14.768615] NET: Registered PF_PPPOX protocol family
[   14.775978] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[   14.783969] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
[   14.798026] kmodloader: done loading kernel modules from /etc/modules.d/*
[   21.208735] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   21.222482] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[   21.233836] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[   21.251680] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
[   21.265725] br-lan: port 1(lan1) entered blocking state
[   21.271058] br-lan: port 1(lan1) entered disabled state
[   21.276318] mt7530-mdio mdio-bus:1f lan1: entered allmulticast mode
[   21.282672] mtk_soc_eth 15100000.ethernet eth0: entered allmulticast mode
[   21.293063] mt7530-mdio mdio-bus:1f lan1: entered promiscuous mode
[   21.313733] mt7530-mdio mdio-bus:1f lan2: configuring for phy/gmii link mode
[   21.330449] br-lan: port 2(lan2) entered blocking state
[   21.335695] br-lan: port 2(lan2) entered disabled state
[   21.341039] mt7530-mdio mdio-bus:1f lan2: entered allmulticast mode
[   21.350642] mt7530-mdio mdio-bus:1f lan2: entered promiscuous mode
[   21.366252] mt7530-mdio mdio-bus:1f lan3: configuring for phy/gmii link mode
[   21.378815] br-lan: port 3(lan3) entered blocking state
[   21.384054] br-lan: port 3(lan3) entered disabled state
[   21.389407] mt7530-mdio mdio-bus:1f lan3: entered allmulticast mode
[   21.398400] mt7530-mdio mdio-bus:1f lan3: entered promiscuous mode
[   21.442706] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:00] driver [MediaTek MT7981 PHY] (irq=POLL)
[   21.452358] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/gmii link mode
[   21.462768] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
[   24.408499] mt7530-mdio mdio-bus:1f lan3: Link is Up - 1Gbps/Full - flow control rx/tx
[   24.416457] br-lan: port 3(lan3) entered blocking state
[   24.421689] br-lan: port 3(lan3) entered forwarding state
[   71.317772] br-lan: port 4(phy1-ap0) entered blocking state
[   71.323481] br-lan: port 4(phy1-ap0) entered disabled state
[   71.329147] mt798x-wmac 18000000.wifi phy1-ap0: entered allmulticast mode
[   71.336174] mt798x-wmac 18000000.wifi phy1-ap0: entered promiscuous mode
[   71.343072] br-lan: port 4(phy1-ap0) entered blocking state
[   71.348669] br-lan: port 4(phy1-ap0) entered forwarding state
[   71.354690] br-lan: port 4(phy1-ap0) entered disabled state
[   72.451607] br-lan: port 4(phy1-ap0) entered blocking state
[   72.457212] br-lan: port 4(phy1-ap0) entered forwarding state
[   77.632641] br-lan: port 5(phy0-ap0) entered blocking state
[   77.638294] br-lan: port 5(phy0-ap0) entered disabled state
[   77.643902] mt798x-wmac 18000000.wifi phy0-ap0: entered allmulticast mode
[   77.650916] mt798x-wmac 18000000.wifi phy0-ap0: entered promiscuous mode
[   77.782610] br-lan: port 5(phy0-ap0) entered blocking state
[   77.788221] br-lan: port 5(phy0-ap0) entered forwarding state
root@OpenWrt:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1504 qdisc mq state UP qlen 1000
    link/ether b2:6f:31:**:**:33 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:60:61:**:**:24 brd ff:ff:ff:ff:ff:ff
4: lan3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
5: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br-lan state LOWERLAYERDOWN qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br-lan state LOWERLAYERDOWN qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
7: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
8: phy1-ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:23 brd ff:ff:ff:ff:ff:ff
9: phy0-ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:22 brd ff:ff:ff:ff:ff:ff
root@OpenWrt:~# uname -a
Linux OpenWrt 6.6.30 #0 SMP Fri May 10 12:11:28 2024 aarch64 GNU/Linux
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.8M      5.8M         0 100% /rom
tmpfs                   242.8M    252.0K    242.6M   0% /tmp
/dev/fitrw                1.8G     94.2M      1.7G   5% /overlay
overlayfs:/overlay        1.8G     94.2M      1.7G   5% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~#

@zcy85611
Copy link

I reviewed the original rax3000m support PR and found something we forgot to change. Please apply this diff:

diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 648ecb9289..8f5da0271a 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -2,6 +2,7 @@
 . /lib/functions.sh
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh

 mediatek_setup_interfaces()
 {
@@ -127,8 +128,8 @@ mediatek_setup_macs()
 		wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			wan_mac=$(mmc_get_mac_binary factory 0x2a)
 			lan_mac=$(mmc_get_mac_binary factory 0x24)
 			label_mac=$wan_mac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
index bd68ef7415..5f2949c93d 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
@@ -3,6 +3,7 @@
 [ -e /lib/firmware/$FIRMWARE ] && exit 0

 . /lib/functions/caldata.sh
+. /lib/upgrade/common.sh

 board=$(board_name)

@@ -25,8 +26,8 @@ case "$FIRMWARE" in
 "mediatek/mt7981_eeprom_mt7976_dbdc.bin")
 	case "$board" in
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			caldata_extract_mmc "factory" 0x0 0x1000
 			;;
 		esac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 75c3d25ed9..9c06d52a03 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -6,6 +6,7 @@ PHYNBR=${DEVPATH##*/phy}

 . /lib/functions.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh

 board=$(board_name)

@@ -55,8 +56,8 @@ case "$board" in
 		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			addr=$(mmc_get_mac_binary factory 0xa)
 			;;
 		*)

Now it works fine:

 ✘ cyy@Yangyus-MBP  ~  ssh root@192.168.1.1


BusyBox v1.36.1 (2024-05-10 12:11:28 UTC) built-in shell (ash)

  _______                     ________        __
 |       |.-----.-----.-----.|  |  |  |.----.|  |_
 |   -   ||  _  |  -__|     ||  |  |  ||   _||   _|
 |_______||   __|_____|__|__||________||__|  |____|
          |__| W I R E L E S S   F R E E D O M
 -----------------------------------------------------
 OpenWrt SNAPSHOT, r26276-e850771b18
 -----------------------------------------------------
=== WARNING! =====================================
There is no root password defined on this device!
Use the "passwd" command to set up a new password
in order to prevent unauthorized SSH logins.
--------------------------------------------------
root@OpenWrt:~# dmesg
[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 6.6.30 (cyy@cyy-pc) (aarch64-openwrt-linux-musl-gcc (OpenWrt GCC 13.2.0 r26276-e850771b18) 13.2.0, GNU ld (GNU Binutils) 2.42) #0 SMP Fri May 10 12:11:28 2024
[    0.000000] Machine model: CMCC RAX3000M
[    0.000000] OF: reserved mem: 0x0000000042ff0000..0x0000000042ffffff (64 KiB) map non-reusable ramoops@42ff0000
[    0.000000] OF: reserved mem: 0x0000000043000000..0x000000004302ffff (192 KiB) nomap non-reusable secmon@43000000
[    0.000000] OF: reserved mem: 0x0000000047c80000..0x0000000047d7ffff (1024 KiB) nomap non-reusable wmcpu-reserved@47c80000
[    0.000000] OF: reserved mem: 0x0000000047d80000..0x0000000047dbffff (256 KiB) nomap non-reusable wo-emi@47d80000
[    0.000000] OF: reserved mem: 0x0000000047dc0000..0x0000000047ffffff (2304 KiB) nomap non-reusable wo-data@47dc0000
[    0.000000] Zone ranges:
[    0.000000]   DMA      [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000]   DMA32    empty
[    0.000000]   Normal   empty
[    0.000000] Movable zone start for each node
[    0.000000] Early memory node ranges
[    0.000000]   node   0: [mem 0x0000000040000000-0x0000000042ffffff]
[    0.000000]   node   0: [mem 0x0000000043000000-0x000000004302ffff]
[    0.000000]   node   0: [mem 0x0000000043030000-0x0000000047c7ffff]
[    0.000000]   node   0: [mem 0x0000000047c80000-0x0000000047ffffff]
[    0.000000]   node   0: [mem 0x0000000048000000-0x000000005fffffff]
[    0.000000] Initmem setup node 0 [mem 0x0000000040000000-0x000000005fffffff]
[    0.000000] psci: probing for conduit method from DT.
[    0.000000] psci: PSCIv1.1 detected in firmware.
[    0.000000] psci: Using standard PSCI v0.2 function IDs
[    0.000000] psci: MIGRATE_INFO_TYPE not supported.
[    0.000000] psci: SMC Calling Convention v1.4
[    0.000000] percpu: Embedded 18 pages/cpu s34536 r8192 d31000 u73728
[    0.000000] pcpu-alloc: s34536 r8192 d31000 u73728 alloc=18*4096
[    0.000000] pcpu-alloc: [0] 0 [0] 1
[    0.000000] Detected VIPT I-cache on CPU0
[    0.000000] CPU features: detected: GIC system register CPU interface
[    0.000000] CPU features: kernel page table isolation disabled by kernel configuration
[    0.000000] alternatives: applying boot alternatives
[    0.000000] Kernel command line: root=/dev/fit0 rootwait
[    0.000000] Dentry cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
[    0.000000] Inode-cache hash table entries: 32768 (order: 6, 262144 bytes, linear)
[    0.000000] Built 1 zonelists, mobility grouping on.  Total pages: 129024
[    0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] software IO TLB: SWIOTLB bounce buffer size adjusted to 0MB
[    0.000000] software IO TLB: area num 2.
[    0.000000] software IO TLB: mapped [mem 0x000000005f540000-0x000000005f5c0000] (0MB)
[    0.000000] Memory: 496916K/524288K available (8512K kernel code, 894K rwdata, 2504K rodata, 384K init, 287K bss, 27372K reserved, 0K cma-reserved)
[    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=2, Nodes=1
[    0.000000] rcu: Hierarchical RCU implementation.
[    0.000000] rcu:     RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=2.
[    0.000000]  Tracing variant of Tasks RCU enabled.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 10 jiffies.
[    0.000000] rcu: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=2
[    0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
[    0.000000] GICv3: GIC: Using split EOI/Deactivate mode
[    0.000000] GICv3: 640 SPIs implemented
[    0.000000] GICv3: 0 Extended SPIs implemented
[    0.000000] Root IRQ handler: gic_handle_irq
[    0.000000] GICv3: GICv3 features: 16 PPIs
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x000000000c080000
[    0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
[    0.000000] arch_timer: cp15 timer(s) running at 13.00MHz (phys).
[    0.000000] clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x2ff89eacb, max_idle_ns: 440795202429 ns
[    0.000000] sched_clock: 56 bits at 13MHz, resolution 76ns, wraps every 4398046511101ns
[    0.000075] Calibrating delay loop (skipped), value calculated using timer frequency.. 26.00 BogoMIPS (lpj=130000)
[    0.000084] pid_max: default: 32768 minimum: 301
[    0.003002] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.003011] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.005134] cacheinfo: Unable to detect cache hierarchy for CPU 0
[    0.005683] RCU Tasks Trace: Setting shift to 1 and lim to 1 rcu_task_cb_adjust=1.
[    0.005843] rcu: Hierarchical SRCU implementation.
[    0.005846] rcu:     Max phase no-delay instances is 1000.
[    0.006261] smp: Bringing up secondary CPUs ...
[    0.006641] Detected VIPT I-cache on CPU1
[    0.006688] GICv3: CPU1: found redistributor 1 region 0:0x000000000c0a0000
[    0.006719] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.006793] smp: Brought up 1 node, 2 CPUs
[    0.006799] SMP: Total of 2 processors activated.
[    0.006802] CPU features: detected: 32-bit EL0 Support
[    0.006805] CPU features: detected: CRC32 instructions
[    0.006836] CPU features: emulated: Privileged Access Never (PAN) using TTBR0_EL1 switching
[    0.006839] CPU: All CPU(s) started at EL2
[    0.006842] alternatives: applying system-wide alternatives
[    0.010132] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.010149] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.011412] pinctrl core: initialized pinctrl subsystem
[    0.012278] NET: Registered PF_NETLINK/PF_ROUTE protocol family
[    0.012902] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
[    0.012934] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA pool for atomic allocations
[    0.012957] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
[    0.013344] thermal_sys: Registered thermal governor 'fair_share'
[    0.013349] thermal_sys: Registered thermal governor 'bang_bang'
[    0.013352] thermal_sys: Registered thermal governor 'step_wise'
[    0.013354] thermal_sys: Registered thermal governor 'user_space'
[    0.013442] ASID allocator initialised with 65536 entries
[    0.014488] pstore: Using crash dump compression: deflate
[    0.014494] pstore: Registered ramoops as persistent store backend
[    0.014496] ramoops: using 0x10000@0x42ff0000, ecc: 0
[    0.021753] Modules: 29584 pages in range for non-PLT usage
[    0.021761] Modules: 521104 pages in range for PLT usage
[    0.022783] cryptd: max_cpu_qlen set to 1000
[    0.024864] SCSI subsystem initialized
[    0.025312] libata version 3.00 loaded.
[    0.026853] clocksource: Switched to clocksource arch_sys_counter
[    0.029194] NET: Registered PF_INET protocol family
[    0.029315] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.030592] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.030609] Table-perturb hash table entries: 65536 (order: 6, 262144 bytes, linear)
[    0.030618] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.030649] TCP bind hash table entries: 4096 (order: 5, 131072 bytes, linear)
[    0.030757] TCP: Hash tables configured (established 4096 bind 4096)
[    0.030840] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.030867] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.031089] NET: Registered PF_UNIX/PF_LOCAL protocol family
[    0.031119] PCI: CLS 0 bytes, default 64
[    0.032924] workingset: timestamp_bits=46 max_order=17 bucket_order=0
[    0.037751] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    0.037759] jffs2: version 2.2 (NAND) (SUMMARY) (LZMA) (RTIME) (CMODE_PRIORITY) (c) 2001-2006 Red Hat, Inc.
[    0.081338] Serial: 8250/16550 driver, 3 ports, IRQ sharing disabled
[    0.082685] printk: console [ttyS0] disabled
[    0.103039] 11002000.serial: ttyS0 at MMIO 0x11002000 (irq = 72, base_baud = 2500000) is a ST16650V2
[    0.103083] printk: console [ttyS0] enabled
[    0.834181] loop: module loaded
[    0.968157] mtk_soc_eth 15100000.ethernet: generated random MAC address 65:74:68:25:64:00
[    0.976349] mtk_soc_eth 15100000.ethernet: generated random MAC address 65:74:68:25:64:00
[    0.999631] mtk_soc_eth 15100000.ethernet eth0: mediatek frame engine at 0xffffffc081400000, irq 74
[    1.009626] mtk_soc_eth 15100000.ethernet eth1: mediatek frame engine at 0xffffffc081400000, irq 74
[    1.019452] i2c_dev: i2c /dev entries driver
[    1.025595] mtk-wdt 1001c000.watchdog: Watchdog enabled (timeout=31 sec, nowayout=0)
[    1.034680] NET: Registered PF_INET6 protocol family
[    1.040782] Segment Routing with IPv6
[    1.044473] In-situ OAM (IOAM) with IPv6
[    1.048470] NET: Registered PF_PACKET protocol family
[    1.053682] 8021q: 802.1Q VLAN Support v1.8
[    1.085540] phy phy-soc:usb-phy@11e10000.1: type_sw - reg 0x218, index 0
[    1.145057] mt7530-mdio mdio-bus:1f: configuring for fixed/2500base-x link mode
[    1.153828] mt7530-mdio mdio-bus:1f: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    1.163125] mt7530-mdio mdio-bus:1f lan3 (uninitialized): PHY [mt7530-0:00] driver [MediaTek MT7531 PHY] (irq=79)
[    1.178087] mmc0: new MMC card at address 0001
[    1.183800] mmcblk0: mmc0:0001 A3A561 57.6 GiB
[    1.194229] mt7530-mdio mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:01] driver [MediaTek MT7531 PHY] (irq=80)
[    1.210077]  mmcblk0: p1 p2 p3 p4 p5 p6 p128
[    1.215997] mmcblk0boot0: mmc0:0001 A3A561 4.00 MiB
[    1.221713] mt7530-mdio mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7531 PHY] (irq=81)
[    1.222520] mmcblk0boot1: mmc0:0001 A3A561 4.00 MiB
[    1.233817] mtk_soc_eth 15100000.ethernet eth0: entered promiscuous mode
[    1.237334] mmcblk0rpmb: mmc0:0001 A3A561 16.0 MiB, chardev (251:0)
[    1.243714] DSA: tree 0 setup
[    1.254262] FIT: Detected U-Boot 2023.07.02-OpenWrt-r23630-842932a63d
[    1.260747] FIT: Selected configuration: "config-1" (OpenWrt cmcc_rax3000m)
[    1.267720] FIT:           kernel sub-image 0x00001000..0x0055e13d "kernel-1" (ARM64 OpenWrt Linux-6.6.30)
[    1.277463] FIT:          flat_dt sub-image 0x0055f000..0x0056514f "fdt-1" (ARM64 OpenWrt cmcc_rax3000m device tree blob)
[    1.288508] FIT:          flat_dt sub-image 0x00566000..0x0056665b "fdt-mt7981b-cmcc-rax3000m-emmc" (ARM64 OpenWrt cmcc_rax3000m device tree overlay mt7981b-cmcc-rax3000m-emmc)
[    1.304324] FIT:          flat_dt sub-image 0x00567000..0x00567d0d "fdt-mt7981b-cmcc-rax3000m-nand" (ARM64 OpenWrt cmcc_rax3000m device tree overlay mt7981b-cmcc-rax3000m-nand)
[    1.320136] FIT:       filesystem sub-image 0x00568000..0x00b0afff "rootfs-1" (ARM64 OpenWrt cmcc_rax3000m rootfs)
[    1.331123] block mmcblk0p5: mapped 1 uImage.FIT filesystem sub-image as /dev/fit0
[    1.339197] block mmcblk0p5: mapped remaing space as /dev/fitrw
[    1.345319] clk: Disabling unused clocks
[    1.357806] VFS: Mounted root (squashfs filesystem) readonly on device 259:1.
[    1.365110] Freeing unused kernel memory: 384K
[    1.369627] Run /sbin/init as init process
[    1.373712]   with arguments:
[    1.376666]     /sbin/init
[    1.379367]   with environment:
[    1.382495]     HOME=/
[    1.384842]     TERM=linux
[    1.559595] init: Console is alive
[    1.563130] init: - watchdog -
[    1.982058] kmodloader: loading kernel modules from /etc/modules-boot.d/*
[    2.013772] usbcore: registered new interface driver usbfs
[    2.019345] usbcore: registered new interface driver hub
[    2.024700] usbcore: registered new device driver usb
[    2.030570] gpio_button_hotplug: loading out-of-tree module taints kernel.
[    2.042850] xhci-mtk 11200000.usb: supply vbus not found, using dummy regulator
[    2.051161] xhci-mtk 11200000.usb: xHCI Host Controller
[    2.056405] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 1
[    2.066835] xhci-mtk 11200000.usb: hcc params 0x01403f99 hci version 0x110 quirks 0x0000000000200010
[    2.076017] xhci-mtk 11200000.usb: irq 82, io mem 0x11200000
[    2.081809] xhci-mtk 11200000.usb: xHCI Host Controller
[    2.087067] xhci-mtk 11200000.usb: new USB bus registered, assigned bus number 2
[    2.094460] xhci-mtk 11200000.usb: Host supports USB 3.2 Enhanced SuperSpeed
[    2.102088] hub 1-0:1.0: USB hub found
[    2.105885] hub 1-0:1.0: 1 port detected
[    2.110209] usb usb2: We don't know the algorithms for LPM for this host, disabling LPM.
[    2.118790] hub 2-0:1.0: USB hub found
[    2.122582] hub 2-0:1.0: 1 port detected
[    2.132268] kmodloader: done loading kernel modules from /etc/modules-boot.d/*
[    2.148835] init: - preinit -
[    2.500556] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[    2.509306] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[    2.522837] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
[    4.692670] mount_root: overlay filesystem in /dev/fitrw has not been formatted yet
[    7.612313] F2FS-fs (fitrw): Found nat_bits in checkpoint
[    7.641451] F2FS-fs (fitrw): Mounted with checkpoint version = 5ccce271
[    7.648902] mount_root: overlay filesystem has not been fully initialized yet
[    7.656374] mount_root: switching to f2fs overlay
[    7.661839] overlayfs: null uuid detected in lower fs '/', falling back to xino=off,index=off,nfs_export=off.
[    7.673188] urandom-seed: Seed file not found (/etc/urandom.seed)
[    7.726111] random: procd: uninitialized urandom read (4 bytes read)
[    7.729215] procd: - early -
[    7.735527] procd: - watchdog -
[    8.288721] procd: - watchdog -
[    8.292329] procd: - ubus -
[   13.366858] random: crng init done
[   13.379638] procd: - init -
[   13.719169] kmodloader: loading kernel modules from /etc/modules.d/*
[   13.746035] crypto-safexcel 10320000.crypto: EIP97:230(0,1,4,4)-HIA:270(0,5,5),PE:150/433(alg:7fcdfc00)/0/0/0
[   13.763735] Loading modules backported from Linux version v6.6.15-0-g51f354b815c4
[   13.771345] Backport generated by backports.git 193becf2
[   13.920271] urngd: v1.0.2 started.
[   14.161819] mt798x-wmac 18000000.wifi: HW/SW Version: 0x8a108a10, Build Time: 20221208201745a
[   14.161819]
[   14.349336] mt798x-wmac 18000000.wifi: WM Firmware Version: ____000000, Build Time: 20221208201806
[   14.477559] mt798x-wmac 18000000.wifi: WA Firmware Version: DEV_000000, Build Time: 20221208202048
[   14.570010] mt798x-wmac 18000000.wifi: eeprom load fail, use default bin
[   14.576793] mt798x-wmac 18000000.wifi: Direct firmware load for mediatek/mt7981_eeprom_mt7976_dbdc.bin failed with error -2
[   14.587923] mt798x-wmac 18000000.wifi: Falling back to sysfs fallback for: mediatek/mt7981_eeprom_mt7976_dbdc.bin
[   14.712363] mt798x-wmac 18000000.wifi: registering led 'mt76-phy0'
[   14.721169] mt798x-wmac 18000000.wifi: registering led 'mt76-phy1'
[   14.762660] PPP generic driver version 2.4.2
[   14.768615] NET: Registered PF_PPPOX protocol family
[   14.775978] wireguard: WireGuard 1.0.0 loaded. See www.wireguard.com for information.
[   14.783969] wireguard: Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
[   14.798026] kmodloader: done loading kernel modules from /etc/modules.d/*
[   21.208735] mtk_soc_eth 15100000.ethernet eth0: Link is Down
[   21.222482] mtk_soc_eth 15100000.ethernet eth0: configuring for fixed/2500base-x link mode
[   21.233836] mtk_soc_eth 15100000.ethernet eth0: Link is Up - 2.5Gbps/Full - flow control rx/tx
[   21.251680] mt7530-mdio mdio-bus:1f lan1: configuring for phy/gmii link mode
[   21.265725] br-lan: port 1(lan1) entered blocking state
[   21.271058] br-lan: port 1(lan1) entered disabled state
[   21.276318] mt7530-mdio mdio-bus:1f lan1: entered allmulticast mode
[   21.282672] mtk_soc_eth 15100000.ethernet eth0: entered allmulticast mode
[   21.293063] mt7530-mdio mdio-bus:1f lan1: entered promiscuous mode
[   21.313733] mt7530-mdio mdio-bus:1f lan2: configuring for phy/gmii link mode
[   21.330449] br-lan: port 2(lan2) entered blocking state
[   21.335695] br-lan: port 2(lan2) entered disabled state
[   21.341039] mt7530-mdio mdio-bus:1f lan2: entered allmulticast mode
[   21.350642] mt7530-mdio mdio-bus:1f lan2: entered promiscuous mode
[   21.366252] mt7530-mdio mdio-bus:1f lan3: configuring for phy/gmii link mode
[   21.378815] br-lan: port 3(lan3) entered blocking state
[   21.384054] br-lan: port 3(lan3) entered disabled state
[   21.389407] mt7530-mdio mdio-bus:1f lan3: entered allmulticast mode
[   21.398400] mt7530-mdio mdio-bus:1f lan3: entered promiscuous mode
[   21.442706] mtk_soc_eth 15100000.ethernet eth1: PHY [mdio-bus:00] driver [MediaTek MT7981 PHY] (irq=POLL)
[   21.452358] mtk_soc_eth 15100000.ethernet eth1: configuring for phy/gmii link mode
[   21.462768] mtk_soc_eth 15100000.ethernet eth1: Link is Up - 1Gbps/Full - flow control rx/tx
[   24.408499] mt7530-mdio mdio-bus:1f lan3: Link is Up - 1Gbps/Full - flow control rx/tx
[   24.416457] br-lan: port 3(lan3) entered blocking state
[   24.421689] br-lan: port 3(lan3) entered forwarding state
[   71.317772] br-lan: port 4(phy1-ap0) entered blocking state
[   71.323481] br-lan: port 4(phy1-ap0) entered disabled state
[   71.329147] mt798x-wmac 18000000.wifi phy1-ap0: entered allmulticast mode
[   71.336174] mt798x-wmac 18000000.wifi phy1-ap0: entered promiscuous mode
[   71.343072] br-lan: port 4(phy1-ap0) entered blocking state
[   71.348669] br-lan: port 4(phy1-ap0) entered forwarding state
[   71.354690] br-lan: port 4(phy1-ap0) entered disabled state
[   72.451607] br-lan: port 4(phy1-ap0) entered blocking state
[   72.457212] br-lan: port 4(phy1-ap0) entered forwarding state
[   77.632641] br-lan: port 5(phy0-ap0) entered blocking state
[   77.638294] br-lan: port 5(phy0-ap0) entered disabled state
[   77.643902] mt798x-wmac 18000000.wifi phy0-ap0: entered allmulticast mode
[   77.650916] mt798x-wmac 18000000.wifi phy0-ap0: entered promiscuous mode
[   77.782610] br-lan: port 5(phy0-ap0) entered blocking state
[   77.788221] br-lan: port 5(phy0-ap0) entered forwarding state
root@OpenWrt:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1504 qdisc mq state UP qlen 1000
    link/ether b2:6f:31:**:**:33 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether b8:60:61:**:**:24 brd ff:ff:ff:ff:ff:ff
4: lan3@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
5: lan2@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br-lan state LOWERLAYERDOWN qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
6: lan1@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue master br-lan state LOWERLAYERDOWN qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
7: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP qlen 1000
    link/ether b8:60:61:**:**:21 brd ff:ff:ff:ff:ff:ff
8: phy1-ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:23 brd ff:ff:ff:ff:ff:ff
9: phy0-ap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-lan state UP qlen 1000
    link/ether b8:60:61:**:**:22 brd ff:ff:ff:ff:ff:ff
root@OpenWrt:~# uname -a
Linux OpenWrt 6.6.30 #0 SMP Fri May 10 12:11:28 2024 aarch64 GNU/Linux
root@OpenWrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                 5.8M      5.8M         0 100% /rom
tmpfs                   242.8M    252.0K    242.6M   0% /tmp
/dev/fitrw                1.8G     94.2M      1.7G   5% /overlay
overlayfs:/overlay        1.8G     94.2M      1.7G   5% /
tmpfs                   512.0K         0    512.0K   0% /dev
root@OpenWrt:~#

thank you very much for the help

@zcy85611
Copy link

zcy85611 commented May 12, 2024

thank you very much for the help

I've applied the diff, wifi is working now, but here is another problem, the switch shows multiple LANs with the same MAC
image
image

This is the patch I applied

From e3bd9104128d2347627ba751662994e87dc91b32 Mon Sep 17 00:00:00 2001
From: Tianling Shen <cnsztl@immortalwrt.org>
Date: Tue, 2 Apr 2024 20:26:45 +0800
Subject: [PATCH 1/2] mediatek: convert eeprom to nvmem format for cmcc
 rax3000m

Switch to new nvmem binding.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
---
 .../linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
index 4d2b01cb63e90..3f401b53d342f 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
@@ -79,7 +79,7 @@
 						reg = <0x100000 0x80000>;
 					};
 
-					factory: partition@180000 {
+					partition@180000 {
 						label = "factory";
 						reg = <0x180000 0x200000>;
 						read-only;
@@ -89,6 +89,10 @@
 							#address-cells = <1>;
 							#size-cells = <1>;
 
+							eeprom_factory_0: eeprom@0 {
+								reg = <0x0 0x1000>;
+							};
+
 							macaddr_factory_24: macaddr@24 {
 								compatible = "mac-base";
 								reg = <0x24 0x6>;
@@ -121,7 +125,8 @@
 	fragment@4 {
 		target = <&wifi>;
 		__overlay__ {
-			mediatek,mtd-eeprom = <&factory 0x0>;
+			nvmem-cells = <&eeprom_factory_0>;
+			nvmem-cell-names = "eeprom";
 		};
 	};
 };

From a56c92714df1c09470abb236a84c4b955a8a3fcd Mon Sep 17 00:00:00 2001
From: Tianling Shen <cnsztl@immortalwrt.org>
Date: Tue, 2 Apr 2024 20:26:45 +0800
Subject: [PATCH 2/2] mediatek: switch to fitblk for cmcc rax3000m

Use the new fitblk driver.

Tested-by: Yangyu Chen <cyy@cyyself.name>
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
---
 .../uboot-envtools/files/mediatek_filogic     | 11 +--------
 .../patches/437-add-cmcc_rax3000m.patch       |  2 +-
 .../dts/mt7981b-cmcc-rax3000m-emmc.dtso       | 23 ++++++++++++++++++-
 .../dts/mt7981b-cmcc-rax3000m-nand.dtso       | 22 ++++++++++++++----
 .../mediatek/dts/mt7981b-cmcc-rax3000m.dts    |  3 ++-
 .../base-files/lib/upgrade/platform.sh        | 23 +++----------------
 6 files changed, 47 insertions(+), 37 deletions(-)

diff --git a/package/boot/uboot-envtools/files/mediatek_filogic b/package/boot/uboot-envtools/files/mediatek_filogic
index c439af1..6f8ec4d 100644
--- a/package/boot/uboot-envtools/files/mediatek_filogic
+++ b/package/boot/uboot-envtools/files/mediatek_filogic
@@ -40,6 +40,7 @@ bananapi,bpi-r3|\
 bananapi,bpi-r3-mini|\
 bananapi,bpi-r4|\
 bananapi,bpi-r4-poe|\
+cmcc,rax3000m|\
 jdcloud,re-cp-03)
 	. /lib/upgrade/common.sh
 
@@ -56,16 +57,6 @@ jdcloud,re-cp-03)
 		;;
 	esac
 	;;
-cmcc,rax3000m)
-	case "$(cmdline_get_var root)" in
-	/dev/mmc*)
-		ubootenv_add_mmc_default
-		;;
-	*)
-		ubootenv_add_ubi_default
-		;;
-	esac
-	;;
 comfast,cf-e393ax)
 	ubootenv_add_uci_config "/dev/mtd1" "0x0" "0x20000" "0x80000"
 	;;
diff --git a/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch b/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch
index 26e0e30a99662..103fbf6161a32 100644
--- a/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch
+++ b/package/boot/uboot-mediatek/patches/437-add-cmcc_rax3000m.patch
@@ -585,7 +585,7 @@
 +serverip=192.168.1.254
 +loadaddr=0x46000000
 +console=earlycon=uart8250,mmio32,0x11002000 console=ttyS0
-+bootargs=root=/dev/mmcblk0p65
++bootargs=root=/dev/fit0 rootwait
 +bootcmd=if pstore check ; then run boot_recovery ; else run boot_emmc ; fi
 +bootconf=config-1#mt7981b-cmcc-rax3000m-emmc
 +bootdelay=0
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
index c1c9c75c271ae..4dfcf95390458 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-emmc.dtso
@@ -7,6 +7,13 @@
 	compatible = "cmcc,rax3000m", "mediatek,mt7981";
 
 	fragment@0 {
+		target = <&chosen>;
+		__overlay__ {
+			rootdisk = <&emmc_rootdisk>;
+		};
+	};
+
+	fragment@1 {
 		target = <&mmc0>;
 		__overlay__ {
 			bus-width = <8>;
@@ -19,10 +26,24 @@
 			pinctrl-1 = <&mmc0_pins_uhs>;
 			vmmc-supply = <&reg_3p3v>;
 			status = "okay";
+
+			card@0 {
+				compatible = "mmc-card";
+				reg = <0>;
+
+				block {
+					compatible = "block-device";
+					partitions {
+						emmc_rootdisk: block-partition-production {
+							partname = "production";
+						};
+					};
+				};
+			};
 		};
 	};
 
-	fragment@1 {
+	fragment@2 {
 		target = <&pio>;
 		__overlay__ {
 			mmc0_pins_default: mmc0-pins {
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
index 3f401b53d342f..fded878332e24 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m-nand.dtso
@@ -7,6 +7,13 @@
 	compatible = "cmcc,rax3000m", "mediatek,mt7981";
 
 	fragment@0 {
+		target = <&chosen>;
+		__overlay__ {
+			rootdisk = <&ubi_rootdisk>;
+		};
+	};
+
+	fragment@1 {
 		target = <&gmac0>;
 		__overlay__ {
 			nvmem-cells = <&macaddr_factory_2a 0>;
@@ -14,7 +21,7 @@
 		};
 	};
 
-	fragment@1 {
+	fragment@2 {
 		target = <&gmac1>;
 		__overlay__ {
 			nvmem-cells = <&macaddr_factory_24 0>;
@@ -22,7 +29,7 @@
 		};
 	};
 
-	fragment@2 {
+	fragment@3 {
 		target = <&pio>;
 		__overlay__ {
 			spi0_flash_pins: spi0-pins {
@@ -46,7 +53,7 @@
 		};
 	};
 
-	fragment@3 {
+	fragment@4 {
 		target = <&spi0>;
 		__overlay__ {
 			pinctrl-names = "default";
@@ -114,15 +121,22 @@
 					};
 
 					partition@580000 {
+						compatible = "linux,ubi";
 						label = "ubi";
 						reg = <0x580000 0x7200000>;
+
+						volumes {
+							ubi_rootdisk: ubi-volume-fit {
+								volname = "fit";
+							};
+						};
 					};
 				};
 			};
 		};
 	};
 
-	fragment@4 {
+	fragment@5 {
 		target = <&wifi>;
 		__overlay__ {
 			nvmem-cells = <&eeprom_factory_0>;
diff --git a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
index c8db5b58f5432..977a61333363c 100644
--- a/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
+++ b/target/linux/mediatek/dts/mt7981b-cmcc-rax3000m.dts
@@ -22,7 +22,8 @@
 		serial0 = &uart0;
 	};
 
-	chosen {
+	chosen: chosen {
+		bootargs-override = "root=/dev/fit0 rootwait";
 		stdout-path = "serial0:115200n8";
 	};
 
diff --git a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
index ff791a6..38974e9 100755
--- a/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
+++ b/target/linux/mediatek/filogic/base-files/lib/upgrade/platform.sh
@@ -84,6 +84,7 @@ platform_do_upgrade() {
 	bananapi,bpi-r3-mini|\
 	bananapi,bpi-r4|\
 	bananapi,bpi-r4-poe|\
+	cmcc,rax3000m|\
 	jdcloud,re-cp-03|\
 	tplink,tl-xdr4288|\
 	tplink,tl-xdr6086|\
@@ -107,18 +108,6 @@ platform_do_upgrade() {
 			;;
 		esac
 		;;
-	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
-			CI_KERNPART="production"
-			emmc_do_upgrade "$1"
-			;;
-		*)
-			CI_KERNPART="fit"
-			nand_do_upgrade "$1"
-			;;
-		esac
-		;;
 	cudy,re3000-v1|\
 	cudy,wr3000-v1|\
 	yuncore,ax835)
@@ -216,17 +205,11 @@ platform_check_image() {
 
 platform_copy_config() {
 	case "$(board_name)" in
-	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
-			emmc_copy_config
-			;;
-		esac
-		;;
 	bananapi,bpi-r3|\
 	bananapi,bpi-r3-mini|\
 	bananapi,bpi-r4|\
-	bananapi,bpi-r4-poe)
+	bananapi,bpi-r4-poe\
+	cmcc,rax3000m)
 		case "$(fitblk_get_bootdev)" in
 		mmcblk*)
 			emmc_copy_config
diff --git a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
index 648ecb9..8f5da02 100644
--- a/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
+++ b/target/linux/mediatek/filogic/base-files/etc/board.d/02_network
@@ -2,6 +2,7 @@
 . /lib/functions.sh
 . /lib/functions/uci-defaults.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh
 
 mediatek_setup_interfaces()
 {
@@ -127,8 +128,8 @@ mediatek_setup_macs()
 		wan_mac=$(macaddr_add $(cat /sys/class/net/eth0/address) 1)
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			wan_mac=$(mmc_get_mac_binary factory 0x2a)
 			lan_mac=$(mmc_get_mac_binary factory 0x24)
 			label_mac=$wan_mac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
index bd68ef7415..5f2949c93d 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/firmware/11-mt76-caldata
@@ -3,6 +3,7 @@
 [ -e /lib/firmware/$FIRMWARE ] && exit 0

 . /lib/functions/caldata.sh
+. /lib/upgrade/common.sh

 board=$(board_name)

@@ -25,8 +26,8 @@ case "$FIRMWARE" in
 "mediatek/mt7981_eeprom_mt7976_dbdc.bin")
 	case "$board" in
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			caldata_extract_mmc "factory" 0x0 0x1000
 			;;
 		esac
diff --git a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
index 75c3d25..9c06d52 100644
--- a/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
+++ b/target/linux/mediatek/filogic/base-files/etc/hotplug.d/ieee80211/11_fix_wifi_mac
@@ -6,6 +6,7 @@ PHYNBR=${DEVPATH##*/phy}
 
 . /lib/functions.sh
 . /lib/functions/system.sh
+. /lib/upgrade/common.sh
 
 board=$(board_name)
 
@@ -55,8 +56,8 @@ case "$board" in
 		[ "$PHYNBR" = "1" ] && macaddr_setbit_la $(macaddr_add $addr 2) > /sys${DEVPATH}/macaddress
 		;;
 	cmcc,rax3000m)
-		case "$(cmdline_get_var root)" in
-		/dev/mmc*)
+		case "$(fitblk_get_bootdev)" in
+		mmcblk*)
 			addr=$(mmc_get_mac_binary factory 0xa)
 			;;
 		*)

@zcy85611
Copy link

zcy85611 commented May 12, 2024

I also tried to use sysupgrade to flash a new firmware, then I get after applying this patch

root@cmcc_rax3000m:~# sysupgrade -n "/tmp/openwrt-mediatek-filogic-cmcc_rax3000m-squashfs-sysupgrade.itb"
/sbin/sysupgrade: /lib/upgrade/platform.sh: line 212: syntax error: unexpected word (expecting ")")

here is line 212 in platform.sh

platform_copy_config() {
	case "$(board_name)" in
	bananapi,bpi-r3|\
	bananapi,bpi-r3-mini|\
	bananapi,bpi-r4|\
	bananapi,bpi-r4-poe\
	cmcc,rax3000m)
		case "$(fitblk_get_bootdev)" in
		mmcblk*)
			emmc_copy_config
			;;
		esac
		;;
	acer,predator-w6|\
	glinet,gl-mt2500|\
	glinet,gl-mt6000|\
	glinet,gl-x3000|\
	glinet,gl-xe3000|\
	jdcloud,re-cp-03|\
	ubnt,unifi-6-plus)
		emmc_copy_config
		;;
	esac
}

@zcy85611
Copy link

I just compile the new firmware with the new patch, it all works fine now on EMMC version, thanks @1715173329

Copy link
Member

@dangowrt dangowrt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As you are switching to use NVMEM for NAND-based devices, why not do the same also for eMMC? You are anyway starting to reference the partition for fitblk, so you could as well add a reference to the factory partition and get rid of userland fixing of MAC address and WiFi EEPROM data entirely.

@1715173329
Copy link
Member Author

Thanks for the hint! I will look into it later.

@1715173329 1715173329 force-pushed the master-mediatek-rax3000m branch 3 times, most recently from 51f2c82 to 6a61828 Compare June 6, 2024 18:52
esac
[ "$PHYNBR" = "1" ] && echo "$addr" > /sys${DEVPATH}/macaddress
addr=$(cat /sys/class/net/eth0/address)
[ "$PHYNBR" = "1" ] && macaddr_add $addr -1 > /sys${DEVPATH}/macaddress
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How annoying, they really use -1 offset for GMAC1... Ok...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nah, gmac1 is gmac0 -3.
MAC table on this board:

dev mac offset
GMAC0 (LAN) B8:60:61:74:XX:64 /
GMAC1 (WAN) B8:60:61:74:XX:61 -3
WLAN2G B8:60:61:74:XX:62 -2
WLAN5G B8:60:61:74:XX:63 -1

Switch to new nvmem binding.

Also fixes a issue that the MAC address assigned to lan/wan was
reversed on eMMC boards.

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
Use the new fitblk driver.

Tested-by: Yangyu Chen <cyy@cyyself.name>
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
@dangowrt
Copy link
Member

Please help with upstream review of the NVMEM-on-MMC series I have submitted:
https://patchwork.kernel.org/project/linux-block/list/?series=857192

@cyyself
Copy link
Contributor

cyyself commented Jun 10, 2024

Please help with upstream review of the NVMEM-on-MMC series I have submitted: https://patchwork.kernel.org/project/linux-block/list/?series=857192

I am willing to help, but the patch you submitted has been revised to v2 from the patches on the OpenWRT repo. So, I can't write down "Tested-By" before testing your v2 revision. Could you please provide a patch list with some nvmem-cells consumers like mtk-eth-soc and mt7915 So I can bump to a mainline kernel with your patches to test on the real device?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core packages pull request/issue for core (in-tree) packages target/mediatek pull request/issue for mediatek target
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants