Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to compile the driver in modules way

Shulou Source: shulou.com Published: 2022-06-01 04:17:54 11月15日 Update

In this article, the editor introduces in detail "how to compile the driver in the way of modules", the content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to compile the driver in the way of modules" can help you solve your doubts.

This document focuses on compiling drivers in modules mode in iTOP-i.MX6Q development board and device tree kernel.

Here, take the compilation of the qt kernel of imx6q (similar to imx6d and plus) as an example, the kernel of Ubuntu16 and

Qt is generic, and the configuration of android6.0 is similar to that of qt.

The document first introduces several files related to driver compilation, Kconfig, Makefile. In addition, the .config file and

Menuconfig file, you can refer to the "iTOP-iMX6- device tree kernel-default file configuration _ V1.X" document and

"iTOP-iMX6- device Tree Kernel-use of menuconfig _ V1.X" document.

Here, take the led driver as an example. The driver source code is the "itop6x_led.c" file under "drivers/char/", as shown in the following figure.

As shown.

Open the Makefile file under "drivers/char/", as shown in the following figure, and you can see that the macro that compiled led is

"CONFIG_LEDS_CTL".

The above file does not need to be modified. Open the "Kconfig" file under "drivers/char/" and search

"LEDS_CTL", as shown in the following figure, change bool to tristate.

Modify and save.

To reconfigure the default file, refer to "iTOP-iMX6- device Tree Kernel-configuration of default File _ V1.X" configuration default

Save the file, recompile the kernel, as shown in the following figure, you can see that the "itop6x_led.ko" file is generated.

Burn the regenerated kernel to the development board (be careful not to burn the image that comes with the CD, which has been added

Led driver), after the new image is written, query "/ dev/led*" in the console, there should be no such device node.

Copy "itop6x_led.ko" to the development board, as shown in the following figure, using the command "insmod itop6x_led.ko"

Load the driver.

Using the command "ls / dev/led8", you can see the device node generation, as shown in the following figure.

After reading this, the article "how to compile drivers in modules" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.

Tags: Files drivers kernels compilers devices configurations methods documents articles mirroring development generation content commands nodes references proper no CD ideas Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Huawei NVidia Shulou Technology macOS