You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yocto环境下如何添加树外设备驱动?

Hey there! Since you're new to Yocto and already have a working build environment for uboot+kernel+rootfs, let's break down how to integrate that bcmdhd driver properly—we'll take it step by step, no jargon overload.

Integrating the BCMDHD Driver into Your Yocto Build

1. Stick to Out-of-Tree Module Best Practices

Your driver is built separately from the mainline kernel, so we'll create a dedicated Yocto recipe for it. This keeps your kernel source clean and aligns with Yocto's modular workflow.

First, create a custom layer to house your driver recipe—this avoids messing with Yocto's core layers:

  • Make a directory like meta-my-drivers
  • Add the standard layer structure inside:
    meta-my-drivers/
    ├── conf/
    │   └── layer.conf
    └── recipes-kernel/
        └── bcmdhd/
            ├── bcmdhd/
            │   └── [drop your full bcmdhd driver source here]
            └── bcmdhd_%.bb
    

Pro tip: If your driver lives in a git repo, you can use SRC_URI to pull it directly instead of copying files—we'll cover that in the recipe.

3. Write the BCMDHD Recipe (bcmdhd_%.bb)

Here's a tailored recipe that mimics your native build command. Adjust placeholders to match your setup:

DESCRIPTION = "Broadcom BCMDHD WiFi Driver (BCM4359 PCIe)"
LICENSE = "Proprietary"
LIC_FILES_CHKSUM = "file://LICENSE;md5=[replace-with-actual-md5-of-your-license-file]"

# Use this if your driver is local, or swap for git://your-repo-url.git if using a repo
SRC_URI = "file://bcmdhd/"
S = "${WORKDIR}/bcmdhd"

# Pull in kernel build dependencies
DEPENDS = "virtual/kernel"
inherit module

# Pass your exact CONFIG flags to the make command
EXTRA_OEMAKE += " \
    CONFIG_BCMDHD_PCIE=y \
    CONFIG_BCMDHD=m \
    CONFIG_BCM4359=y \
"

# Install the module to the correct kernel module directory
do_install() {
    install -d ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/
    install -m 0644 ${S}/bcmdhd.ko ${D}${base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/
}

# Ensure the module is included in your image and dependencies are met
FILES_${PN} += "${base_libdir}/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/bcmdhd.ko"
RDEPENDS_${PN} = "kernel-module-bcmdhd"

Key details:

  • The inherit module line handles all the tedious stuff like pointing to the correct kernel build directory (no more manual -C or M= parameters!).
  • EXTRA_OEMAKE injects your custom CONFIG flags directly into the build—exactly like your native make command.
  • If your driver needs firmware files, add them via SRC_URI and install them to ${D}/lib/firmware/ in the do_install section.

4. Enable Your Layer and Recipe

  • Add your new layer to conf/bblayers.conf in your build directory:
    BBLAYERS += "${TOPDIR}/../meta-my-drivers"
    
  • Add the driver to your image's package list in local.conf:
    IMAGE_INSTALL:append = " bcmdhd"
    
    Use IMAGE_INSTALL += " bcmdhd" if you're on an older Yocto version.

5. Build and Verify

Run your build as usual:

bitbake your-target-image-name

Once the build finishes, flash the image to your target. Test if the module loads with:

modprobe bcmdhd
lsmod | grep bcmdhd

Quick Troubleshooting

  • Kernel version mismatch: Double-check that your Yocto kernel version matches what you used for native compilation. Use uname -r on the target or check KERNEL_VERSION in your build logs.
  • Build errors: Check the detailed log at tmp/work/[your-target-arch]/bcmdhd/[version]/temp/log.do_compile—most issues are missing dependencies or typos in CONFIG flags.
  • Firmware not found: If the driver complains about missing firmware, add those files to your recipe and install them to /lib/firmware/.

内容的提问来源于stack exchange,提问作者ZioByte

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:58:20