Add/build external kernel module with torizon

Hi,

I have some mediatek wifi USB devices that I would like to connect to my coli imx8X on viola plus. I noticed that the Torizon OS 7 for Colibri imx8M already support mediatek drivers (/lib/modules/6.6.23-7.0.0-g558ba3740880/kernel/drivers/net/wireless/mediatek), however my USB devices require mt7961 module which is not supported in that version.

Hence, I would like to check if you are able to add mt7961 module in the nightly release? Otherwise, can you guide me how to add/build the module using torizon.

Thank you.

Regards,
Jeff

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 Jeff,

Thank you for reaching out with your question about adding support for the mt7961 module on your Colibri iMX8X with Torizon OS 7. Since the current version of Torizon OS does not include this module, you can build it yourself by following these steps:

  1. Set Up Your Development Environment:

    • Use a Linux-based development machine.
    • Install necessary tools such as git, make, and gcc.
    • Ensure the build-essential package and other dependencies for building kernel modules are installed.
  2. Obtain the Kernel Source:

    • Download the kernel source that matches your Torizon OS version. This can be found on the Toradex GitHub repository or via the TorizonCore Builder tool.
    • Make sure the kernel headers are installed on your development machine.
  3. Prepare the Build Environment:

    • Set up a cross-compilation environment if your development machine’s architecture differs from your target device.
    • Export necessary environment variables like ARCH and CROSS_COMPILE if cross-compiling.
  4. Compile the Module:

    • Navigate to the directory containing the kernel source.
    • Use the make command to compile the module, specifying the path to the kernel headers and the module source code.
    • Example command: make -C /path/to/kernel/source M=$(pwd) modules
  5. Install the Module:

    • Transfer the compiled module to your Colibri iMX8X device.
    • Use insmod or modprobe to insert the module into the kernel.
  6. Verify the Module:

    • Check if the module is loaded using lsmod.
    • Test the functionality of your Mediatek WiFi USB device.

By following these steps, you should be able to successfully build and load the mt7961 module on your Torizon OS 7 system. If you encounter any issues, double-check that all dependencies are installed and that the kernel source matches your running kernel version.

I hope this helps you get your WiFi USB devices up and running!

Best regards,
Toradex AI Assistant

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

Enabling in-tree kernel driver torizon core using torizoncore builder.

Greetings @Jeff89,

Just to clarify are you saying this mt7961 kernel driver/module is available in a future version of the Linux kernel? Do you know what version it is supported in?

If that is the case, then we don’t typically back-port such drivers ourselves. If the driver is present in the version of the Linux kernel that we currently support then we can enable this with no issue.

What you can do is try to build and include this driver as an external kernel module. Our TorizonCore Builder tool is capable of doing this: Building External Kernel Modules With Torizon | Toradex Developer Center

That said, if I understood you correctly and this driver is in a future version of the Linux kernel, then there might be some complications. If the driver happens to rely on any features/headers/functions that were only added in the Linux kernel later on. Then I imagine it won’t just build cleanly without issue. Though it’s hard to say for certain without knowing anything about the driver itself

Best Regards,
Jeremias

Hi @jeremias.tx ,

My apologies, it should be mt7921 kernel driver instead of mt7961. I believe mt7921 kernel driver should be able to work for kernel version 5.12 and above.

As per the article on: /building-external-kernel-modules-with-torizon, are you able to advise on the steps for the kernel customization part to include mt7921 driver module?

Regards,
Jeff

My apologies, it should be mt7921 kernel driver instead of mt7961. I believe mt7921 kernel driver should be able to work for kernel version 5.12 and above.

Oh wait, if that is the case then we should be fine. We use kernel version 6.6 on our 7.X BSP. So then we should just be able to enable this as a kernel module for you. Let’s go with this approach since it should be simpler for you.

Do you know what Kernel config option should be enabled for the mt7921 driver? Once we have this information I can put in the request to our team to enable this.

Best Regards,
Jeremias

Hi @jeremias.tx,

May I know where can I find the list of kernel config options? If I am not wrong, it should be CONFIG_MT7921U.

Best Regards,
Jeff

May I know where can I find the list of kernel config options?

I typically check the online database here: LKDDb: Linux Kernel Driver DataBase

But the most accurate would be checking the actual Linux kernel source code for the config options available, in any given version of the Linux kernel.

If I am not wrong, it should be CONFIG_MT7921U.

Sounds good. Let me go ahead and make the request to our team to enable this config as a kernel module in Torizon OS. I’ll let you know once I have an update from the team.

Best Regards,
Jeremias

Hi @jeremias.tx ,

Look forward to your update. Thank you!

Regards,
Jeff

Hi @Jeff89!

The team already enabled this kernel module, it should be on today’s (or at most tomorrow’s) nightly.

Could you please test it and tell us if it worked?

Best regards.
Lucas Azeituno