I am after compiling a module for a wireless card. I got plenty of errors, thus decided to go to the basis and test the creation of a "hello" module.
I am using the image: Armbian_22.11.4_Orangepi5_jammy_legacy_5.10.110_xfce_desktop.img
vi hello.c
-------------------------------------------------
#include <linux/init.h>
#include <linux/module.h>
static int hello_init(void)
{
printk("Hello Orange Pi -- init\n");
return 0;
}
static void hello_exit(void)
{
printk("Hello Orange Pi -- exit\n");
return;
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
------------------------------------------
orangepi@orangepi:~$ vim Makefile
ifneq ($(KERNELRELEASE),)
obj-m:=hello.o
else
KDIR :=/lib/modules/$(shell uname -r)/build
PWD :=$(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
rm -f *.ko *.o *.mod.o *.mod *.symvers *.cmd *.mod.c *.order
endif
------------------------------------------------
Then try to compile the module :
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules
Running that command the first time after a fresh install of the jammy image, I realised that the directory /usr/src/linux-headers-5.10.110-rockchip-rk3588//scripts/mod
was missing the modpost program.
So I created it with the command: sudo make M=scripts/mod
Then I run again
make -C /lib/modules/$(uname -r)/build M=$(pwd) modules and got the log
--------------------------------
make: Entering directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'
arch/arm64/Makefile:44: Detected assembler with broken .inst; disassembly will be unreliable
CC [M] /home/eric/installed/TestCompileModule/hello.o
MODPOST /home/eric/installed/TestCompileModule/Module.symvers
ERROR: modpost: "_mcount" [/home/eric/installed/TestCompileModule/hello.ko] undefined!
make[1]: *** [scripts/Makefile.modpost:169: /home/eric/installed/TestCompileModule/Module.symvers] Error 1
make[1]: *** Deleting file '/home/eric/installed/TestCompileModule/Module.symvers'
make: *** [Makefile:1822: modules] Error 2
make: Leaving directory '/usr/src/linux-headers-5.10.110-rockchip-rk3588'
------------------------------------
There are few errors in it:
- "assembler with broken .inst; disassembly will be unreliable", is this important?
- "ERROR: modpost: "_mcount"", This seems blocking as there is no .ko generated
Any idea about what I am missing?
Thank you.