Problem compiling kernel modules

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm using the Atmel buildroot 2.1.0, and I'm looking to get modules up and running (so I can develop a custom driver).

I have changed busybox and linux to support modules (and insmod, etc), but I can't seem to get the module itself to compile correctly.

Using the following command ...

make ARCH=avr32 CROSS_COMPILE=avr32-linux- -C /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23 M=`pwd`

... I get my test.ko file. But when I try to use insmod, I get the following error ...

test: version magic '2.6.23 mod_unload AVR32v1' should be '2.6.23 AVR32v1'
insmod: cannot insert 'test.ko': Invalid module format (-1): Exec format error

If I try the following (manual) compile ...

avr32-linux-gcc -O2 -DMODULE -D__KERNEL__ nanotest.c -c -o nanotest.o -I /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include

... I get the following errors ...

In file included from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/notifier.h:14,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/memory_hotplug.h:7,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/mmzone.h:493,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/gfp.h:4,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/slab.h:14,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/percpu.h:5,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/asm-generic/local.h:4,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/asm/local.h:4,
                 from /usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/module.h:18,
                 from nanotest.c:3:
/usr/local/dev/avr32/buildroot/project_build_avr32_nofpu/atngw100-base/linux-2.6.23/include/linux/rwsem.h:24:65: error: asm/rwsem.h: No such file or directory

Can anyone shed some light on what's wrong, and how I might fix it ?

Thanks
Mark

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As a quick update, I have noticed that there is no /lib/modules directory on my target !!

I guess this could be the cause ?

Where are the files I need to copy ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
make modules_install INSTALL_MOD_PATH=/media/usbdisk-1/

(INSTALL_MOD_PATH have to be set to the path where you have mounted the SD card or where you want the modules..)

Life's to short for waiting on slow CPU's

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've solved this problem simply by installing the module directly into the kernel (rather than using insmod, etc).

Since my device driver was very simple, it only took a few turns to get this going.

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello. I'm having the same problem with the message
"error: asm/rwsem.h: no such file or directory". Can anybody provide a makefile which would successfully build the kernel module.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well what commands are you executing to get the error?

Life's to short for waiting on slow CPU's

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

mpfjackson wrote:

test: version magic '2.6.23 mod_unload AVR32v1' should be '2.6.23 AVR32v1'
insmod: cannot insert 'test.ko': Invalid module format (-1): Exec format error


That's because you've enabled module versioning, and the kernel you built the module for has module unloading support enabled while the kernel installed on your target does not. That makes your module incompatible with the running kernel.

Replacing the kernel image on the target with the one built by buildroot should fix it.

Quote:
error: asm/rwsem.h: No such file or directory

That's because you've left out a lot of flags that are supposed to be present when compiling kernel modules -- in this case I think it's "-include /.../autoconf.h" that's the main omission. In general, building modules manually is very difficult -- use the kernel's build system instead.

Please see Documentation/kbuild/modules.txt for more information.