Hello everyone, i'm a beginner of android embedded. i'm using i.MX8 MQ EVK board to build Android and i want write a helloworld kernel module to test. But i have some problems when compiler.
I don't know how to config and build kernel module. Can you help me indicate steps to do that?
I created 2 files: hello.c, Android.bp
This is code of Hello.c
// hello.c
#include <linux/module.h>
#include <linux/kernel.h>
int init_module(void) {
printk(KERN_INFO "Hello, kernel!\n");
return 0;
}
void cleanup_module(void) {
printk(KERN_INFO "Goodbye, kernel!\n");
}
This is code of Android.bp
cc_library {
name: "hello_kernel_module",
srcs: [
"hello.c",
],
arch: ["x86_64"],
}
Then I used mm to make file but it didn'n success.
I try alternative way by Makefile, but I think my Makefile is not true.
this is Makefile and Hello.c
Hello.c
Hello,
*** When i used Makefile, i didn't know what is tool to compile, that's reason Makefile error.
On the path where is Hello.c and your make file, run the next command:
make all
If you get errors, please share them.
Best regards.
Got it.
Could you please share more about which Linux version are you using to compile?
I am having some issues to compile it since there are missing some packages for my current Linux version.
Best regards.