Driver development for a stock kernel possible? - Galaxy S III Q&A, Help & Troubleshooting

Hello,
I've been trying to compile a driver to the stock kernel of my S3. I've ensured that I have the correct kernel version and have done a modinfo on the compiled driver to check the version magic string is correct. However I can't insmod the driver. I am root on the device when I try to do so.
I've managed to do this on other brands of phone which leads me to wonder if the S3 default kernel config from the open source repository correctly reflects .config that was actually used for the release kernel on the phone.
Is it possible to develop drivers for the stock kernel? (3.0.31-2788594, build number JSS15J.I9300XXUGNJ2 in my case). Does anyone have a correct .config for this kernel build?
regards,
Rob

Related

Kernel sources

I have a Garminfone and have done a lot of Rom hacking with it so far, enough that I want to port cyanogen to it now. In the config.gz file there are references to Garmin specific items... how do I go about figuring what is included in the kernel and if the stock one might work with the right config settings. I know that they load a few ko modules at boot, but I don't know the requirements for when they must release kernel sources and what to do with it if they do.
I know they have released some in the past for the a10 but not the a50, and none for the 2.1 build.
I do know that they use the 2.6.29 kernel so is there a chance that I could use the current kernel with froyo?
Any assistance would be appreciated.

Q on building the "latest" Android Kernel

I have a general question about building the Android kernel. For understanding purposes, I'm a C/C++/C# developer (and Android application developer), but have little functional knowledge of the Linux kernel.
With regard to porting Android, I'm curious how one builds the latest Kernel. The Android Kernel is not simply the standard Linux Kernel branch, correct? Where does one get the latest "Android" Kernel from? Does Google host a Kernel site as part of AOSP that we can sync with?
Once you have the latest Kernel, is it simply a matter of ensuring the Make file is accurate, adding the appropriate device drivers (as .so files?) for your particular hardware, and performing a Make? Then I assume you can update your device's Kernel with the one you've buildt?
In closing, for example, I'd like to sync the Android 3.0 Kernel, update the drivers necessary for my EVO 4G, build the latest Kernel, and then flash it to my phone. Just looking for some insight as I start getting educated on the topic.
Thanks for any advice you can offer!
Actually, the android kernel is very similar to the linux kernel (well it is based on the linux kernel). You can get the kernel from here: http://source.android.com/source/downloading.html. You can also take a look here: http://elinux.org/Android_Kernel_Download and here: http://elinux.org/Android_Kernel_Features. It will be quite difficult to build a kernel for your device without the source (there's none for 3.0.1 for your device), but you could still build it from a lower kernel version: http://linux.softpedia.com/progDownload/HTC-EVO-4G-Sprint-Kernel-Source-Code-Download-58254.html.
Thanks for the info, Theonew. When you say that it will be difficult for me to build the kernel for an EVO without the source, is that because the vendors (Qualcomm, for example) haven't made source for their devices available, so it's hard to build the drivers (.so files?) that are compatible with the latest kernel?
Shidell said:
Thanks for the info, Theonew. When you say that it will be difficult for me to build the kernel for an EVO without the source, is that because the vendors (Qualcomm, for example) haven't made source for their devices available, so it's hard to build the drivers (.so files?) that are compatible with the latest kernel?
Click to expand...
Click to collapse
HTC hasn't released the source of the kernel v3.0.1 (which comes in Ice Cream Sandwich) for your device (since it's not available for your device...yet at least).

Build kernel from source

I was trying to build Kernel from original HTC Source. My rom on phone has version 2.18.401.3, but the original HTC kernel source (enru-3.1.10-g7f360be.zip) with this version did not build, because it contains only hox (endeavour) "in arch\arm\mach-tegra" not HOX+ (enrc2b). I was using the extracted config from my device. The HTC kernel source with the biggest number (2.18.1136.2, enrc2b-3.1.10-42105bd.zip) builds properly but the merged boot.img did not boot. I checked with other boot.img from HOX+ i.e. from cyanogenmod (unpack, repack) whether I generate a correct one, but it was binary same. So I believe the zImage has some defect. Please help.
Trivalik said:
I was trying to build Kernel from original HTC Source. My rom on phone has version 2.18.401.3, but the original HTC kernel source (enru-3.1.10-g7f360be.zip) with this version did not build, because it contains only hox (endeavour) "in arch\arm\mach-tegra" not HOX+ (enrc2b). I was using the extracted config from my device. The HTC kernel source with the biggest number (2.18.1136.2, enrc2b-3.1.10-42105bd.zip) builds properly but the merged boot.img did not boot. I checked with other boot.img from HOX+ i.e. from cyanogenmod (unpack, repack) whether I generate a correct one, but it was binary same. So I believe the zImage has some defect. Please help.
Click to expand...
Click to collapse
use this, I kept it in tact for this reason :
https://github.com/Lloir/htc_kernel_oxp/tree/master
It's the source straight from htc
you'll also need this commit https://github.com/Lloir/htc_kernel_oxp/commit/b3cade38f9d17682778ea767722d20b94696f6ae which has the defconfig unless you already have it.
Enjoy
Lloir said:
use this, I kept it in tact for this reason :
https://github.com/Lloir/htc_kernel_oxp/tree/master
It's the source straight from htc
you'll also need this commit https://github.com/Lloir/htc_kernel_oxp/commit/b3cade38f9d17682778ea767722d20b94696f6ae which has the defconfig unless you already have it.
Enjoy
Click to expand...
Click to collapse
I tried the master branch, but it make boot loop all the time. Another test would be, if you can provide me a boot.img what I can test.
I found the solution, is for me a little bit strange but it works. In case somebody can show me the big difference that I can understand the "why", whould be fine.
I used for build this toolchain: prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin stored: git clone --depth=1 https://android.googlesource.com/platform/prebuilt
before I was using arm-eabi-4.8/bin/ from master branch(not sure about git clone path)
There is now one point I did not understand, I build original source, why is then my SIM not working? (no question for pin), (Answer: Maybe are the orignal modules signed. After change the modules on /system/lib/modules/ it was working like before), because after flashing the android revolution boot.img, it was all working. Any ideas? (Answer: It is because they didn't change th zImage)

Porting drivers to a clean kernel?

How can I port the vendor's kernel drivers for my model phone from their open-source kernel code to a clean kernel of a similar version number?
They are using 4.4.78 perf+ so presumably that would port to a generic android 4.4 kernel?
Is there any books or guides available to provide an overview of which parts of the android kernel get changed during development of a new model?
The reason I need to port the kernel source drivers to a clean kernel is because I cannot replicate the vendor's environment and have failed to make their source code standalone compilable - so it fails to build even some basic modules.
Bump - haven't found any info on how to work the Android Linux kernel in terms of the boot loader and drivers.
Bump!
Bump!

Need help with errors when compiling kernel from source.

So, I recently got a ASUS Zenfone 4 Selfie Pro, the phone is stuck on android 7.1 and doesn't have any roms, nothing, just TWRP. So I'm on a journey trying to build stuff for this device from the ground up, I already made a device tree based on Zenfone 3 (which has the same SoC) and I tried to build lineage/cyanogenmod 14.1 for it and got a lot of kernel errors, so I went to try to compile the kernel from the source ASUS gave on their website and uploaded it to my github. In this past 3 days was able to fix and workaround some of the errors I got while building, but now I'm stuck on this one: https://hastebin.com/iqisuzegeg.coffeescript | any help would be greatly apreciated .
For easier access to the kernel source I uploaded it to my github and made some fixes/workarounds for some errors: https://github.com/2003Frost/android_kernel_asus_Z01M_stock
I'm using Linaro 7.5.0 as arm64 toolchain.
I'm using Zorin OS 15.2 as OS.
If any more information is needed I'll be glad to give out.
0
Seppppx said:
Hmm. There is probably no definition for 'drivers/platform' and 'drivers/platform/msm' . But there is a reference (probably). Also have you tried to build the kernel with the defconfig "the manual way". If there is something wrong with the kernel I have almost no way of helping you because I'm not a real developer.
EDIT : There is a kernel source for your phone that on a developer's github https://github.com/shakalaca/android_kernel_asus_zd552kl . That is also the person who is the maintainer for official twrp. He has some large commits on the kernel so his kernel should build.
Click to expand...
Click to collapse
I already tried his kernel and got the same exact error :/
I didn't understand fully what you said with "the manual way" but I'm trying to compile the kernel outside the rom build environment, by using my device's defconfig and compiling with linaro.
0
Seppppx said:
By the manual way I mean the with the defconfig. Also I made a pull request to your Device Tree (adds persist partition and Shakalaca's kernel).
Also if you're trying to build with defconfig there is a tutorial by google. https://source.android.com/setup/build/building-kernels-deprecated .
After that you will have to put it to the boot image. Another guide for that. https://source.android.com/setup/build/building-kernels#embedding-into-Android .
Edit : Isn't the Android kernel build with the defconfig when you run a source build? I think it actually builds the kernel when you build android so you don't build the kernel separately.
Click to expand...
Click to collapse
I accepted your pull request. Yes when you build a rom from source it also compiles the kernel, but I wasn't able to build the rom because it gave me kernel errors, so I went and started compiling separately because it's easier to fix kernel errors like this.
I am not using Google's tutorial, I'm following one that has almost the same steps and I'm using the same toolchain.
0
Seppppx said:
By toolchain you mean tools that you need to compile a kernel? Why doesn't one just install the tools needed to compile a kernel source.
The guide I linked doesn't specify any toolchain (thus idk if I need one). It also doesn't have anything to do with build.sh script used to compile a kernel. Instead it uses the defconfig. The commands are actually very simple.
cd kernel-source_code
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-android-
make ZD552KL-Phoenix_defconfig
make
Also have you tried to build another kernel that you are sure builds? If another kernel builds. The issues have to do something with the kernel itself. If it does not it's most likely something else.
Click to expand...
Click to collapse
To compile a kernel from source you need something a cross compiler or toolchain in my case I'm actually using the exact same commands you commented with linaro toolchain/cross compiler (aarch64-linux-android). As far as I know you need that to compile a kernel and I don't think the toolchain is the problem but the kernel itself. I can try another kernel later to see if it compiles.
0
Seppppx said:
Okay thanks!
If you manage to compile the kernel for your device make sure to mention/quote me. I would like to contribute. I'm on my way to make another pull request (now about cameras).
Click to expand...
Click to collapse
If you want to talk to me more quickly you can message me on telegram https://t.me/Frost_2003
0

Categories

Resources