Greetings, Colleagues!
I'm trying to build simple hello-world linux kernel module using yocto external sdk for i.MX8QuadPlus (MEK board) and currently stuck at compilation error:
ysfedorov@LAPTOP-TU9D1V4V:~/my_c$ make
make -C /opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/usr/src/kernel M=/home/ysfedorov/my_c modules
make[1]: Entering directory '/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build'
CC [M] /home/ysfedorov/my_c/my_module.o
In file included from ./include/linux/types.h:6,
from ./include/linux/list.h:5,
from ./include/linux/module.h:9,
from /home/ysfedorov/my_c/my_module.c:1:
./include/uapi/linux/types.h:5:10: fatal error: asm/types.h: No such file or directory
5 | #include <asm/types.h>
| ^~~~~~~~~~~~~
compilation terminated.
make[2]: *** [scripts/Makefile.build:266: /home/ysfedorov/my_c/my_module.o] Error 1
make[1]: *** [Makefile:1703: /home/ysfedorov/my_c] Error 2
make[1]: Leaving directory '/opt/fsl-imx-xwayland/5.4-zeus/sysroots/aarch64-poky-linux/lib/modules/5.4.47-2.2.0+g5ec03d06f54e/build'
make: *** [Makefile:6: all] Error 2
What i've done:
Source file hello.c:
#include <linux/module.h>
static int __init hello_init(void)
{
pr_info("hello from init\n");
return 0;
}
static void __exit hello_exit(void)
{
pr_info("hello from exit\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENCE("GPL");
MODULE_AUTHOR("ysfedorov");
MODULE_DESCRIPTION("This is simple hello world example of module");
Makefile:
Hello YuriF,
You must correct the path of include/uapi/linux/types and you compile your project.
Regards
Hello Bio_TICFSL
Thanks for your reply. Would you tell me what exactly path must be?
If try compile source like ordinary user application with $(CC) hello.c -o hello it will pass includes but break further at unknown symbols (__init) so it knows how to resolve/find any needed headers.
@YuriF ,
Did you figure this out. I see this issue too.
any additional info you can provide?
Thanks,
Dan
I think I figured it out.
It looks like there are a number of paths that need to be changed from asm to asm-generic.
I believe this is what Bio_TICFSL was referring to.
I was wrong and am not sure what @YuriF was saying.
This is what I did to resolve the issue.