Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Sony Reader > Sony Reader Dev Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 08-17-2012, 08:16 AM   #1
altruizine
Senior Altruist
altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 600554
Join Date: Jun 2012
Device: Sony Reader PRS-T1
Lightbulb 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. :-)
  1. Download and unpack the Android NDK. I happen to use a slightly outdated version of the NDK (Revision 6), but the GCC 4.4.3 toolchain is included in newer NDK revisions as well. YMMV.
  2. Download and unpack Sony's kernel release by following the link on the distribution page (direct download). This is for the 1.0.04.12210 firmware; if you're using another revision, try finding it on Sony's open-source distribution page.
  3. Download the small kernel patch for the build issue mentioned above (attached to this post) and apply it:
    Code:
    cd linux-2.6.35.3
    zcat ../linux-gcc.patch.gz | patch -p1
  4. Grab the /proc/config.gz file from your PRS-T1, uncompress it, and put it in your kernel source tree as .config.
    Code:
    adb shell cat /proc/config.gz | zcat > .config
  5. You're ready to build the kernel. Here's a slightly complicated command line to do it in one step. I'm sure you can figure out how to do this in a fashion that's more convenient to you.
    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-
  6. Now you're ready to build a module. Assuming it's part of the kernel sources, configure it (with make xconfig or menuconfig):
    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
    Then run make, not forgetting the -fno-pic option:
    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- EXTRA_CFLAGS=-fno-pic modules
Attached Files
File Type: gz linux-gcc.patch.gz (244 Bytes, 106 views)

Last edited by altruizine; 08-22-2012 at 03:17 AM. Reason: Fix: Made explicit that make xconfig needs the cross-compile options, too
altruizine is offline   Reply With Quote
Old 08-17-2012, 01:41 PM   #2
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
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 )
e-ink is offline   Reply With Quote
Old 08-19-2012, 02:35 PM   #3
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
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
ARM Version of the module:
Code:
# modinfo xt_owner.ko
vermagic:       2.6.35.3 preempt mod_unload modversions ARMv5
while the ARM Version of the Kernel is:
Code:
# uname -a
Linux localhost 2.6.35.3 #74 PREEMPT Wed Dec 21 14:50:19 JST 2011 armv7l GNU/Linux
as well as the ARM Version of the pre-compiled modules:
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
Could that be that conflict? Can I configure/re-build the ndk toolchain to compile for 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
e-ink is offline   Reply With Quote
Old 08-20-2012, 11:26 AM   #4
altruizine
Senior Altruist
altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 600554
Join Date: Jun 2012
Device: Sony Reader PRS-T1
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
If that turns out to be your problem, I'll update my guide to make this explicit.

No, a “make modules_install” is not required to use the module.

Last edited by altruizine; 08-20-2012 at 11:32 AM.
altruizine is offline   Reply With Quote
Old 08-21-2012, 10:12 PM   #5
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
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!
e-ink is offline   Reply With Quote
Old 08-22-2012, 03:18 AM   #6
altruizine
Senior Altruist
altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 600554
Join Date: Jun 2012
Device: Sony Reader PRS-T1
Thanks for your feedback! I've updated the original post to include the cross-compile options in the make xconfig step.
altruizine is offline   Reply With Quote
Old 08-30-2012, 08:54 AM   #7
altruizine
Senior Altruist
altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 600554
Join Date: Jun 2012
Device: Sony Reader PRS-T1
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.
altruizine is offline   Reply With Quote
Old 08-30-2012, 01:12 PM   #8
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
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...
e-ink is offline   Reply With Quote
Old 09-02-2012, 04:49 PM   #9
altruizine
Senior Altruist
altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.altruizine ought to be getting tired of karma fortunes by now.
 
Posts: 77
Karma: 600554
Join Date: Jun 2012
Device: Sony Reader PRS-T1
Quote:
Originally Posted by e-ink View Post
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'
As far as I know, there is no hook that's run when wifi is enabled. Possibly you could wrap the wpa_supplicant binary, but I haven't ever tried that.

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.
altruizine is offline   Reply With Quote
Old 09-03-2012, 09:12 PM   #10
e-ink
partly refreshed
e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.e-ink could sell banana peel slippers to a Deveel.
 
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:
Originally Posted by mobileread.com/forums
You must spread some Reputation around before giving it to altruizine again.

Last edited by e-ink; 09-03-2012 at 09:16 PM. Reason: see edit
e-ink is offline   Reply With Quote
Reply

Tags
kernel, linux, module, prs-t1

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Compiling the Linux Kernel for the Kindle yifanlu Kindle Developer's Corner 60 05-18-2014 08:47 AM
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


All times are GMT -4. The time now is 11:47 AM.


MobileRead.com is a privately owned, operated and funded community.