GP2X Create Fw 2.0 Kernel / Modules


michu

Still Fresh
Joined
Mar 6, 2006
Messages
60
Website
www.neophob.com
well I just need another module for my gp2x, so my gps recever will work... I'll post here my steps i did to successfully build the modules:

get the kernel source:
# svn export http://svn.gp2x.com/gp2x/tag/kernel/2.0.0/

I use the gph toolchain, so i set up my path:
# export PATH="$PATH:/gp2xsdk/Tools/bin"

edit the Makefile in the root dir, edit this line:
export CROSS_COMPILE = arm-gp2x-linux-

now edit the file arch/arm/Makefile, change those lines (this option: -mshort-load-bytes had been renamed to -malignment-traps):
CFLAGS_BOOT :=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Uarm
CFLAGS +=$(apcs-y) $(arch-y) $(tune-y) -mshort-load-bytes -msoft-float -Uarm
to:
CFLAGS_BOOT :=$(apcs-y) $(arch-y) $(tune-y) -malignment-traps -msoft-float -Uarm
CFLAGS +=$(apcs-y) $(arch-y) $(tune-y) -malignment-traps -msoft-float -Uarm

change the kernel config... now

and build the stuff:
# make dep
# make modules

well it looks nice, the module was build. so I copied this module and the usbserial.o module on my gp2x, when i try to insert them i get this error:

[root@gp2x root]$insmod usbserial
Using /lib/modules/2.4.25/kernel/drivers/usb/serial/usbserial.o
insmod: couldn't find the kernel version the module was compiled for

-> i assume the compilation wasnt successfully..(or wrong target) any hints?

cheers michu /neophob.com
 
good luck, i wish you well. ill be doing a kernel recompile soon to fix automounting, so more information for everyone is a good thing.
 
Sparr posted on Aug 3 2006 at 03:21 PM said:
good luck, i wish you well. ill be doing a kernel recompile soon to fix automounting, so more information for everyone is a good thing.

another thing i found out.. when you see an error like this:
keyboard.c: In function `kbd_processkeycode':
keyboard.c:413: error: label at end of compound statement
keyboard.c: In function `do_fn':
keyboard.c:720: warning: comparison is always true due to limited range of data type
make[3]: *** [keyboard.o] Error 1


}
rep = 0;
out: << this is line 413;
}

add a semicolon after the label:
out:;

this is because of a sticter gcc check (I think..)

but i still didnt solve my module problem....
 
Last edited by a moderator:
michu posted on Aug 3 2006 at 09:50 AM said:
[root@gp2x root]$insmod usbserial
Using /lib/modules/2.4.25/kernel/drivers/usb/serial/usbserial.o
insmod: couldn't find the kernel version the module was compiled for

-> i assume the compilation wasnt successfully..(or wrong target) any hints?

cheers michu /neophob.com

Basicly whats happening is that the kernel that you compiled the module for is not the running kernel on the gp2x

version isn't the only thing you have to watch out for when compiling a module.
Check these:
1. Version of running kernel on gp2x, "uname -r" should work, remember you need the whole name not just 2.x.x

2. Make sure when you compile the kernel on your computer that the name matches what you found in step one. The module will store the name of the kernel within its code. Change this in .config I believe

3. Make sure you compiling with the same version of gcc

hope it helps
 
Last edited by a moderator:
3. Make sure you compiling with the same version of gcc

And there is the problem.

The GPH toolchain is NOT the same as the GCC 2.95 GCC that they used to build the kernel ;).

You can build the entire 2.0 GP2X kernel with some 3.* GCC's (I know that the OE GCC 3.3 works as do ones built with the Open2x crosstool derived scripts). By building the whole lot you would have the benifit of a GCC 3.* hosted 2.4 kernel and no problems cooking your own modules.
 
DJWillis posted on Aug 3 2006 at 06:43 PM said:
3. Make sure you compiling with the same version of gcc

And there is the problem.

The GPH toolchain is NOT the same as the GCC 2.95 GCC that they used to build the kernel ;).

You can build the entire 2.0 GP2X kernel with some 3.* GCC's (I know that the OE GCC 3.3 works as do ones built with the Open2x crosstool derived scripts). By building the whole lot you would have the benifit of a GCC 3.* hosted 2.4 kernel and no problems cooking your own modules.

HMMM this is getting funnier..

well, a im running this version on my gp2x:
[root@gp2x root]$uname -a
Linux gp2x 2.4.25 #3390 2006. 04. 20. (.ñ) 14:31:55 KST armv4l unknown

VERSION = 2
PATCHLEVEL = 4
SUBLEVEL = 25
EXTRAVERSION = #3390 2006. 04. 20. (.ñ)

so i changed the EXTRAVERSION to the string above... BUT I think this is worthless, as a insmod -f should ignore this "incompatible" version and thus load the module
-> [root@gp2x root]$insmod -f usbserial
Using /lib/modules/2.4.25/kernel/drivers/usb/serial/usbserial.o
insmod: couldn't find the kernel version the module was compiled for

in the header of my new compiled modules i see, that those modules are for arm arch., this should mean I used my crosscompiler.. but as allready noted, not in the right version..

version of the gph gcc: gcc version 3.4.6
version of the oop toolchain gcc: gcc version 4.0.2

whats the OE GCC 3.3 or where can i find it?

I try to compile the modules now with oop's toolchain, but it looks like the compile-options changed from gcc 3 to gcc 4:
cc1: error: invalid option 'apcs-32'
cc1: error: invalid option 'alignment-traps'

conclusion: I think the only chance to compile and use modules for my gp2x is to use this oe toolchain (or gcc), but i didnt find it. i checked the open2x site, but they use gcc 4.x

cheers
michu
 
Last edited by a moderator:
ok I used another toolchain with gcc2.95 (arm-dev).. with this one the modules compiles and works fine.. I put the modules in the archive..
 
I've been building kernels/modules for my GP2X all year so far, and I've used the arm-dev gcc2.95.2 compiler, as well as the Scratchbox gcc 3.3.4 .. FWIW, the scratchbox 3.3.4 is the 'best' so far ..
 
michu posted on Aug 7 2006 at 06:07 PM said:
ok I used another toolchain with gcc2.95 (arm-dev).. with this one the modules compiles and works fine.. I put the modules in the archive..

What is the URL for the modules you put in the archive?

I am interested in the gps driver. Is it gpsd ?
 
Last edited by a moderator:
DJWillis posted on Aug 3 2006 at 07:43 PM said:
3. Make sure you compiling with the same version of gcc

And there is the problem.

The GPH toolchain is NOT the same as the GCC 2.95 GCC that they used to build the kernel ;).

You can build the entire 2.0 GP2X kernel with some 3.* GCC's (I know that the OE GCC 3.3 works as do ones built with the Open2x crosstool derived scripts). By building the whole lot you would have the benifit of a GCC 3.* hosted 2.4 kernel and no problems cooking your own modules.

How do you know (find out) which version of gcc the kernel was built with? I've been banging my head against the wall trying to get my usb driver working. The module loads but the returned struct used in the modprobe callback is wrong even though both the sdk and the fw source has the same struct defs.

Everytime I try to do something with Linux apart from follow someone elses examples I get my arse bit. I'm not giving up, just need to find out the undocumented 'got yas'. :(
 
Last edited by a moderator:
GnoStiC posted on Aug 13 2006 at 12:31 AM said:
gcc adds it's "signature" to compiled files. if you check the files of fw 2.0, you can clearly see;
GCC: (GNU) 2.95.3 20010315 (release)

Sorry, dumb question, how do I do this?
So, in short, the offical SDK can't be used to code drivers for the 'open source' machine. If I could i'll give them a slap on the back of the head, BAD GPH!!! :angry:

I want to make a module that can be used by others, for this i'll need to get the 2.95.3 tool chain? More to learn, I suppose its all a good learning experiance. ;)

Edit: Just had a thought, maybe the up comming release of a new FW is 2.0 compiled with the correct GCC version.
 
Last edited by a moderator:
MadDog posted on Aug 13 2006 at 02:43 AM said:
Sorry, dumb question, how do I do this?
So, in short, the offical SDK can't be used to code drivers for the 'open source' machine. If I could i'll give them a slap on the back of the head, BAD GPH!!! :angry:
any hex file editor would do. assuming you're using windows, i could recommend far manager or hiew :)

MadDog posted on Aug 13 2006 at 02:43 AM said:
I want to make a module that can be used by others, for this i'll need to get the 2.95.3 tool chain? More to learn, I suppose its all a good learning experiance. ;)

Edit: Just had a thought, maybe the up comming release of a new FW is 2.0 compiled with the correct GCC version.
a must read:
Linux Device Drivers, 2nd Edition (By Alessandro Rubini & Jonathan Corbet)
Chapter 2: Building and Running Modules
 
Last edited by a moderator:
GnoStiC posted on Aug 13 2006 at 04:45 PM said:
MadDog posted on Aug 13 2006 at 02:43 AM said:
Sorry, dumb question, how do I do this?
So, in short, the offical SDK can't be used to code drivers for the 'open source' machine. If I could i'll give them a slap on the back of the head, BAD GPH!!! :angry:
any hex file editor would do. assuming you're using windows, i could recommend far manager or hiew :)

MadDog posted on Aug 13 2006 at 02:43 AM said:
I want to make a module that can be used by others, for this i'll need to get the 2.95.3 tool chain? More to learn, I suppose its all a good learning experiance. ;)

Edit: Just had a thought, maybe the up comming release of a new FW is 2.0 compiled with the correct GCC version.
a must read:
Linux Device Drivers, 2nd Edition (By Alessandro Rubini & Jonathan Corbet)
Chapter 2: Building and Running Modules

I've just got the 3rd edition in the last few days, hopfully that we be just as good. Time to get my reading glasses on. :)
 
Last edited by a moderator:
Back
Top