Adding support for MediaTek MT7981 device

Hi everyone,

I am looking for support to make Openwrt firmware (vanilla) image for following router specifications:

SoC : MediaTek MT7981
RAM : DDR3 512MiB
Flash : SPI-NAND 256 MiB
WLAN : Using independent WIFI 6 chip, QCN5022+QCN5052 (2.4G: 574Mbps + 5G: 2402Mbps)
Ethernet Ports: 1WAN+3LAN 1000M adaptive network port, support auto flip (Auto MDI/MDIX)
Power : 12V 1A DC power supply

Here below the boot logs:
Full version of the boot logs is here ( MediaTek MT7981 bootlogs )

▒▒
F0: 102B 0000
FA: 1040 0000
FA: 1040 0000 [0200]
F9: 0000 0000
V0: 0000 0000 [0001]
00: 0000 0000
BP: 2400 0041 [0000]
G0: 1190 0000
EC: 0000 0000 [1000]
T0: 0000 0252 [010F]
Jump to BL

NOTICE:  BL2: v2.6(release):
NOTICE:  BL2: Built : 00:34:23, Oct 14 2022
NOTICE:  WDT: disabled
NOTICE:  EMI: Using DDR3 settings

dump toprgu registers data:
1001c000 | 00000000 0000ffe0 00000000 00000000
1001c010 | 00000fff 00000000 00f00000 00000000
1001c020 | 00000000 00000000 00000000 00000000
1001c030 | 003c0003 003c0003 00000000 00000000
1001c040 | 00000000 00000000 00000000 00000000
1001c050 | 00000000 00000000 00000000 00000000
1001c060 | 00000000 00000000 00000000 00000000
1001c070 | 00000000 00000000 00000000 00000000
1001c080 | 00000000 00000000 00000000 00000000

dump drm registers data:
1001d000 | 00000000 00000000 00000000 00000000
1001d010 | 00000000 00000000 00000000 00000000
1001d020 | 00000000 00000000 00000000 00000000
1001d030 | 00a083f1 000003ff 00100000 00000000
1001d040 | 00000000 00000000 00020303 000000ff
1001d050 | 00000000 00000000 00000000 00000000
1001d060 | 00000002 00000000 00000000 00000000
drm: 500 = 0x8
[DDR Reserve] ddr reserve mode not be enabled yet
DDR RESERVE Success 0
[EMI] ComboMCP not ready, using default setting
BYTE_swap:0
BYTE_swap:0
Window Sum 624, worse bit 0, min window 76
Window Sum 632, worse bit 11, min window 76
Window Sum 530, worse bit 0, min window 66
Window Sum 498, worse bit 9, min window 60
Window Sum 534, worse bit 1, min window 66
Window Sum 508, worse bit 8, min window 62
Window Sum 542, worse bit 1, min window 66
Window Sum 520, worse bit 8, min window 64
Window Sum 526, worse bit 8, min window 64
NOTICE:  EMI: Detected DRAM size: 512MB
NOTICE:  EMI: complex R/W mem test passed
NOTICE:  CPU: MT7981 (1300MHz)
NOTICE:  SPI_NAND parses attributes from parameter page.
NOTICE:  SPI_NAND Detected ID 0xef
NOTICE:  Page size 2048, Block size 131072, size 268435456
NOTICE:  Initializing NMBM ...
NOTICE:  Signature found at block 2047 [0x0ffe0000]
NOTICE:  First info table with writecount 0 found in block 1920
NOTICE:  Second info table with writecount 0 found in block 1923
NOTICE:  NMBM has been successfully attached in read-only mode
NOTICE:  BL2: Booting BL31
NOTICE:  BL31: v2.6(release):
NOTICE:  BL31: Built : 23:57:18, Oct 17 2022
NOTICE:  Hello BL31!!!


U-Boot 2022.04 (Oct 17 2022 - 23:45:57 -0700)

CPU:   MediaTek MT7981
Model: mt7981-rfb
DRAM:  512 MiB
Core:  32 devices, 13 uclasses, devicetree: embed

Initializing NMBM ...
spi-nand: spi_nand spi_nand@0: Winbond SPI NAND was found.
spi-nand: spi_nand spi_nand@0: 128 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
Could not find a valid device for nmbm0
Signature found at block 1023 [0x07fe0000]
First info table with writecount 0 found in block 960
Second info table with writecount 0 found in block 963
NMBM has been successfully attached

Loading Environment from MTD... OK
In:    serial@11002000
Out:   serial@11002000
Err:   serial@11002000
Net:   eth0: ethernet@15100000

  *** U-Boot Boot Menu ***

     1. Startup system (Default)
     2. Upgrade firmware
     3. Upgrade ATF BL2
     4. Upgrade ATF FIP
     5. Upgrade single image
     6. Load image
     0. U-Boot console


  Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit
ubi0: attaching mtd6
ubi0: scanning is finished
ubi0: attached mtd6 (name "ubi", size 64 MiB)
ubi0: PEB size: 131072 bytes (128 KiB), LEB size: 126976 bytes
ubi0: min./max. I/O unit sizes: 2048/2048, sub-page size 2048
ubi0: VID header offset: 2048 (aligned 2048), data offset: 4096
ubi0: good PEBs: 512, bad PEBs: 0, corrupted PEBs: 0
ubi0: user volume: 3, internal volumes: 1, max. volumes count: 128
ubi0: max/mean erase counter: 13/10, WL threshold: 4096, image sequence number: 0
ubi0: available PEBs: 19, total reserved PEBs: 493, PEBs reserved for bad PEB handling: 19
Reading from volume 'kernel' to 0x46000000, size 0x0 ... OK
## Loading kernel from FIT Image at 46000000 ...
   Using 'config-1' configuration
   Trying 'kernel-1' kernel subimage
     Description:  ARM64 OpenWrt Linux-5.4.213
     Type:         Kernel Image
     Compression:  lzma compressed
     Data Start:   0x460000e8
     Data Size:    3301730 Bytes = 3.1 MiB
     Architecture: AArch64
     OS:           Linux
     Load Address: 0x48080000
     Entry Point:  0x48080000
     Hash algo:    crc32
     Hash value:   5dbbf6b0
     Hash algo:    sha1
     Hash value:   2102a0505b4d3a6ef84428797fab46017b84da20
   Verifying Hash Integrity ... crc32+ sha1+ OK
## Loading fdt from FIT Image at 46000000 ...
   Using 'config-1' configuration
   Trying 'fdt-1' fdt subimage
     Description:  ARM64 OpenWrt mt7981-spim-nand-rfb device tree blob
     Type:         Flat Device Tree
     Compression:  uncompressed
     Data Start:   0x46326390
     Data Size:    18380 Bytes = 17.9 KiB
     Architecture: AArch64
     Hash algo:    crc32
     Hash value:   81d8132a
     Hash algo:    sha1
     Hash value:   35a8c32ba790912898120323ee32b58de053641d
   Verifying Hash Integrity ... crc32+ sha1+ OK
   Booting using the fdt blob at 0x46326390
   Uncompressing Kernel Image
   Loading Device Tree to 000000005f7f1000, end 000000005f7f87cb ... OK

Starting kernel ...

[    0.000000] Booting Linux on physical CPU 0x0000000000 [0x410fd034]
[    0.000000] Linux version 5.4.213 (haowen@haowen) (gcc version 8.4.0 (OpenWrt GCC 8.4.0 unknown)) #0 SMP Mon Oct 31 08:39:59 2022
[    0.000000] Machine model: MediaTek MT7981 RFB
[    0.000000] earlycon: uart8250 at MMIO32 0x0000000011002000 (options '')
[    0.000000] printk: bootconsole [uart8250] enabled
[    0.000000] On node 0 totalpages: 130128
[    0.000000]   DMA32 zone: 2048 pages used for memmap
[    0.000000]   DMA32 zone: 0 pages reserved
[    0.000000]   DMA32 zone: 130128 pages, LIFO batch:31
[    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.0
[    0.000000] percpu: Embedded 20 pages/cpu s43992 r8192 d29736 u81920
[    0.000000] pcpu-alloc: s43992 r8192 d29736 u81920 alloc=20*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] Built 1 zonelists, mobility grouping on.  Total pages: 128080
[    0.000000] Kernel command line: console=ttyS0,115200n1 loglevel=8                           earlycon=uart8250,mmio32,0x11002000
[    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] mem auto-init: stack:off, heap alloc:off, heap free:off
[    0.000000] Memory: 492040K/520512K available (6846K kernel code, 438K rwdata, 1904K rodata, 448K init, 286K bss, 28472K 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:     CONFIG_RCU_FANOUT set to non-default value of 32.
[    0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
[    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] GICv3: Distributor has no Range Selector support
[    0.000000] GICv3: 16 PPIs implemented
[    0.000000] GICv3: no VLPI support, no direct LPI support
[    0.000000] GICv3: CPU0: found redistributor 0 region 0:0x000000000c080000
[    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.000003] sched_clock: 56 bits at 13MHz, resolution 76ns, wraps every 4398046511101ns
[    0.008198] Calibrating delay loop (skipped), value calculated using timer frequency.. 26.00 BogoMIPS (lpj=52000)
[    0.018517] pid_max: default: 32768 minimum: 301
[    0.023238] Mount-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.030589] Mountpoint-cache hash table entries: 1024 (order: 1, 8192 bytes, linear)
[    0.039278] ASID allocator initialised with 65536 entries
[    0.044780] rcu: Hierarchical SRCU implementation.
[    0.049903] smp: Bringing up secondary CPUs ...
[    0.054781] Detected VIPT I-cache on CPU1
[    0.054801] GICv3: CPU1: found redistributor 1 region 0:0x000000000c0a0000
[    0.054823] CPU1: Booted secondary processor 0x0000000001 [0x410fd034]
[    0.054888] smp: Brought up 1 node, 2 CPUs
[    0.076501] SMP: Total of 2 processors activated.
[    0.081227] CPU features: detected: 32-bit EL0 Support
[    0.086389] CPU features: detected: CRC32 instructions
[    0.091659] CPU: All CPU(s) started at EL2
[    0.095781] alternatives: patching kernel code
[    0.102637] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
[    0.112449] futex hash table entries: 512 (order: 3, 32768 bytes, linear)
[    0.119347] pinctrl core: initialized pinctrl subsystem
[    0.125251] NET: Registered protocol family 16
[    0.129935] DMA: preallocated 256 KiB pool for atomic allocations
[    0.152208] SCSI subsystem initialized
[    0.156124] libata version 3.00 loaded.
[    0.160245] usbcore: registered new interface driver usbfs
[    0.165830] usbcore: registered new interface driver hub
[    0.171225] usbcore: registered new device driver usb
[    0.177102] Bluetooth: Core ver 2.22
[    0.180749] NET: Registered protocol family 31
[    0.185222] Bluetooth: HCI device and connection manager initialized
[    0.191612] Bluetooth: HCI socket layer initialized
[    0.196513] Bluetooth: L2CAP socket layer initialized
[    0.201595] Bluetooth: SCO socket layer initialized
[    0.206741] rbus 18000000.wbsys: PCI host bridge to bus 0000:00
[    0.212706] pci_bus 0000:00: root bus resource [mem 0x18000000-0x18ffffff]
[    0.219617] pci_bus 0000:00: root bus resource [bus 00-ff]
[    0.225130] pci_bus 0000:00: scanning bus
[    0.229169] pci 0000:00:00.0: [14c3:7981] type 00 class 0x000280
[    0.235215] pci 0000:00:00.0: reg 0x10: [mem 0x18000000-0x1800000f 64bit]
[    0.242039] pci 0000:00:00.0: reg 0x18: [mem 0x00000000-0x0000000f]
[    0.248338] pci 0000:00:00.0: reg 0x1c: [mem 0x00000000-0x0000000f]
[    0.254637] pci 0000:00:00.0: reg 0x20: [mem 0x00000000-0x0000000f]
[    0.260936] pci 0000:00:00.0: reg 0x24: [mem 0x00000000-0x0000000f]
[    0.268079] pci_bus 0000:00: fixups for bus
[    0.272292] pci_bus 0000:00: bus scan returning with max=00
[    0.278893] clocksource: Switched to clocksource arch_sys_counter
[    0.285591] thermal_sys: Registered thermal governor 'fair_share'
[    0.285597] thermal_sys: Registered thermal governor 'bang_bang'
[    0.291750] thermal_sys: Registered thermal governor 'step_wise'
[    0.297789] thermal_sys: Registered thermal governor 'user_space'
[    0.303825] thermal_sys: Registered thermal governor 'power_allocator'
[    0.310200] NET: Registered protocol family 2
[    0.321247] IP idents hash table entries: 8192 (order: 4, 65536 bytes, linear)
[    0.328847] tcp_listen_portaddr_hash hash table entries: 256 (order: 0, 4096 bytes, linear)
[    0.337260] TCP established hash table entries: 4096 (order: 3, 32768 bytes, linear)
[    0.345070] TCP bind hash table entries: 4096 (order: 4, 65536 bytes, linear)
[    0.352286] TCP: Hash tables configured (established 4096 bind 4096)
[    0.358734] UDP hash table entries: 256 (order: 1, 8192 bytes, linear)
[    0.365308] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes, linear)

Look at the examples and do the same:

Thanks!
The router which I have is OEM router with no brand, I do not want other brands names to appear in internal files

Any solutions?!

DIY

This one worked with my router except the LAN ports. I will investigate further the reasons. but I have a question:

  • If this image worked; does this mean that DTS, Flash Layout are the same (expect brand name/model)?

Not always. It would be nice to check everything (layout, leds, buttons, ports) if you're planning create a pull request or distribute you OpenWrt build. See @frollic's links above.

1 Like

I think this is at least is a good start.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.