FORUMS
Remove All Ads from XDA

Compiling kernel modules?

19 posts
Thanks Meter: 0
 
By rale00, Junior Member on 11th November 2008, 02:11 AM
Post Reply Email Thread
I'm trying to compile bnep as a module (needed for Bluetooth PAN), but I keep running into the following error when I try to load it:

Quote:

insmod: init_module 'bnep.ko' failed (Exec format error)

I'm using kernel-android-msm-htc-2.6.25 and arm-eabi-4.2.1-gcc from the android source, so I'm not sure what's wrong. Anyone have any pointers?
 
 
11th November 2008, 02:18 AM |#2  
JesusFreke's Avatar
Inactive Recognized Developer
Flag Dallas
Thanks Meter: 52
 
More
Quote:
Originally Posted by rale00

I'm trying to compile bnep as a module (needed for Bluetooth PAN), but I keep running into the following error when I try to load it:



I'm using kernel-android-msm-htc-2.6.25 and arm-eabi-4.2.1-gcc from the android source, so I'm not sure what's wrong. Anyone have any pointers?

hmm. good question. Unfortunately I don't have any advice right now :\. But it sounds interesting and now I want to see if I can build a minimal do-nothing kernel module and get it to load.

More to come
11th November 2008, 04:42 AM |#3  
JesusFreke's Avatar
Inactive Recognized Developer
Flag Dallas
Thanks Meter: 52
 
More
No joy here. I couldn't even figure out how to get it to compile a minimal "hello world" kernel module.
11th November 2008, 08:03 AM |#4  
Member
Thanks Meter: 1
 
More
I am trying to make a driver too. But I am still not sure how to compile a module.

I was trying to make the whole source tree from my redhat machine, but no luck.

So instead, I plan to just compile my driver by using the toolchain from android source.

But I am sure how to make a makefile for this.
Could you share it?

Thanks,
Blues
11th November 2008, 01:33 PM |#5  
Junior Member
Thanks Meter: 0
 
More
The "exec format error" means that you compiled it for the wrong architecture.

For a quick reference to seeing what arch for which a binary is compiled, use the "file" command found on any Linux computer (but not present on the phone itself).
The file command is an extremely useful function for identifying files -- including files that are packaged together, such as the .img files in the updates (see the -k option).

Dynamically linked executable:
"ELF 32-bit LSB executable, ARM, version 1 (SYSV), dynamically linked (uses shared libs), not stripped"

Statically linked executable:
"ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, stripped"

Object file:
"ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped"

More specifically, if it doesn't say 32bit ARM, it will not work.
This may prove useful to some:
http://www.gentoo.org/proj/en/base/e...?part=1&chap=6
(And the compilers references in "CROSS_COMPILING" must be in your path -- see also the CC variable)
11th November 2008, 07:17 PM |#6  
OP Junior Member
Thanks Meter: 0
 
More
This is file on wlan.ko pulled directly from the phone - a known working module:

wlan.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

This is the module I compiled:

bnep.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped


There must be something else at work here...
12th November 2008, 12:05 AM |#7  
Member
Thanks Meter: 1
 
More
I am having same problem now. I am also using the toolchain from Android source...
12th November 2008, 01:09 AM |#8  
beartard's Avatar
Senior Member
Flag Winter Haven, Florida, USA
Thanks Meter: 14
 
More
I haven't gotten this deep into Android yet, but make sure the kernel source tree you're compiling against is the same version as the kernel on the phone. Modules compiled for a different kernel version will not load on another one (usually).
12th November 2008, 01:26 AM |#9  
JesusFreke's Avatar
Inactive Recognized Developer
Flag Dallas
Thanks Meter: 52
 
More
Quote:
Originally Posted by rale00

This is file on wlan.ko pulled directly from the phone - a known working module:

wlan.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped

This is the module I compiled:

bnep.ko: ELF 32-bit LSB relocatable, ARM, version 1 (SYSV), not stripped


There must be something else at work here...



Right after you try to insmod the module, type dmesg. Look through the last part of the output and see if there is anything helpful..
12th November 2008, 02:32 AM |#10  
Member
Thanks Meter: 1
 
More
yeah, that's the problem.
The version magic number doesn't match.

May I know where to get the RC19 source tree? Thanks.
12th November 2008, 04:23 AM |#11  
OP Junior Member
Thanks Meter: 0
 
More
Quote:
Originally Posted by JesusFreke

Right after you try to insmod the module, type dmesg. Look through the last part of the output and see if there is anything helpful..

Thanks, that was the key. Apparently kernel/scripts/setlocalversion queries git for part of the version string. I ended up just changing it to print "-01843-gfea26b0", which is the string for RC30, and the module worked fine.
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes