error: -1 Invalid module format when using insmod with module cross-compiled for arm
Linux - Embedded & Single-board computerThis forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
error: -1 Invalid module format when using insmod with module cross-compiled for arm
I am trying to build a kernel module for an Arcom zeus board with a PXA270 processor running arcom embedded linux with kernel 2.6.16.28-arcom1-2-zeus. I followed the steps described below:
1: Installed development environment (arm-linux- cross compiler etc.) on host pc (x86 processor running Centos 4 with kernel 2.6.9-55.0.9.EL)
2: Created linux-source-2.6.16.18-arcom1 source tree under /opt/arcom/src/ using tarball supplied by Arcom
3: in root directory of linux-source-2.6.16.18-arcom1 tree, entered command cp /arch/arm/configs/zeus_defconfig ./.config
4: ran make ARCH=arm CROSS_COMPILE=arm-linux- xconfig
5: changed nothing in xconfig
6: ran make ARCH=arm CROSS_COMPILE=arm-linux-
7: wrote module in /linux-source-2.6.16.18-arcom1/drivers/helloworld
9:At this point, running
$make -C ../../ M=`pwd` ARCH=arm CROSS_COMPILE=arm_linux- modules
causes built-in.o, hello.ko, hello.mod.c hello.mod.o and hello.o to be created within the helloworld directory.
10: ftp hello.ko to the Zeus board.
11: put hello.ko in /lib/modules/2.6.16.28-arcom1-2-zeus/kernel/drivers/helloworld on the Zeus board
12: from that directory, run /sbin/insmod hello.ko
When I try to do the insmod command, my computer returns the error message
"insmod: error inserting 'hello.ko': -1 Invalid module format"
If I try to use modprobe by running /sbin/modprobe hello.ko, I get the error
"FATAL: Module hello.ko not found."
I have previously been able to cross compile applications for the zeus board using arm-linux-gcc, but this is my first driver.
I have also been able to use insmod with modules that have been provided on the zeus board, such as pxa2xx_spi.ko, but /sbin/modprobe pxa2xx_spi.ko also causes the message "FATAL: module pxa2xx_spi.ko not found."
Any help you can offer would be gratefully recieved.
EDIT:
After doing some more searches I found out about dmesg, which gives me the message
"hello: version magic '2.6.16.28-arcom1 ARMv5 gcc-3.4' should be '2.6.16.28-arcom-1-2-zeus ARMv5 gcc-3.4"
Last edited by AndrewShanks; 10-10-2007 at 10:00 AM.
Reason: New information
I've not done that - I got some advice from my vendor about how to build my development kernel so that the magics match, and that seemed to work when I tried it. What does the strip command do?
In case anyone else has the same problem, or is curious, I'm including a description of what I did following the vendor's advice:
===What I did following vendor's advice====
For my system (Arcom Zeus running Arcom embedded linux), the vendor supplies a board specific script "ael-kmake" that provides the appropriate parameters to the makefiles if called with ael-kmake -b zeus. Provided I used the vendor's script to ensure that my build was the same as their's, I could get away with changing the magic by hand. On my system, the extension for the magic "-arcom1" or "-arcom1-2-zeus" is defined in a file called localversion00-arcomn, although my reading indicates that in some versions you can get the same effect by changing the line of the top-level Makefile that reads "EXTRAVERSION = (whatever)".
In summary, the steps I took to get a working module were
1) unpack linux kernel to /opt/arcom/src/linux-source-2.6.16.27-arcom1
2) mkdir /opt/arcom/src/build-zeus
3) cp /opt/arcom/src/linux-source-2.6.16.27-arcom1/arch/arm/configs/zeus_defconfig /opt/arcom/src/build-zeus/.config
4) cd opt/arcom/src/linux-source-2.6.16.27-arcom1
5) open localversion00-arcomn in text editor and change "arcom1" to "arcom1-2-zeus"
6) eal-kmake -b zeus
At this stage the development kernel should be built. The folowing steps are to compile the modules against it.
7)change Makefile associated with module so that it fits better with the script - mainly defining parameters and testing how the makefile is being run:
CC=/opt/arcom/bin/arm-linux-gcc
#location of cross-compiler
ifneq ($(KERNELRELEASE),)
#standard test for whether or not makefile is being called from within kernel build tree
obj-m := hello.o
else
KERNELDIR ?= /*Put the path of your include file here*/
8) from the linux-source-2.6.16.28-arcom1 directory, issue the command (eg)
ael-kmake -b zeus -m drivers/helloworld
9) ftp the resulting hello.ko file from the hello world directory to the Zeuz board
10) ssh or telnet to the zeus board and run /sbin/insmod hello.ko
I don't know how well this exact sequence will work for non-zeus boards, but hopefully there are some bits that will be useful.
Last edited by AndrewShanks; 10-11-2007 at 07:18 AM.
Reason: Clean up info. on what I did
Have you experienced embedded linux OS development?
You can download arm cross-compilation-toolchain directly?
And you can make changes to other linux device driver in original source code, other than rewite a new device drviers, such as "hello" driver, so as to test your cross toolhain.
This is my first experience with embedded Linux, as you might have guessed from the fact that I'm doing a "hello world" module. I don't really know what makes up a toolchain. Is that preprocessor->compiler->linker, or is it something different? the supplier of my board provided a cd with a script for building what they call a "development environment", including cross-compilers and Linux source. I think there's some support for autoconf and other tools, but I don't really know how to use them.
I've been able to compile applications with the development environment, and I managed to get the hello world module to work after following the instructions from the supplier, and changing the version number in the makefile.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.