insmod: failed to load hello.ko: Function not implemented
during kernel build to logout message like 'hello world', I've got such an error, following steps will reproduce the bug:
1)I downloaded goldfish kernel from git clone https://android.googlesource.com/kernel/goldfish/ -b android-goldfish-3.18
2)also downloaded the toolchain coming with the above repo using git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/x86/x86_64-linux-android-4.9
3)I changed directory to goldfish and created the paths mentioned in the documentation (github)
4)then i attempted to build the kernel using this sudo make ARCH=x86_64 CROSS_COMPILE=/home/ana/x86_64-linux-android-4.9-nougat-dev/bin/x86_64-linux-android-
in the kernel directory (goldfish) and set LOADABLE_MODULES=y
5)In the next step, I created hello.c file and the Makefile related to it in helloKernel directory.
hello.c
#include<linux/module.h>
#include<linux/init.h>
#include<linux/kernel.h>
MODULE_AUTHOR("Robert P. J. Day");
MODULE_LICENSE("Dual BSD/GPL");
MODULE_VERSION("2:1.0") ;
MODULE_DESCRIPTION("You have to start somewhere.");
static int hello_init(void){
printk(KERN_ALERT "Hello TheLittleNaruto it’s your first driver.\n");
return 0;
}
static void hello_exit(void){
printk(KERN_INFO "Goodbye TheLittleNaruto No point in keeping this driv er running.\n");
}
module_init(hello_init);
module_exit(hello_exit);
Makefile
obj-m := hello.o
KERNELDIR := /home/ana/goldfish/
PWD :=$(shell pwd)
ARCH=x86_64
CROSS_COMPILE=/home/ana/x86_64-linux-android-4.9-nougat-dev/bin/x86_64-linux-android-
CC=$(CROSS_COMPILE)gcc
LD=$(CROSS_COMPILE)ld
CFLAGS_MODULE=-fno-pic
modules:
make -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) modules
clean:
rm *.o *.ko *.mod.c *.order *.symvers
- in the same directory I created hello.ko with this
sudo make ARCH=x86_64 CROSS_COMPILE=/home/ana/x86_64-linux-android-4.9-nougat-dev/bin/x86_64-linux-android-
7)and then i copied hello.ko to android emulator using sudo adb push hello.ko /data/local
8)and then i attempt insmod hello.ko
in /data/local
and I get the above-mentioned error, please help me solve this problem. thanks in advance