How to copy custom files into the zImage-initramfs via the buildroot folders

Hello there,

Can someone help me copy my custom driver files in the buildroot so that it comes inside the zImage-initramfs image when i boot that image from SD card.

I have tried all the below paths, but it is not getting copied into the zImage-initramfs, when i boot the image the /lib/firmware folder is empty
build_dir/target-arm_cortex-a9+neon_musl_eabi/root-imx6/lib
build_dir/target-arm_cortex-a9+neon_musl_eabi/root.orig-imx6/lib
staging_dir/target-arm_cortex-a9+neon_musl_eabi/root-imx6/lib
build_dir/target-arm_cortex-a9+neon_musl_eabi/linux-imx6/base-files/.pkgdir/base-files/lib
build_dir/target-arm_cortex-a9+neon_musl_eabi/linux-imx6/base-files/ipkg-arm_cortex-a9_neon/base-files/lib

Below are the files im trying to copy in /lib folder

lib/modules/4.19.52/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
lib/modules/4.19.52/kernel/drivers/net/wireless/broadcom/brcm80211/brcmutil/brcmutil.ko
lib/modules/4.19.52/kernel/net/bluetooth/bluetooth.ko
lib/modules/4.19.52/kernel/net/wireless/cfg80211.ko
lib/modules/4.19.52/kernel/compat/compat.ko

lib/firmware/brcm/4343w.hcd -> bcm4343w/4343w.hcd
lib/firmware/brcm/bcm4343w/4343w.hcd
lib/firmware/brcm/bcm4343w/brcmfmac43430-sdio.bin -> brcmfmac43430-sdio-prod.bin
lib/firmware/brcm/bcm4343w/brcmfmac43430-sdio.clm_blob
lib/firmware/brcm/bcm4343w/brcmfmac43430-sdio-etsi.txt
lib/firmware/brcm/bcm4343w/brcmfmac43430-sdio-prod.bin
lib/firmware/brcm/bcm4343w/brcmfmac43430-sdio.txt -> brcmfmac43430-sdio-etsi.txt
lib/firmware/brcm/brcmfmac43430-sdio.bin -> bcm4343w/brcmfmac43430-sdio.bin
lib/firmware/brcm/brcmfmac43430-sdio.clm_blob -> bcm4343w/brcmfmac43430-sdio.clm_blob
lib/firmware/brcm/brcmfmac43430-sdio.txt -> bcm4343w/brcmfmac43430-sdio-etsi.txt

Duplicate of this post: Removing Wireless drivers from the linux kernel for OpenWrt build

NOT A DUPLICATE !!
The reference i made in the another post is now removed, so this post is explicit for the question to help the community. So this is not a duplicate question and is specifically valid for the description.

Btw the answer i had received on other threads is still not the solution for this problem. So this will allow community to answer this question here.

If you're just trying to place the files into the final image, and aside from whether you'll be able to actually USE them, you just create a folder called files in your OpenWrt root directory.

Then you build out the directory structure and files that you want to be put on the rootfs.

For example, I have custom /etc/config files that need to be loaded.

grommish@norwits:~/openwrt/files/etc/config$ ls -la
total 20
drwxr-xr-x 2 grommish grommish 4096 Jun 29 13:36 .
drwxr-xr-x 6 grommish grommish 4096 Jun 29 13:36 ..
-rwxr-xr-x 1 grommish grommish  522 Jun 29 13:36 firstboot-sh
-rw-r--r-- 1 grommish grommish  636 Jun 28 04:15 network
-rw-r--r-- 1 grommish grommish  267 Jun 27 02:49 snort
grommish@norwits:~/openwrt/files/etc/config$

You can go down as deep as you need to.

grommish@norwits:~/openwrt/files$ ls -la usr/lib/lua/luci/model/cbi
total 28
drwxr-xr-x 2 grommish grommish 4096 Jun 27 02:45 .
drwxr-xr-x 3 grommish grommish 4096 Jun 24 15:23 ..
-rwxr-xr-x 1 grommish grommish 9898 Jun 27 01:38 snort.lua
-rwxr-xr-x 1 grommish grommish 7576 Jun 24 15:23 snort.lua.bak
grommish@norwits:~/openwrt/files$
1 Like

Thanks Grommish. Yes it mentioned in this page as you had described.
https://openwrt.org/docs/guide-developer/build-system/use-buildsystem#custom_files