Tony3 Posted January 25, 2023 Posted January 25, 2023 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. 0 Quote
OttawaHacker Posted January 25, 2023 Posted January 25, 2023 9 hours ago, Tony3 said: 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 think you are going the complex route. The armbian build system is incredible, all you need is setup a VM with ubuntu and the build system will generate a custom image with your kernel customizations. Please submit a PR if you can validate the build and hardware - this distribution needs more modules. I recently submitted a PR that got accepted for MediaTek USB devices. 0 Quote
royk Posted January 25, 2023 Posted January 25, 2023 You actually don't need to create a virtual machine, you could also do it within Armbian, the rk3588 is fast enough with enough cooling 0 Quote
Tony3 Posted January 26, 2023 Author Posted January 26, 2023 Actually I managed to build my wireless module by only using the linx header files. It did not work initially, because I had forgotten to run "make scripts" in the "linux header" directory, after running that, my "_mcount" error disappeared. Thanks for your advices. 0 Quote
gounthar Posted May 29, 2023 Posted May 29, 2023 I have the same kind of problem, trying to build a rtl8821CU module for the Rock5B. I have installed the whole firmware package through armbian-config . Then: sudo apt update sudo apt upgrade sudo apt install build-essential dkms sudo apt install git git clone https://github.com/whitebatman2/rtl8821CU.git cd rtl8821CU sudo make make ARCH=aarch64 CROSS_COMPILE= -C /lib/modules/6.2.0-rc1-station-m6/build M=/home/poddingue/rtl8821CU modules make[1]: Entering directory '/usr/lib/modules/6.2.0-rc1-station-m6/build' make[1]: *** No rule to make target 'modules'. Stop. make[1]: Leaving directory '/usr/lib/modules/6.2.0-rc1-station-m6/build' make: *** [Makefile:1923: modules] Error 2 but it fails... `uname -r` gives me `6.2.0-rc1-station-m6`. ll /lib/modules/6.2.0-rc1-station-m6/ total 1392 drwxr-xr-x 11 root root 4096 Mar 20 15:19 kernel -rw-r--r-- 1 root root 320711 Mar 17 14:22 modules.alias -rw-r--r-- 1 root root 327286 Mar 17 14:22 modules.alias.bin -rw-r--r-- 1 root root 16981 Mar 17 14:22 modules.builtin -rw-r--r-- 1 root root 37042 Mar 17 14:22 modules.builtin.alias.bin -rw-r--r-- 1 root root 18873 Mar 17 14:22 modules.builtin.bin -rw-r--r-- 1 root root 117401 Mar 17 14:22 modules.builtin.modinfo -rw-r--r-- 1 root root 79754 Mar 17 14:22 modules.dep -rw-r--r-- 1 root root 123183 Mar 17 14:22 modules.dep.bin -rw-r--r-- 1 root root 243 Mar 17 14:22 modules.devname -rw-r--r-- 1 root root 38207 Mar 17 14:22 modules.order -rw-r--r-- 1 root root 703 Mar 17 14:22 modules.softdep -rw-r--r-- 1 root root 136364 Mar 17 14:22 modules.symbols -rw-r--r-- 1 root root 170537 Mar 17 14:22 modules.symbols.bin 0 Quote
balbes150 Posted May 30, 2023 Posted May 30, 2023 11 часов назад, gounthar сказал: I have the same kind of problem, trying to build a rtl8821CU module for the Rock5B. You are using an old version of the kernel. Use the latest version of the images, there is already the necessary module there. https://github.com/150balbes/build/blob/ed6c18895b1ed1429ea1a22210a826039d177d58/config/kernel/linux-station-m3-current.config#L2939 1 Quote
gounthar Posted May 30, 2023 Posted May 30, 2023 Thank you @balbes150. I guess there is no other alternative to the existing image? I have to rewrite everything with the new image, I can't update the board with the latest kernel because it's not official yet.? 0 Quote
balbes150 Posted May 30, 2023 Posted May 30, 2023 2 часа назад, gounthar сказал: I guess there is no other alternative to the existing image? Clone my GIT and build the kernel (you can additionally change the configuration as you wish) - get a DEB package for manual installation\updating of the kernel on any system. The assembly can be done on the rock 5b itself, the assembly time is small. 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.