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?
Hello, I hope you are doing well.
Could you please share me the steps you are following to replicate the error?
Best regards.
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.
when i used make all, this error is "this kernel was built by clang-450784e, your hello.c was built by gcc"
so file .ko was not compatible version kernel in android board"
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.