Changes between Version 26 and Version 27 of buildroot


Ignore:
Timestamp:
09/11/2020 10:42:51 PM (5 years ago)
Author:
Tim Harvey
Comment:

added example section showing how to load kernel modules

Legend:

Unmodified
Added
Removed
Modified
  • TabularUnified buildroot

    v26 v27  
    144144For more information see the Buildroot user manual 'init system' section.
    145145
     146
     147
     148[=#modules]
     149== Loading kernel modules
     150Typical Linux systems have a hotplug manager such as {{{udev}}} running in the background that loads modules for detected devices. Without such as system you must do this manually. Once easy solution is to do this at boot time via an init script.
     151
     152Examples:
     153 * Auto load modules for devices detected at boot as well as a non-device specific module such as 'batman-adv':
     154  1. make menuconfig and set BR2_ROOTFS_OVERLAY=files
     155  2. create an init script that loads modules for detected devices and modules listed in {{{/etc/modules}}}:
     156{{{#!bash
     157mkdir -p files/etc/init.d
     158cat << \EOF > files/etc/init.d/S30modules
     159#!/bin/sh
     160
     161case "$1" in
     162  start)
     163    printf "Loading modules:"
     164    # load modules for detected devices
     165    find /sys/ -name modalias -print0 | xargs -0 sort -u -z | xargs -0 modprobe -abq
     166
     167    # load modules from /etc/modules
     168    [ -r /etc/modules ] || exit 0
     169    while read module args; do
     170        case "$module" in
     171                ""|"#"*) continue ;;
     172        esac
     173
     174        # attempt to load modules
     175        modprobe ${module} ${args} >/dev/null
     176    done < /etc/modules
     177    ;;
     178esac
     179EOF
     180chmod +x files/etc/init.d/S30modules
     181}}}
     182  3. create an {{{/etc/modules}}} file with extra modules and arguments you wish to load:
     183{{{#!bash
     184cat << \EOF > files/etc/modules
     185batman-adv
     186EOF
     187}}}
     188  3. build with 'make'
    146189
    147190