[Linux driver learning] a simple compilation error

Here is a record of the unexpected pitfalls I stepped on in the Linux driver learning:
[1] C99 programming is not supported
The C99 form is not supported
[2] Makefile writing needs to be careful. When using multiple .c to compile module .ko, the module and . c cannot have the same name.
The infinite reentry caused by the duplicate name directly leads to led.c not being compiled into it
The main error:
led-y := led.o board_demo.o obj-m += led.o
the first declared module name here is: led; led.c is used when compiling the led module, so there is led.o behind it, and the module name led.o is also used when compiling .ko, so it appears An unexpected error occurred. Change it to this and it will be normal:
led_modules-y := led.o board_demo.o obj-m += led_modules.o
the corresponding generated module file is led_modules.ko.
This problem is difficult to find, because even if it is wrongly written, it will still compile the module file and APP file, and will not report. You need to carefully check the compilation process The printing will find [dependency dropped]. However, the installation of this module file will display some problems, but the root cause of the problem cannot be found by checking these related prints, because there are many other problems that can also cause such prints. The printing on ARM is as follows:
ARM printing
At first, the landlord’s idea was to track the problem based on this printing, but after a long time of research, he did not find it. Later, I thought that the init part of the module is printed by the landlord. In theory, as long as the init function is entered, the information of the file, function, and line number will be printed in the kernel immediately. But this is not there, indicating that even the init has not been entered, so I thought it was a compilation problem.
When compiling a simple LED driver program, the Makefile is written like this:
obj-m += led.o
Here, there is no problem because the driver file is only led.c.
[3] Digression: A problem that is prone to occur when using VsCode under Ubantu: When using the pinyin input method of ibus, the left mouse button will fail to select the code, and it will be normal when switching to the English input method.

Supongo que te gusta

Origin blog.csdn.net/qq_32006213/article/details/128959060
Recomendado
Clasificación