[Q] [Module] Build and load module on GS3 - Galaxy S III Q&A, Help & Troubleshooting

Hello,
I tried to do a simple task which raise several problem and it start to drive me crazy, so here I am, asking for help. The subject may have been already mentioned, but can't find an issue with the galaxy s3.
I work with ubuntu 12.04 and Odin on win7. My GS3 has XXELL4 baseband, and 3.0.31-742798 kernel version.
I need to load and run a custom module (let's say a "hello world" one for begin) on the galaxy S3.
I compiled it through a Makefile with the toolchain from the ndk package (
Code:
path_to_ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
and the source code from the samsung web site (GT-I9300_JB_Opensource_Update8.zip).
Obviously, when i tried to insmod my module, I've got some compatibility error like
Code:
Exec format error
.
The fact is that the kernel from website is not the same as the phone one.
So I tried to put the kernel from the website on the phone
I compiled it with the same toolchain and I received a zImage file in result. But what to do with this file ? I extracted a boot.img from the phone with Odin and split it (with perl script stuff) to use the extracted files with my compiled zImage for reconstruct a new boot.img. But since fastboot is not available on GS3 (or I miss something) I can't simply
Code:
$ fastboot flash boot boot.img
, and need to use Odin again. So I replace the boot.img from odin's backup folder on my PC with my boot.img. But the nandroid.md5 file raise an error. I deleted the dd5 file and regenerate one with md5sum. Still have the Exec format error when insmod. Am I doing it wrong or too complicated ? If I can correct the md5 error, is that my module will work ?
I also tried to compil my module directly with the kernel from the phone but didn't manage to extract the kernel files to do it. Stuck with a boot.img. Same with the stock kernel from http://forum.xda-developers.com/showthread.php?t=1646610
I made a lot of research but don't find any concrete solutions to my simple task. Maybe I miss something or looking too deep.
Is there a more simple way to run a custom module on the GS3 ? How do I find a loadable and targetable kernel for my module ?
sorry for my english

Related

Building Kernel

Hi,
i downloaded from opensource.samsung.c_om source code of S5830 firmware, compiled the kernel and i cannot flash it to the phone, after compilig there is two different files zImage has 2,9MB and Image has 6.8MB, i use CWM and function flash kernel, but after flashing it Phone doesnt boot, what iam doing wrong?
Or what kind of source i may use for gingerbread 2.3.3??
For compiling i use: Ubuntu distribution.
Use adb for the 6MB one and use CWM Manager for the 2MB one .
Sent from my GT-S5830 using XDA App
Yes, but if i flash "2MB" kernel with CWM using function flash kernel, phone has a boot loop and never don't boot.
u need to use the zimage file.. unpack samsungs default kernel to get ramdisk, and repack the ramdisk with the zimage file. but ur kernel need to have local version matching the module in the ramdisk, or it wouldnt boot.
How i can do it? Im doing it first time
because u already successfully compiled a kernel, i assume u know linux workaround.
first read
http://forum.xda-developers.com/showthread.php?t=1173427 to unpack the samsung default kernel.
then cd into the module dir which is ramdisk/lib/modules and issue this command
Code:
strings fsr.ko | grep vermagic
and it shoud give some output eg
Code:
vermagic=2.6.35.7-perf-CL382966 preempt mod_unload ARMv6
take note of the local numbers, in my case above its "-perf-CL382966".
then u need to edit the kernel config file, which is arch/arm/configs/cooper_rev03_defconfig. search for this string
Code:
CONFIG_LOCALVERSION="-perf"
and edit it so it matched the local version of the module from the ramdisk eg
Code:
CONFIG_LOCALVERSION="-perf-CL382966"
now compile ur kernel. take the result zImage file and repack it back with the ramdisk u unpack earlier.
Oh, thanx a lot, now i compiling new kernel, but after i unpack my old boot.img and watch into ramdisk, there is no file called zImage :/
if u read carefully the link i gave u earlier, u should know that its the boot.img-kernel file. replace it with ur compiled zimage file.
I do exactly what u wrote, than i flash boot.img with odin as "PDA" but phone has in the boot loop again
File: http://www.earth-project.ic.cz/CODE.tar
what did u edit in the kernel? first u should try to compile plain default without any editing to make sure it even boot.
and u need to compile using the defconfig u edited
Code:
make cooper_rev03_defconfig
make
or just
Code:
./make_kernel_GT-S5830.sh
I did't edit anything, i compile only source what i DL from samsung source, but old bootimg have 6,1MB and my 5,9, is that problem?
size is not a problem at all. the size of my highly optimize kernel after compile is just 2.3mb, after repack with ramdisk is just 5.3mb. it boot just fine. maybe u download wrong source? use froyo kernel source for froyo rom, and gb kernel source for gb rom. dont mismatched.
I use: GT-S5830_S5570_EUR_OpenSource.zip from: https://opensource.samsung.com/
For: S5830XEKPH Firmware - Gingerbread 2.3.3.
I would really like, if you can tell me what kind of software and kernel source i may use.
see, thats the problem. ur compiling froyo kernel for gb rom.
use the GT-S5570_S5670_S5830_Opensource_GB.zip or GT-S5830_Opensource_GB.zip. both for gb. personally i use the second one. and toolchain use Sourcery G++ Lite 2011.03-42 for ARM EABI
THX!! I will test it! )
Ok, that is better but not too much, now iam stucked on the screen with text "GALAXY ACE" "GT-S58930" .... i wait for aprox. 30 minutes and nothing happen. :/
Killercek said:
Ok, that is better but not too much, now iam stucked on the screen with text "GALAXY ACE" "GT-S58930" .... i wait for aprox. 30 minutes and nothing happen. :/
Click to expand...
Click to collapse
u didnt edit anything rite? if u just compile the stock kernel source with just modifying local version in config file, it should boot.
maybe u should install qtadb and look at the logcat while it boot, and if it stuck, look for the last line in logcat.
I see only that:
20:53:55.859 exec '/system/bin/sh' failed: No such file or directory 2 2) -
Oh, iam on windows i don't have linux computer here, iam compiling on my server and i cannot connect phone on it
that error indicate that the module in ramdisk mismatch with the kernel local version. check again if the module local version matched with the kernel local version in the defconfig file.
THX it working!

[Q] Repacked boot.img gives bootloop, how to do it correctly?

I am building my own ROM now, and I am checking to do my own unsecure stock kernel.
I found the tools that unpack a kernel boot.img file and edit the properties file to make it unsecure, but after repacking the kernel and trying it, device went into a boot loop.
what is needed to repack it?
the tools i found were these here, mainly some perl or shell scripts that does the mkbootimg thing a bit automatically, but I also tried manually.
I did not compile mkbootimg, I used a ready made linux binary, which seem a bit old because it does not contain the --pagesize parameter, and that's the only missing thing from the original, does this cause bootloop?
the ramdisk should be ok, but packing it back with zImage is not....
Fixed
I used Linux tools and they failed, but I found the Android Image Kitchen for windows (cygwin) and strangely they worked, the produced boot.img works as expected !!!

[Q] [Module] Build and load module on GS3

Hello,
I tried to do a simple task which raise several problem and it start to drive me crazy, so here I am, asking for help. The subject may have been already mentioned, but can't find an issue with the galaxy s3.
I work with ubuntu 12.04 and Odin on win7. My GS3 has XXELL4 baseband, and 3.0.31-742798 kernel version.
I need to load and run a custom module (let's say a "hello world" one for begin) on the galaxy S3.
I compiled it through a Makefile with the toolchain from the ndk package (
Code:
path_to_ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-
and the source code from the samsung web site (GT-I9300_JB_Opensource_Update8.zip).
Obviously, when i tried to insmod my module, I've got some compatibility error like
Code:
Exec format error
.
The fact is that the kernel from website is not the same as the phone one.
So I tried to put the kernel from the website on the phone
I compiled it with the same toolchain and I received a zImage file in result. But what to do with this file ? I extracted a boot.img from the phone with Odin and split it (with perl script stuff) to use the extracted files with my compiled zImage for reconstruct a new boot.img. But since fastboot is not available on GS3 (or I miss something) I can't simply
Code:
$ fastboot flash boot boot.img
, and need to use Odin again. So I replace the boot.img from odin's backup folder on my PC with my boot.img. But the nandroid.md5 file raise an error. Am I doing it wrong or too complicated ? If I can correct the md5 error, is that my module will work ?
I also tried to compil my module directly with the kernel from the phone but didn't manage to extract the kernel files to do it. Stuck with a boot.img. Same with the stock kernel from http://forum.xda-developers.com/showthread.php?t=1646610
I made a lot of research but don't find any concrete solutions to my simple task. Maybe I miss something or looking too deep.
Is there a more simple way to run a custom module on the GS3 ?
sorry for my english
Hello and welcome to xda!
You do not have to use odin to flash your kernel, you can do it via custom recovery too.
Just get an simple cwm package of another kernel for s3 and replace the boot.img in the zip.
I attached a simple empty cwm package, just drag your boot.img to the root of the zip with winrar or something.
hsrars-d said:
Hello and welcome to xda!
You do not have to use odin to flash your kernel, you can do it via custom recovery too.
Just get an simple cwm package of another kernel for s3 and replace the boot.img in the zip.
I attached a simple empty cwm package, just drag your boot.img to the root of the zip with winrar or something.
Click to expand...
Click to collapse
Thanks
I've got also a md5 error when i tried to restore with cwm, since I have no md5 file in my folder. Do I need to generate one ? how ?
EDIT: so a generate a md5 file with md5sum, but still have the Exec format error when i try to insmod my module.
ok, im not good with kernel stuff/modules so i cant help you any further...
try to find someone that has experience with kernel modules
edit: found something with google, not exactly for s3 but the error is pretty common:
http://www.linuxquestions.org/questions/linux-kernel-70/insmod-error-version-magic-4175424366/
http://forum.xda-developers.com/showthread.php?t=444338&page=1
http://stackoverflow.com/questions/...for-android-unknown-relocation-27-when-insmod
Why are you posting in this section?
Glebun said:
Why are you posting in this section?
Click to expand...
Click to collapse
well ... I don't yet have access to other section. But If someone could move the thread in a more appropriate one I'll thanks him.
Yes, you do. Questions go in the Q&A section, obviously

[Help nedded] Repacking boot.img with newly compiled zImage

Hello,
I searched a lot for a tutorial showing how to repack or create a boot.img with a newly compiled zImage BUT didn't find a valid one for S3.
I'm using kubuntu 13.04 and the kernel compilation (update10) succeeded as I (painly) managed to arrange the build environment.
I then tried to use abootimg to unpack another boot.img but both the command of update or create boot.img are failing because of size mismatch ...
Can anybody help me ? It's the last step keeping me away from entering the S3 kernel development world
Try XDA Development hacking Android Chef Central etc .
jje

[Q] [KERNEL][DEV HELP] Recreating Stock Kernel

Hello,
I have changed my handset and now have a spare SGS2 (I9100) for learning about the kernel.
I'm running the following stock kernel & rom downloaded from sammobile.com ...
I9100XWLSW_I9100XEULS5_XEU.zip
In order to teach myself more, I am trying to create a replica of my current stock kernel...
3.0.31-1211311
I've downloaded/ familiarized myself with Android SDK, NDK (r8e) and Samsung Open Source (GT-I9100_JB_Opensource.zip).
I've got as far as making a kernel from the Samsung Source, but I've got the following differences:
1. New zImage size is approx 4Mb original zImage (in boot.img from I9100XWLSW_I9100XEULS5_XEU.zip) is approx 8Mb
2. New zImage also compiled 4 Modules in /lib/modules, there are six in the original zImage
Clearly the two are different and this is where I am stuck.
If I unpack the original zImage, I get what looks like a disk image, /data, /dev, /proc etc, if I unpack the new zImage I get two directories /dev & /root both are empty.
The difference in modules is also worrying, makes me think that the config in the original zImage is different to that supplied when I run 'make u1_defconfig'
I've sifted through a lot of forums, tuts and docs to get this far, any dev's help with some pointers? Is it possible to compare kernels?
Thanks,
YYo
**Please save yourself some time by reading the following**
Do not answer with 'I don't know but...'
'...have you tried kernel/ Rom xyz'
'...don't modify your kernel, you'll most likely brick your phone'
'...leave kernel development to people who know how to do it'
'...I am nigerian businessman who has just inherited $2,000,000...'
Bump,... anybody got any ideas how I can find out what was included when the original kernel was compiled (without going back to Samsung)?
YYo

Categories

Resources