How to add an in-tree-module to my Torizon yocto build

Hi,

I need to build Torizon with yocto.
Now, I am trying to add an in-tree kernel module (kernel-source/drivers/input/touchscreen/hycon-hy46xx.c) to my yocto build (torizon-minimal).

In my yocto-layer I have this bbappend-file (recipes-kernel/linux/linux-toradex-ti_%.bbappend)

# Package summary
SUMMARY = "Adjusting kernel config to enable HYCON touch controller module"

DESCRIPTION = ""
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"

do_configure:prepend () {
    # Enable touch controller HYCON HY46XX
    echo "CONFIG_TOUCHSCREEN_HYCON_HY46XX=m"  >> ${WORKDIR}/defconfig
}

do_configure:append() {
    oe_runmake oldconfig
}

After I run ‘bitbake torizon-minimal’ I can see that the defconfig contains the line as expected. But the module hasn’t been build nor included in the final image.

Any hints what I am missing?

Hi, I’m the Toradex AI Assistant. The Toradex Support team will follow up with you shortly!

Did you like my answer?

:+1: :-1:


Hello,

To successfully add an in-tree kernel module to your Torizon Yocto build, you need to ensure that the module is properly configured, compiled, and included in the final image. Here are some steps to help you troubleshoot and resolve the issue:

  1. Verify Kernel Configuration: Make sure your bbappend file is correctly modifying the kernel configuration. The line echo "CONFIG_TOUCHSCREEN_HYCON_HY46XX=m" >> ${WORKDIR}/defconfig should enable the module as a loadable module (m). After running bitbake, check the .config file in the build directory to confirm that this configuration is present.

  2. Check Compilation: Ensure the module is being compiled by inspecting the build logs for any errors related to the module. The module should be compiled into a .ko file, which is the format for loadable kernel modules.

  3. Include Module in Image: If the module is compiled but not included in the image, you may need to explicitly add it to the image. You can do this by adding the module to the IMAGE_INSTALL variable in your image recipe or local.conf like this:

    IMAGE_INSTALL_append = " hycon-hy46xx"
    

    This ensures the module is included in the final image.

  4. Rebuild the Image: After making these changes, rebuild your image using bitbake to ensure the module is included.

  5. Verify on Target: Once the image is deployed to your device, verify that the module is available by using the modprobe command to load it and lsmod to check if it is loaded.

By following these steps, you should be able to successfully add and verify the in-tree kernel module in your Torizon Yocto build.

Best regards,
Toradex AI Assistant.

Please, also check if these links can help you solve your problem:

https://community.nxp.com/t5/i-MX-Processors/Add-Kernel-Modules-in-the-core-image-minimal/m-p/768004

Help to integrate a custom kernel into a Torizon Core Image.

Greetings @FlorianG,

I’m not certain if the method you used would successfully work to enable the kernel module/driver. I would use a configuration fragment as this is a more officially supported way to modify the kernel configuration in Yocto.

A configuration fragment file looks like so: preempt-rt.cfg « linux-toradex-5.15-2.2.x « linux « recipes-kernel - meta-toradex-nxp.git - Toradex BSP layer, recipes for NXP based modules

Make sure the file name ends in the extension .cfg so that the Yocto build recognizes it as a special configuration fragment file. Once the file is created, you just need to add it to the SRC_URI of the kernel recipe. During the build Yocto will modify the final kernel configuration using the provided fragments.

One more important thing to consider is that your configuration fragment should also specify any other configuration options that CONFIG_TOUCHSCREEN_HYCON_HY46XX requires. These won’t be added automatically unless you’re explicit about it.

Best Regards,
Jeremias

I sometimes forgot to commit. Just by the way…

Hi,
Thanks for your replays.

I figured out that if I write to ${B}/.config instead of ${WORKDIR}/defconfig, the module gets build and integrated into the final image.

This is how my do_configure:prepend function looks like:

do_configure:prepend () {
    # Enable touch controller HYCON HY46XX
    # echo "CONFIG_TOUCHSCREEN_HYCON_HY46XX=m"  >> ${WORKDIR}/defconfig
    echo "CONFIG_TOUCHSCREEN_HYCON_HY46XX=m"  >> ${B}/.config
}

Glad you were able to come to a solution.

Best Regards,
Jeremias