Jason Liu
Jason Liu

Reputation: 818

How to change kernel module loading order in yocto

Current I am working on building a custom yocto morty kernel. I found that in the kernel, the improper loading order of kernel modules (actually the camera drivers) will result in module failure.

I don't want to modify the driver since there are too many dependencies and they are implemented by different people in different companies.

So as the title mentioned, how can I change the order of driver loading in the stage of kernel booting?

Any help is greatly appreciated!

Upvotes: 0

Views: 3389

Answers (2)

David Bensoussan
David Bensoussan

Reputation: 3205

You can also use the KERNEL_MODULE_AUTOLOAD variable. It is working for me.

Add KERNEL_MODULE_AUTOLOAD += "<module-name>" in your local.conf

Upvotes: 1

metamorphling
metamorphling

Reputation: 379

If you are talking about loading a driver, that means it's not a built-in one, since those are activated on a startup and you can't prioritize one over another. For kernel modules you should use your startup system functionality, systemd or sysv.
Example for working driver(speaking about precedence) for systemd:

[Unit]
Description=Initializer for good driver
Before=bad_driver.service

[Service]
Type=oneshot
ExecStart=/bin/sh /usr/bin/script_modprobing_good_driver.sh

[Install]
WantedBy=multi-user.target

Example for not working driver(speaking about precedence) for systemd:

[Unit]
Description=Initializer for bad driver
After=good_driver.service

[Service]
Type=oneshot
ExecStart=/bin/sh /usr/bin/script_modprobing_bad_driver.sh

[Install]
WantedBy=multi-user.target

And a little .bb file to install those guys.

SUMMARY = "Systemd test for changing precedence of 2 kernel modules"
LICENSE = "CLOSED"

SRC_URI = "file://script_modprobing_good_driver.sh \
           file://script_modprobing_bad_driver.sh \
           file://bad_driver.service \
           file://good_driver.service \
          "

DEPENDS = "systemd"

S = "${WORKDIR}"

inherit systemd

SYSTEMD_SERVICE_${PN} = " bad_driver.service good_driver.service "

do_install () {
    install -d ${D}/usr/bin
    install -d ${D}/etc/systemd/system

    install -m 700 ${S}/script_modprobing_bad_driver.sh  ${D}/usr/bin/
    install -m 700 ${S}/script_modprobing_good_driver.sh ${D}/usr/bin/
    install -m 644 ${S}/bad_driver.service               ${D}/etc/systemd/system/
    install -m 644 ${S}/good_driver.service              ${D}/etc/systemd/system/
}

Upvotes: 0

Related Questions