systemd: how to enable auto-loading kernel modules


Merlin
 

SUMMARY

What should I do to enable auto-loading kernel modules in a systemd-employed system IN ADDITION TO setting KERNEL_MODULE_AUTOLOAD?
 
DETAILS
 
I'm trying to automatically load out-of-tree kernel modules in my distro (built using Dunfell) that uses systemd.
Kernel modules and the correponding config files are certainly installed to the rootfs (each under `/lib/modules/5.xxx/extra/` and `/etc/modules-load.d/`); however, auto-loading does not occur at all.
 
My module recipe is as follows. I've added KERNEL_MODULE_AUTOLOAD to enable auto-loading.
 
```
LICENSE = "CLOSED"
SUMMARY = "Some description"

PV = "1.0+git${SRCPV}"
SRC_URI = "git://url/to/my.git;user=git;protocol=ssh;branch=main"
SRCREV = "${AUTOREV}"
 
inherit module
 
S = "${WORKDIR}/git/src"
RPROVIDES_${PN} += " kernel-module-my_module"
KERNEL_MODULE_AUTOLOAD += " my_module"
```
 
I've learned that in systemd, systemd-modules-load service is responsible for module autoload, but I couldn't find either systemd-modules-load itself and systemd-modules-load.service in the rootfs.
It looks like that modules-load existed in past versions of systemd.bb, so I've tried to enable modules-load by adding `PACKAGECONFIG_pn-systemd += " modules-load"` in conf/local.conf. However, bitbake rejected it saying:
 
```
WARNING: systemd-1_244.5-r0 do_configure: QA Issue: systemd: invalid PACKAGECONFIG: modules-load [invalid-packageconfig]
```
 
Is there anything I can do further?

(Supposedly I'm having the same problem with this? https://lists.yoctoproject.org/g/yocto/message/45275)
 
Thanks in advance.
 
Merlin


Mike Looijmans
 

Likely there's a problem with the underscore. Recipes (and packages) with an underscore don't work properly because it's used as a version separator.

Rename "my_module" to "my-module".

Having said that, kernel modules rarely need to be forced to load. The rare exceptions are modules that aren't linked to hardware (e.g. some software pipe, or typical test modules that do their thing during init) or modules that need special parameters to work (uio needs this for example).

Normally you'd have a match in the devicetree (or ACPI or PCI or USB or ...) and the match with your module will automatically trigger loading the module (and its dependencies). If your module is hardware related, this is how it should load. If that doesn't work, your hardware wasn't detected anyway and the module, after loading, likely won't do anything anyway.



On 26-10-2022 08:07, Merlin via lists.yoctoproject.org wrote:
SUMMARY

What should I do to enable auto-loading kernel modules in a systemd-employed system IN ADDITION TO setting KERNEL_MODULE_AUTOLOAD?
 
DETAILS
 
I'm trying to automatically load out-of-tree kernel modules in my distro (built using Dunfell) that uses systemd.
Kernel modules and the correponding config files are certainly installed to the rootfs (each under `/lib/modules/5.xxx/extra/` and `/etc/modules-load.d/`); however, auto-loading does not occur at all.
 
My module recipe is as follows. I've added KERNEL_MODULE_AUTOLOAD to enable auto-loading.
 
```
LICENSE = "CLOSED"
SUMMARY = "Some description"

PV = "1.0+git${SRCPV}"
SRC_URI = "git://url/to/my.git;user=git;protocol=ssh;branch=main"
SRCREV = "${AUTOREV}"
 
inherit module
 
S = "${WORKDIR}/git/src"
RPROVIDES_${PN} += " kernel-module-my_module"
KERNEL_MODULE_AUTOLOAD += " my_module"
```
 
I've learned that in systemd, systemd-modules-load service is responsible for module autoload, but I couldn't find either systemd-modules-load itself and systemd-modules-load.service in the rootfs.
It looks like that modules-load existed in past versions of systemd.bb, so I've tried to enable modules-load by adding `PACKAGECONFIG_pn-systemd += " modules-load"` in conf/local.conf. However, bitbake rejected it saying:
 
```
WARNING: systemd-1_244.5-r0 do_configure: QA Issue: systemd: invalid PACKAGECONFIG: modules-load [invalid-packageconfig]
```
 
Is there anything I can do further?

(Supposedly I'm having the same problem with this? https://lists.yoctoproject.org/g/yocto/message/45275)
 
Thanks in advance.
 
Merlin




-- 
Mike Looijmans

Met vriendelijke groet / kind regards,

Mike Looijmans

System Expert

TOPIC Embedded Products B.V.
Materiaalweg 4    
5681 RJ Best T:    +31 (0) 499 33 69 69
The Netherlands E:    mike.looijmans@...
W:    www.topic.nl
L: LinkedIn

Please consider the environment before printing this e-mail


Merlin
 

Thanks Mike for your advice!

I've replaced underscore to hyphen and rerun a build from fetch, but unfortunately that didn't invoke auto-load.

In fact, my modules are device drivers developed in out-of-tree repositories. Some user-space applications depend on them, so I wanted them to be auto-loaded on boot. Autoload didn't occur even though I've added corresponding devicetree properties.

Best

Merlin


Mike Looijmans
 

Guess you'll have to provide more than just "It doesn't work" if you want any serious assistance.

The source code would help. Also telling us whether the drivers actually probe if you load them manually using modprobe.



Met vriendelijke groet / kind regards,

Mike Looijmans
System Expert


TOPIC Embedded Products B.V.
Materiaalweg 4, 5681 RJ Best
The Netherlands

T: +31 (0) 499 33 69 69
E: mike.looijmans@...
W: www.topic.nl

Please consider the environment before printing this e-mail

On 08-11-2022 07:58, Merlin via lists.yoctoproject.org wrote:
Thanks Mike for your advice!
I've replaced underscore to hyphen and rerun a build from fetch, but unfortunately that didn't invoke auto-load.
In fact, my modules are device drivers developed in out-of-tree repositories. Some user-space applications depend on them, so I wanted them to be auto-loaded on boot. Autoload didn't occur even though I've added corresponding devicetree properties.
Best
Merlin