[solved] How to builtin firmware.bin into kernel

I am trying to compile a newer kernel (6.1.1 at the moment). Everything works except for the wireless part. I would like to minimise patching (for now) so I am trying to use everything that's inside mainline kernel, including the CFG_80211 and MAC80211 plus the MT76 drivers.

For the MT76 drivers I need to include 2 firmware.bin files. Normally those are included in the mounted root but that doesn't get mounted until after the MT76 driver times-out:

[    1.486620] pci 0000:00:00.0: enabling device (0006 -> 0007)
[    1.492330] mt76x2e 0000:01:00.0: enabling device (0000 -> 0002)
[    1.498617] mt76x2e 0000:01:00.0: ASIC revision: 76120044
[    2.135680] mt76x2e 0000:01:00.0: Invalid MAC address, using random address 06:fe:ad:3f:9d:9c
[    2.165765] mt76x2e 0000:01:00.0: Direct firmware load for mt7662_rom_patch.bin failed with error -2
[    2.174887] mt76x2e 0000:01:00.0: Falling back to sysfs fallback for: mt7662_rom_patch.bin
[   64.525779] mt76x2e: probe of 0000:01:00.0 failed with error -145
[   64.532435] pci 0000:00:01.0: enabling device (0006 -> 0007)
[   64.538196] mt7603e 0000:02:00.0: enabling device (0000 -> 0002)
[   64.544388] mt7603e 0000:02:00.0: ASIC revision: 76030010
[   64.551085] mt7603e 0000:02:00.0: Invalid MAC address, using random address 56:ad:03:22:4f:4f
[   64.565979] mt7603e 0000:02:00.0: Direct firmware load for mt7603_e2.bin failed with error -2
[   64.574500] mt7603e 0000:02:00.0: Falling back to sysfs fallback for: mt7603_e2.bin
[  125.965810] mt7603e: probe of 0000:02:00.0 failed with error -145
[  125.974748] NET: Registered PF_INET6 protocol family
[  125.981987] Segment Routing with IPv6
[  125.985897] In-situ OAM (IOAM) with IPv6
[  125.989932] NET: Registered PF_PACKET protocol family
[  125.995302] 8021q: 802.1Q VLAN Support v1.8
[  126.009410] mt7530 mdio-bus:1f: MT7530 adapts as multi-chip module
[  126.038766] mt7530 mdio-bus:1f: configuring for fixed/trgmii link mode
[  126.048449] mt7530 mdio-bus:1f: Link is Up - 1Gbps/Full - flow control rx/tx
[  126.057148] mt7530 mdio-bus:1f lan2 (uninitialized): PHY [mt7530-0:02] driver [MediaTek MT7530 PHY] (irq=23)
[  126.069827] mt7530 mdio-bus:1f lan1 (uninitialized): PHY [mt7530-0:03] driver [MediaTek MT7530 PHY] (irq=24)
[  126.082375] device eth0 entered promiscuous mode
[  126.087196] DSA: tree 0 setup
[  126.096603] VFS: Mounted root (squashfs filesystem) readonly on device 31:9.
[  126.107798] Freeing unused kernel image (initmem) memory: 1256K

I tried including those files inside the kernel by adding them to: CONFIG_EXTRA_FIRMWARE

This results in:

make[9]: *** No rule to make target '/lib/firmware/mt7603_e2.bin', needed by 'drivers/base/firmware_loader/builtin/mt7603_e2.bin.gen.o'. Stop.

I copied the mt7603_e2.bin into the /lib/firmware folder which seems the way to do it based on the example from: Kconfig add firmware.bin

What am I missing to get those binary files included in the kernel?

Nevermind. I figured it out: I really need to put the required firmware files into the absolute /lib/firmware on my build system for it to work.

2 Likes