Compiling Kernel modules for z902 - Android Q&A, Help & Troubleshooting

Okay so heres my problem.. Im currently trying to compile modules to add to my z902. i have the 3.0.8 kernel source used for the mele which uses the same allwinner a10 proccessor. I have done some looking around and found that in order for android to load the module it needs to be compiled with the correct vermagic as well.. i managed to get info from both a module already on the device and from the module i compiled.
My module retrieves the following info when using modinfo()...
filename: hid-sony.ko
license: GPL
alias: hid:b0003v0000054Cp0000024B
alias: hid:b0005v0000054Cp00000268
alias: hid:b0003v0000054Cp0000042F
alias: hid:b0003v0000054Cp00000268
depends:
vermagic: 3.0.8+ preempt mod_unload modversions ARMv7
the original im comparing to looks as follows...
filename: sun4i-keypad.ko
alias: platform:sw-keypad
license: GPL
author: Aaron.maoye<[email protected]>
description: SW keypad driver
depends:
vermagic: 3.0.8+ preempt mod_unload modversions ARMv7
this is what it took me a while to acheive. the problem is when trying to insert the module into linux using the insmod command i get this error..
insmod: init_module 'hid-sony.ko' failed (Exec format error)
afterwords i ran dmesg and noticed a line that looks as follows:
hid-sony: dissagrees about version of symbol module_layout
after doing this i read about a way to overlook the vermagic by using modprobe..
here i ran into another problem.. when executing modprobe as follows i recive this error..
#busybox modprobe hid-sony.ko
modprobe: chdir(/lib/modules): No such file or directory
after recieving this error i tried making the directory and typed in the same command..
it returned that modules.dep was not found..i looked into this file and it seems to be where linux stores all the initiated drivers.
I searched high and low and could not find this file anywhere on the system.
my question is.. What the hell am i doing wrong..? lol
I compiled the entire kernel first.. then i compiled the modules afterwords to a set location.
does the baseband version info have anything to do with this because i couldnt find any info on it..
the z902 has 1.2.3 as a baseband..? is it possible i may not have the correct kernel source..?
anyone who helps me solve this i will personally buy them a unit and set it up for them.. lol

BUMP
Bump.. please someone help... how can i make modules.dep without depmod in my busybox applets.. anyone know if i can update busybox within android or through linux. id really like to add support for some controllers and bluetooth dongles. im pretty sure the module is setup and compiled right. but its trying to install it in the wrong place. unless it matters that android is compiled within the kernel as well.. because the tutorial i read through didnt say it was neccisary. i belive it was aimed towards the mele a2000. but its an allwinner a10 with the same kernel. 3.0.8+.. the only thing in not sure of is the build number. the z902 shows a 1.2.3 build. and i have no clue what build number the mele a2000 uses.

prob a waste of time as nobody seems interested...
I managed to update busy box and add depmod to the list of applets. After doing so I tried mod probe and the module still won't load. Don't have the info on the error in front of me but it was something to the effect that it was not compatible with the kernel. Back to square one. Going to try compiling it with android over the weekend and give it another attempt. Need to find some kind of a work around for actual controllers for this thing. USB/bt joystick center would be a phenomenal upgrade for this device.

Related

Compile Kernel Module

Whats the right way of compiling a module for the Atrix kernel?
I'm currently using the stock android 2.6.32.9 linux sources and the Atrix's config, although I can't get the kernel to agree with the modules I'm trying to build.
Motorola didn't use froyo sources to compile the kernel, they used vanilla 2.6.32.9 to do it.
The last problem is that modules are built as ARMv5 instead of ARMv7, probably since there is a patch setting the system type to Tegra 2.
Compile Atrix 2.3.6 kernel mods
I've grabbed the source for the 91 kernel source since the 141 kernel source has not be release. I need to get iso9660 and udf file system support.
I've followed this thread on compiling the kernel http://forum.xda-developers.com/showthread.php?t=1141506
I can successfully compile the kernel and the kernel modules, but I keep getting an invalid module format error, what's a revised way for compiling kernel mods?
[email protected]:/opt/dev/kernel modules/kmods$ sudo insmod ext4.ko
insmod: error inserting 'ext4.ko': -1 Invalid module format
[email protected]:/opt/dev/kernel modules/kmods$ sudo insmod udf.ko
insmod: error inserting 'udf.ko': -1 Invalid module format
My end Goal after I get the kernel mods working is to compile a kernel with swap support.
Thanks for any help rendered.
When you get the insmod errors try looking at dmesg at the tail end of the log, usually that error means the version string doesn't match what is baked into the kernel.
Cheers!
cpuchip said:
My end Goal after I get the kernel mods working is to compile a kernel with swap support.
Thanks for any help rendered.
Click to expand...
Click to collapse
The general rule is that you do not want to enable swap on a flash based file system, but that is up to you.
Are you getting the module load errors against your own kernel, or are you trying to reproduce the stock kernel and your modules fail when loading against the real stock kernel?
If the latter, there are many things to look at. First would be your cross tools. These could easily produce incompatable code. But if the error is just a symble not found, then most likely your kernel config does not match the running kernel.
EDIT: missed the error messages, but it still is about the same answer. The compiler is generating the wrong code either becasue it is different from that whcih generated the running kernel, or the config options comming out of your kernel tree are not matching.
Have you tried actually running your kernel?
Thanks so much for the advice from the two of you. These are my dmesg errors. they pop up right after I enter the command: insmod isofs.ko
[505123.289798] usb_ether_get_stats
[505123.322414] isofs: no symbol version for module_layout
I'm new to kernel work. I used the config from my phone directly, it was located at /proc/config.gz
I used the cross compilers as defined in the post I linked to in my first post. unfortunately I don't have the source to 141, just 91, what's on source forge from motorola. I don't know if they did any changes between the two, but the release version was slightly different between the two.
I'm okay with burning through external sd cards for the sake of having more browser tabs open, and an overall more responsive system.
---------- Post added at 10:44 PM ---------- Previous post was at 10:20 PM ----------
I saw in one thread that you have to compile the kernel first before the modules. I did that, and now I'm getting a new error:
[506616.823352] usb_ether_get_stats
[506616.867837] isofs: disagrees about version of symbol module_layout
seems to be a version conflict. do I have to inject that in on compile?
Have a look here: http://forum.xda-developers.com/showthread.php?t=1014010
Not the modules you are talking about, but same error.
For cifs/smb I ended up using smbnetfs, taking advantage of the fuse fs already in place. /dev/fuse has to be set group fuse with rw for group, and user adas has to be in group fuse.
Cheers!

[Q] DEVELOPPER HELP: lite'ning or ninphetamine source code, help building ftdi_sio.ko

Hi,
If you're a developer, I need your help.
I am running the following:
Android 2.3.4
Baseband I9100XXKH3
Kernel 2.6.35.11-ninphetamine-2.0.5+ ninpo at titan #20
Version Lite'ning Rom v6.1 XXKH3
I would like to compile a module (usb serial driver ftdi_sio.ko). For that I need the kernel source code. I found github.com /Ninpo /ninphetamine and got as far as compiling the module and insmod it, but I got in dmesg
"ftdi_sio: version magic '2.6.35.11-ninphetamine-2.0.5 SMP preempt mod_unload ARMv7 ' should be '2.6.35.11-ninphetamine-2.0.5+ SMP preempt mod_unload ARMv7 '
My problem I assume is that the source for ninphetamine I use, Android-galaxys2-ninphetamine-2d1ffbc, is not the right one. I can't find on the web the right source code version (2.0.5+), not to mention 2.1.3.
Anyone can point to the source code for me? (on a server that is running, kernel.org is on maintenance)
I am also quite open to install another ROM, kernel or other... even if possible one that has by default ftdi_sio.ko module running by default.
Thanks in advance for your responses.
edit:
I have now figured out so much, I can hack a bit to be able to insmod the modules:
- had to manually edit .config (replace ninphetamine-2.0.5 by ninphetamine-2.0.5+)
- make menuconfig modules ARCH=arm CROSS_COMPILE=arm-linux-androideabi-
- make drivers/usb/serial/*.ko ARCH=arm CROSS_COMPILE=arm-linux-androideabi- EXTRA_CFLAGS=-fno-pic
(it seems this -fno-pic was required for that version of tools, but does not work for all modules either)
=> it would still be nice to have access to exact source/config used to compile a ROM/kernel as well as the tools used to build it.
Now both modules load, but when I plug my device I am back to start with dmesg:
- usb 2-1: new full speed USB device using s3c_otghcd and address 2
- usb 2-1: device v0403 p6001 is not supported
- host_notify: ndev name=s3c_otghcd: from state=0 -> to state=5
- otg_dbg: in otg_handle_interrupt()::00087
- => Port Interrupt
- otg_dbg: in process_port_intr()::00271
- => port enable/disable changed
- hub 2-0:1.0: unable to enumerate USB device on port 1
Hope anyone get a clue.
Bump Bump Bump
A nice piece of advice was found here:
http://forum.xda-developers.com/showthread.php?p=18081882#post18081882

[Q] kernel modules for ICS, 2.6.39.4, error loading module

Hi there,
I would have posted this in /dev but you know...first post.
I was trying to apply these kernel modules: http://forum.xda-developers.com/showthread.php?t=1557868
but I'm getting the error "insmod: init_module '/system/lib/modules/cifs.ko' failed (Exec format error)", or if i use the busybox insmod i get the following error: "insmod: can't insert '/system/lib/modules/cifs.ko': invalid module format"
Are updated versions available for 2.6.39.4? I'm guessing the ones for 2.6.36.3 aren't inter-operable.
I haven't used the other bash-4.2.zip and config from the above link, is that necessary for this to work?
Thanks for any tips on getting these kernel modules working.
Thanks,
abactor
IRC channel
Is there an IRC channel that's in use for sony tablet S, by any chance?
compile module yourself?
You might be successful compiling the kernel modules yourself from the available source code and a crossplatform compiler on linux. It has worked for me for the tun module
Source code at sony.net, I cannot publish external links yet. But you can find the link e.g. in this thread at first page http://forum.xda-developers.com/showthread.php?t=1473621
The free Sourcery G++ Lite for ARM GNU Linux did a good job for me.
I don't know of any Tablet S IRC channels, but it would be cool if there was.
As for the modules, you do need to recompile it. Kernel modules (in practically every Linux flavour) are completely incompatible, even across minor revisions, but recompiling against the newest code and headers should yield the same result with a new module.
The Sony.net link walsera mentioned is (I believe) this one
Thanks guys,
I'll look into it. I've compiled c code for android under mingw, but I don't have a linux toolchain setup. Anyone try to compile these sorts of things on the device itself (I.e. not cross_compiled)? I just started playing around with a native android/arm gcc toolchain, but I was having linker issues I think, with crt0.o and libc and whatnot.
Thanks and take care,
Abactor
I've never tried it natively on the device, but there have been a couple of developments into native versions of gcc and whatnot, so that may be worth a look. You can always compile on your PC, then copy the ko over...
After mounting a debian chroot on the tablet and installing the needed tools, unpacking the kernel source, and copying over config.gz, and editing .config to build the needed modules then calling make modules everything seems to work. What's the best way to make them available and what modules do people need? I've done ntfs and tun so far.
Take care
A

[HELP] Compiling RTL8187 Driver

I'm trying to compile the rtl8187 kernel module for my archos 101 g9, I've pulled the archos-gpl-gen9-kernel-ics git repository and I've used the android-ndk r8 to compile the modules. Everything looks perfectly fine (the vermagic is matching the other modules "3.0.8+ SMP preempt mod_unload ARMv7" no issues there) except when I try to insmod the eeprom_93cx6.ko (This module needs to be loaded before the rtl8187.ko) I get told in dmesg "eeprom_93cx6: unknown relocation: 27"
After googling around it hasn't really helped me any.
So hopefully you guys can help me out. Any ideas of whats causing the above error?
mcd1992 said:
Sorry if this should go in the other gen9 section of this forum, wan't really sure. Feel free to move it mods.
I'm trying to compile the rtl8187 kernel module for my archos 101 g9, I've pulled the archos-gpl-gen9-kernel-ics git repository and I've used the android-ndk r8 to compile the modules. Everything looks perfectly fine (the vermagic is matching the other modules "3.0.8+ SMP preempt mod_unload ARMv7" no issues there) except when I try to insmod the eeprom_93cx6 (This module needs to be loaded before the rtl8187.ko) I get told in dmesg "eeprom_93cx6: unknown relocation: 27"
After googling around it hasn't really helped me any. (Not sure what R_ARM_PLT32 and all that is)
So hopefully you guys can help me out. Any ideas of how to my realtek wifi dongle working?
Click to expand...
Click to collapse
Hi !
You can try to update :
sudo apt-get install build-essential
sudo apt-get install libssl-dev
...and now recompile the module ....and also you need to take a look at Module.symvers - look into it an see if export symbols !
surdu_petru said:
Hi !
You can try to update :
sudo apt-get install build-essential
sudo apt-get install libssl-dev
...and now recompile the module ....and also you need to take a look at Module.symvers - look into it an see if export symbols !
Click to expand...
Click to collapse
Thanks for replying.
I'm using the latest build-utils and libssl for my os and inside my Module.symver the modules does appear.
Code:
0x00000000 eeprom_93cx6_read drivers/misc/eeprom/eeprom_93cx6 (unknown)
0x00000000 eeprom_93cx6_multiread drivers/misc/eeprom/eeprom_93cx6 (unknown)
mcd1992 said:
Thanks for replying.
I'm using the latest build-utils and libssl for my os and inside my Module.symver the modules does appear.
Code:
0x00000000 eeprom_93cx6_read drivers/misc/eeprom/eeprom_93cx6 (unknown)
0x00000000 eeprom_93cx6_multiread drivers/misc/eeprom/eeprom_93cx6 (unknown)
Click to expand...
Click to collapse
Ok !
Seem to be good ! If you want I can try to compile for you ...but I need your source module ...I will take a look tomorrow if you upload it !
Digging deeper into google I actually found a solution, adding -fno-pic to the compiler flags stops the error.
Original post by the_zuck
EDIT:
Yesssssss, Originally inserting the realtek dongle was causing a backtrace to appear in the dmesg but unloading the built-in modules (compat, wl12xx*, mac80211, and then cfg80211) and then loading my compiled modules (cfg80211, lib80211, mac80211, eeprom_93cx6, and then rtl8187) has resulted in success
So finally got my tablet where I want it, arch linux chroot with aircrack-ng / kismet running on it nicely with my alfa dongle. Thanks for trying to help me solve my issue at least surdu_petru
Compiled Modules tested and working on surdu_petru's 4.0.7 rooted rom.
mcd1992 said:
Digging deeper into google I actually found a solution, adding -fno-pic to the compiler flags stops the error.
Original post by the_zuck
EDIT:
Yesssssss, Originally inserting the realtek dongle was causing a backtrace to appear in the dmesg but unloading the built-in modules (compat, wl12xx*, mac80211, and then cfg80211) and then loading my compiled modules (cfg80211, lib80211, mac80211, eeprom_93cx6, and then rtl8187) has resulted in success
So finally got my tablet where I want it, arch linux chroot with aircrack-ng / kismet running on it nicely with my alfa dongle. Thanks for trying to help me solve my issue at least surdu_petru
Compiled Modules tested and working on surdu_petru's 4.0.7 rooted rom.
Click to expand...
Click to collapse
Im trying to compile the rtl8187 driver for my s3 - could you point me in the right directions to try and compile it. My s3 is rooted running a custom kernel. Thanks.
mcd1992 said:
Digging deeper into google I actually found a solution, adding -fno-pic to the compiler flags stops the error.
Original post by the_zuck
EDIT:
Yesssssss, Originally inserting the realtek dongle was causing a backtrace to appear in the dmesg but unloading the built-in modules (compat, wl12xx*, mac80211, and then cfg80211) and then loading my compiled modules (cfg80211, lib80211, mac80211, eeprom_93cx6, and then rtl8187) has resulted in success
So finally got my tablet where I want it, arch linux chroot with aircrack-ng / kismet running on it nicely with my alfa dongle. Thanks for trying to help me solve my issue at least surdu_petru
Compiled Modules tested and working on surdu_petru's 4.0.7 rooted rom.
Click to expand...
Click to collapse
I was trying to download the rtl8187 for my device that you posted and the link is bad. Any chance I can get it from you? Im trying to get an 8187.ko to work on my MK808 TV Stick and the rtl8187.ko that I have is giving me an "exec format error" when I insmod.

Help build kernel module for MiBox 1S

So long story short, I wanted to build the ftdi_sio.ko module for the linux kernel of android based MiBox 1S. I was able to build the module but once I run "insmod" via adb, the system crashes and reboots (I couldn't see any error message because of this). Please could anyone suggest how to find where the problem is or whether what I wanted to do is even possible?
The device is running system version 1.3.88 rooted by the Chinese 360 root app. Kernel version follows:
Code:
adb shell cat /proc/version
Linux version 3.10.33 ([email protected]) (gcc version 4.7.3 20130205 (prerelease) (crosstool-NG linaro-1.13.1-4.7-2013.02-01-20130221 - Linaro GCC 2013.02) ) #1 SMP PREEMPT Tue Jun 16 00:38:26 CST 2015
As Xiaomi doesn't have kernel source release for MiBox (afaik), I went to look for the Amlogic kernel source for AML8726-MX (M6).
The closet kernel source I could find was from Stane1983's github repo amlogic-m6_m8. I'm using the earliest commit for 3.10.33 kernel version.
For the building of the kernel module, I pretty much followed a github document named 'Android-Build-Kernel-Modules-HOWTO.txt' by marco-pratesi. I downloaded the toolchain from the archive of linaro releases 13.02 which shows the same version of the android kernel above. I copied the .config from arch/arm/configs/meson6_deconfig and use 'make menuconfig' to add OTG_support and USB FTDI Single Port Serial Driver. Make the module by "make M=drivers/usb/serial/". And then adb push the generated ftdi_sio.ko file to /mnt/sdcard.
For loading the module, I run
Code:
adb shell
su
insmod /mnt/sdcard/ftdi_sio.ko
Then the box freezes for 10 seconds and reboots...
So my questions are:
1. Is there a way to find some logs of insmod to know what's gone wrong? As the system freezes and reboots, I can't use the dmesg method normally suggested, can I?
2. As the kernel source is from Amlogic, could it be that Xiaomi created their own kernel that is very different from this one to cause this problem?
3. Even if Xiaomi used exactly the same source code, as i'm using the meason6_defconfig file from the repo, it is likely to be different from the one Xiaomi was using. Would it matter for just building a module?
4. Is it possible to recover the config file from the prebuild kernel? I counld't find /proc/config.gz. And modprobe has error "can't open 'modules.dep': No such file or directory. "
5. What else I can try?
Sorry for the long post. I'm very new to this type of work and this forum as well. So any comments would be appreciated.

Categories

Resources