Jump to content

Compiling module for wireless card


Tony3
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

When discussing a problem make sure to provide full logs!

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. 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...