08-17-2012, 08:16 AM | #1 |
Senior Altruist
Posts: 82
Karma: 600554
Join Date: Jun 2012
Device: Onyx Boox C67ML, Onyx Boox Note Pro
|
How-to: Compiling the kernel and kernel modules
In another thread, the question came up of how I went about compiling a kernel module for the kernel shipping on the PRS-T1. In this How-to, I'm assuming you know how to compile a Linux kernel, and will focus the PRS-T1 specifics. I'm using the 1.0.04.12210 firmware.
To compile a kernel module, you first need to build Sony's kernel to generate a Module.symvers file with the correct ABI-version signature. In a second step, you can build your module. I've been using the GCC 4.4.3 toolchain coming with the Android NDK on Linux, which is trivial to set up (just unpack the NDK tarball). The shipped kernel has been compiled with GCC 4.4.0. This minor version difference triggers a compilation issue, which I (with a little net-wisdom help) have fixed with a small patch (attached to this post). Another issue is that the kernel does not export the _GLOBAL_OFFSET_TABLE_ symbol, so modules need to be compiled with the -fno-pic compiler option. I'm not sure why that actually works, but it does. :-)
Last edited by altruizine; 08-22-2012 at 03:17 AM. Reason: Fix: Made explicit that make xconfig needs the cross-compile options, too |
08-17-2012, 01:41 PM | #2 |
partly refreshed
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
|
thank you very much altruizine! I will try your guide soon (pretty busy this week )
|
08-19-2012, 02:35 PM | #3 |
partly refreshed
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
|
I used both toolchain 4.4.3 (ndk-r6b) and 4.4.0 (ndk-5c) following your guide, however
Code:
# insmod xt_owner.ko insmod: can't insert 'xt_owner.ko': invalid module format Code:
# modinfo xt_owner.ko vermagic: 2.6.35.3 preempt mod_unload modversions ARMv5 Code:
# uname -a Linux localhost 2.6.35.3 #74 PREEMPT Wed Dec 21 14:50:19 JST 2011 armv7l GNU/Linux Code:
# modinfo /lib/modules/2.6.35.3/kernel/drivers/usb/host/ehci-hcd.ko vermagic: 2.6.35.3 preempt mod_unload modversions ARMv7 Does the module on the reader needs to be properly installed (aka 'make modules install')? FW: 1.0.04.12210 (rupor_rooted) linux-src: Sony linux-2.6.35.3-111114 |
08-20-2012, 11:26 AM | #4 |
Senior Altruist
Posts: 82
Karma: 600554
Join Date: Jun 2012
Device: Onyx Boox C67ML, Onyx Boox Note Pro
|
Yes, that could very well be the conflict. Running “dmesg” after trying insmod on the target may offer additional clues.
I tried adding that module as well, and in my case it's built for ARMv7. I guess that it's key that you run the “make xconfig” (or menuconfig) step with the right cross-compiler settings as well: Code:
env PATH=$PWD/../android-ndk-r6/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin:$PATH make -j4 ARCH=arm CROSS_COMPILE=arm-linux-androideabi- xconfig No, a “make modules_install” is not required to use the module. Last edited by altruizine; 08-20-2012 at 11:32 AM. |
08-21-2012, 10:12 PM | #5 |
partly refreshed
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
|
yes, that solved the problem.
When no settings are passed to make (menu/x)config, make will ask for quite a few configurations when starting building the modules (which I had all set to default). Thank you very much for your effort! |
08-22-2012, 03:18 AM | #6 |
Senior Altruist
Posts: 82
Karma: 600554
Join Date: Jun 2012
Device: Onyx Boox C67ML, Onyx Boox Note Pro
|
Thanks for your feedback! I've updated the original post to include the cross-compile options in the make xconfig step.
|
08-30-2012, 08:54 AM | #7 |
Senior Altruist
Posts: 82
Karma: 600554
Join Date: Jun 2012
Device: Onyx Boox C67ML, Onyx Boox Note Pro
|
BTW, e-ink, your mention of xt_owner.ko inspired me to try DroidWall on the Reader. And indeed, with this module loaded, DroidWall works just fine. Nice!
I've put the corresponding insmod call into /system/etc/install-recovery.sh so that it runs on each boot. |
08-30-2012, 01:12 PM | #8 |
partly refreshed
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
|
Hehe, just last night I was wondering how to auto load it (messing with /init.rc of a running ramdisk lol). So your tip comes not only very handy but also perfectly in time...
Do you know if there are WiFi scripts too? It would be even nicer to load the Droidwall stuff only upon on WiFi initialization. Also I'm still trying to find out how Droidwall actually works. How does it apply its owner ID filters to iptables and why don't they show up in iptables? see 'iptables -L' vs 'Droidwall --> Menu --> More --> Show rules' Why not change your Droidwall link to the open source f-droid.org repo with direct downloads: http://f-droid.org/repository/browse...3&fdstyle=list :P I think I'm getting super off-topic... |
09-02-2012, 04:49 PM | #9 | |
Senior Altruist
Posts: 82
Karma: 600554
Join Date: Jun 2012
Device: Onyx Boox C67ML, Onyx Boox Note Pro
|
Quote:
Anyway, dynamic startup should not be necessary. DroidWall loads an iptables configuration into the kernel after boot (or when you manually select “Apply rules”) and doesn't need to keep running in the background thereafter. The rules remain loaded despite wifi going up or down. The individual rules do show up in “iptables -L”, but this command does not list the uid data (instead you get as many similar-looking rules as you have rules in DroidWall). I think only “iptables -S” (aka “iptables-save”) does that, but that command is not compiled into the iptables binary installed on my device. Thanks for the F-Droid pointer, BTW. I had forgotten that DroidWall is open source and available there. |
|
09-03-2012, 09:12 PM | #10 | |
partly refreshed
Posts: 36
Karma: 3026
Join Date: Aug 2012
Device: It's a Sony :P prs-t1
|
So much karma altruizine! Here... have some more
Btw, I found a way to make persistant changes to /init.rc edit: Quote:
Last edited by e-ink; 09-03-2012 at 09:16 PM. Reason: see edit |
|
Tags |
kernel, linux, module, prs-t1 |
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Compiling the Linux Kernel for the Kindle | yifanlu | Kindle Developer's Corner | 82 | 12-12-2016 09:35 PM |
iLiad Kernel 2.4.21 support | cesarlr | iRex Developer's Corner | 1 | 12-21-2009 11:41 AM |
iLiad How to compile the iRex stock kernel and modules? | jharker | iRex Developer's Corner | 7 | 11-22-2008 04:50 AM |
iLiad Kernel 2.6 | Jaapjan | iRex Developer's Corner | 6 | 09-01-2008 06:17 AM |
iLiad Anyone working on a 2.6 Kernel? | Adam B. | iRex Developer's Corner | 12 | 08-15-2007 03:43 PM |