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

如何在Yocto构建的Raspberry Pi CM3系统启动时自动加载内核模块?

Hey there! Let's sort out that kernel module auto-loading problem for your Raspberry Pi CM3 Yocto build. Since you already have the modules sitting in /lib/modules on your target device, we’ve got a couple of reliable approaches to get them loading automatically on boot—plus we’ll fix those dependency headaches at the same time.

If your drivers were added via a custom recipe or .bbappend, you can set this up directly in your Yocto build so the configuration ships with the image (no post-flash edits needed):

  • For a single module:
    Add this line to your .bb or .bbappend file:
    MODULES_AUTOLOAD += "your-module-name"
    
    This variable tells Yocto to generate the necessary modprobe configs, which will auto-load the module on boot and handle dependencies automatically (modprobe is way smarter than insmod about resolving dependent modules).
  • For multiple modules, just space-separate them:
    MODULES_AUTOLOAD += "module1 module2 module3"
    
  • If your module needs load-time parameters, use MODULES_CONF to add a custom config:
    MODULES_CONF += "your-module.conf"
    
    Then create your-module.conf in your recipe's files directory with content like:
    options your-module-name param1=value1 param2=value2
    
    This ensures the parameters are applied automatically when the module loads.

Method 2: Manually Configure on the Target System (Great for Testing or Post-Flash Edits)

If you don't want to rebuild your Yocto image, you can set this up directly on your Raspberry Pi CM3:

  • First, stop using insmod—switch to modprobe your-module-name instead. It will automatically detect and load any dependent modules, which eliminates those dependency issues you were hitting.
  • To set up auto-load on boot:
    1. Create or edit a file in /etc/modules-load.d/ (e.g., /etc/modules-load.d/my-drivers.conf), adding each module name on its own line:
      your-module-name
      another-dependent-module
      
      Systemd reads all configs in this directory on boot and uses modprobe to load the listed modules.
    2. For module parameters, create a file in /etc/modprobe.d/ (e.g., /etc/modprobe.d/my-driver.conf):
      options your-module-name param1=value1
      
  • To verify your setup works:
    Use systemctl status systemd-modules-load.service to check the status of the module-loading service, or reboot and run lsmod | grep your-module-name to confirm the module is loaded.

Quick Notes to Avoid Headaches

  • Double-check that your module matches your kernel version: Run uname -r on the target, and make sure there's a matching directory in /lib/modules/ (modules are stored per kernel version).
  • Ensure your Yocto kernel config has dynamic module support enabled (CONFIG_MODULES=y)—this is usually default in meta-raspberrypi, but it's worth confirming if you've tweaked kernel settings.
  • If you built the module directly into the kernel (not as a dynamic module), you don't need to load it manually—it will be present on boot automatically. But since you're seeing it in /lib/modules, you're using dynamic modules, so the above methods apply.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 09:42:44