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:
- add to conf/local.conf TOOLCHAIN_TARGET_TASK_append = " kernel-devsrc" in order to build sdk with the kernel sources
- used "bitbake core-image-minimal -c populate_sdk" to build sdk
- installed it to default location (/opt/..)
- after install cd to ~/my_c folder and source /opt/fsl-imx-xwayland/5.4-zeus/environment-setup-aarch64-poky-linux
- and run "make" command (ARCH and CROSS_COMPILE has been defined by setup script)
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:
obj-m += hello.o
KERNEL_DIR ?= $(SDKTARGETSYSROOT)/usr/src/kernel
all:
make -C $(KERNEL_DIR) M=$(PWD) modules
clean:
make -C $(KERNEL_DIR) M=$(PWD) clean
I've tried replace CC variables in kernel Makefile to variables from environment setup - still got that error.
What did i miss? Is there any additional setup steps i need to do?
Any help will be appreciated!