Android kernel how to make compatible with higher os? (+Where can I find the patch?) - Android Q&A, Help & Troubleshooting

Hello, I'm newbie dev trying to build CM13 for Lenovo Phab plus.
I think I'm almost finished with device and vendor, but I cannot figure it out what to do with kernel.
The circumstance is,
I have a stock kernel source which runs in 5.1.1 LP, with version of 3.10.49.
What I want is to make kernel compatible with 6.0.1.
I already know that linux kernel version doesn't have to be exactly same with new Android OS versions and I can just make a few patches in order to run kernel in higher OS.
So I googled and studied(?) for 2-3weeks, but got not many useful informations and I still cannot figure out where to find required patches for 6.0.1 .
So here's what I am not sure about.
1. I found that I can either upstream, merge, cherry-pick kernel sources from higher OS. For instance, if I merge kernel patches (starting from 3.10.50 to 3.18 step by step) and check if the kernel compiles successfully, is this a right thing to do? I am confused whether merging or cherry-picking is required for my situation.
2. I see lots of commits when comparing with other kernel sources in github. How do you find those kinds of patches? -> just keep compiling kernel and if error comes out->search->commit
Always this pattern goes again and again till boot properly?
3. i'm quite curious with backports. What i know is that "backports" are the files which is compatible for lower version kernels. For example, backported audio driver originally based on 4.9 can be used in kernels with version below 4.9. Is it right?
4. If there is an useful links, anything could be helped a lot.
THANKS IN ADVANCE.

Related

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).

[Kernel] Starship Kernel 06/29/2015 (Stock/AOSP_5.1.1|CM-12.1|)

Starship Kernel is being developed in conjunction with the not yet posted Starship Rom. Like I had done with the KK incarnation of the Starship Rom I am also posting the Kernel separately for anyone who may not like the Rom's Theme. Though unlikely as that may sound because I have spent much time and effort with the Kernel am posting the Kernel separately so it can be used with other Roms and not just Starship.
If you are looking for new features to play with this will not be the Kernel for you. It is designed to improve the overall experience as if it was not there. At this point and probably never you wont find over clocking or voltage controls to play with but rather just a more efficient overall experience.
Each Kernel Download section contains a link to the commit list for both the purpose of following rules about posting links to Kernel Sources as well as serving as a change log. You will find in the main branch all Linux Kernel Increment Updates are grouped into one commit. This is to easily distinguish what commits have been made as part of the Linux Kernel Increment Updates from other additions/optimizations that are not part of the Linux Version Updates. You can find descriptions of each change made as part of the Increment Updates in the staging branch. In other words the second link below the download links will give a description off the changes made in the Linux Version Updates .
Downloads
AOSP/Stock (Android Version 5.1.1)
AOSP/Stock Kernel is compiles using Google's GCC 4.8 toolchain and tested tested on the Stock 5.1.1 Rom as well as AOSP compiled Rom using unmodified pure 5.1.1 Source code. The Kernel may or may not work on custom Roms based on 5.1.1 depending on what changes have been made by the Roms developer and how far the Rom has strayed from the original source code. In most cases if the Rom is AOSP based the Kernel will work but provide no guarantee as am not testing with every ROM available. If you do find a Rom the Kernel does not work with feel free to comment but please include what Kernel was used that did not work as I may be able to shed light on reasons why and provide a workaround if possible. Most of incompatibility will find that the Kernel is not the issue rather what is included inside the boot.img like Ramdisk iinit.rc files that set permissions and create the Rom file-system.
Starship-lollipop-5.1_Kernel-3.4.91_r1
https://www.androidfilehost.com/?fid=24052804347767806
Starship-lollipop-5.1_Kernel-3.4.88_r1
https://www.androidfilehost.com/?fid=24052804347766347
Starship-lollipop-5.1_Kernel-3.4.86_r1
https://www.androidfilehost.com/?fid=24052804347760505
Starship-lollipop-5.1_Kernel-3.4.83_r1
https://www.androidfilehost.com/?fid=24052804347756685
Source / Change-log
https://github.com/Starship-Android/android_kernel_lge_hammerhead-starship/commits/lollipop
Including individual explanation of changes included as part of Linux version increment update patches.
https://github.com/Starship-Android/android_kernel_lge_hammerhead-starship/commits/lollipop_staging
CM-12.1
CM-12.1 Kernels may be updated more frequently without posting a new date so don’t be surprised to see multiple release number increments. In most cases there has been no change in the Kernel itself but update frequently as development is fast moving. Because of this some of the files that get packaged into the boot.img along with the Kernel may change and cause issues. Because of this will update as frequently as I can to insure everything packaged into the boot.img is up to date.
Starship-CM-12.1_Kernel-3.4.88_r1
https://www.androidfilehost.com/?fid=24052804347766796
Starship-CM-12.1_Kernel-3.4.86_r1
https://www.androidfilehost.com/?fid=24052804347760507
Starship-CM-12.1_Kernel-3.4.80_r1
https://www.androidfilehost.com/?fid=23991606952613802
Source / Change-log
https://github.com/Starship-Android/android_kernel_lge_hammerhead-starship/commits/cm-12.1_staging
Donations
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MMEVCWUX83SXJ
I am not responsible for any effect using the downloads from this forum my have on any device and you download and use at your own risk.
Just decided to include the CM-11 Kernel for anyone who may be using CM-11. Is a nice Kernel and gave me an extra hour or two battery so recompiling with a few new commits I have been using in both CM-12 & AOSP. Will post in a few. Checking nothing else may have changed on the CM side with the rest of the boot.img and will post in a bit.
I will try out the AOSP kernel tonight or tomorrow, we are under blizzard conditions right now and can't mess with phone because of work (boss & I texting back and fourth)
Thanks for your work
Sent from my rooted RCT6203W46 using xda-dev app
Downloading now!
Sent from my Nexus 5 using XDA Free mobile app
rickballs said:
Downloading now!
Sent from my Nexus 5 using XDA Free mobile app
Click to expand...
Click to collapse
Sorry about this then but have uploaded an update. I had intended on holding off until reaching Linux version 3.4.40 as it is the version I had left off with for Kit-Kat and have just been modifying each version increment patch from the Kit-Kat 3.4 Kernel for Lollipop. Anyhow last night before bed had used my Bluetooth Headset with the current version and sounded like I had gone out and bought a brand new higher end set so decided to post the update now. Found in the past Android can have a completely different experience when it comes to different BT devices like for example the same headset had become completely unusable on my N7 with constant skips and pauses on 4.4.4 after working beautifully on 4.4.3 so hope others can hear the same boost in overall audio quality including BT headsets.
Updated Kernels with a few new optimizations and 3.4.36 version update
Ok will try it
Can't download from devhost. Anyone else is having problema?
gengi said:
Can't download from devhost. Anyone else is having problema?
Click to expand...
Click to collapse
Looks to be up and running. Can try direct links though.
updated so links are no longer current.
Well it feels like with all the side track projects been talking Starship L long enogh maybe some of those who have sent PM's asking about the lollipop update are starting to become doubters so decided to post up a few screen shots. Was going to finish a few things then go over the theme image by image and color by color but think instead after finishing up a few things will post and then start going over each apk over again for touching up, fixing and adding missed optimizations including Kernel updating along the way. Once again not for everyone so haters can hate and I just keep doing it because its what I like doing.
Made new boot.img for Stock / AOSP 5.1.0 as old image used in 5.0 - 5.0.2 caused boot loops.
The MultiROM not work with this kernel? :-O
dado70 said:
The MultiROM not work with this kernel? :-O
Click to expand...
Click to collapse
Honestly have been meaning but have not tried MultiROM. Looked over at the thread and see allot of mention about the boot.img and modifications. If I had to guess with the limited knowledge I have would say if not working is not so much the Kernel but the boot.img in the same way that both the Stock / AOSP zips posted are the same exact Kernel inside but changes made to files like the init.rc inside the 5.1.0 boot.img that creates the file system and sets permissions among a score of other things caused 5.1.0 from booting properly after updating and flashing the boot.img. As developers we use the name Kernel but there is much more inside than the actual Kernel. In some cases can be more than a dozen other scripts and other files inside. Will need to try and learn a bit about MultiROM. Out of curiosity was it Stock or CM giving you issues?
Little more reading and looks like not everyone including CM has updated to include new bootloader version checks to include new bootloader from the 5..1.0 update. So for example I needed to change the bootloader version in CM source or nightly builds will not flash in TWRP without errors.
Maybe an update on this if flashing CM version, seems latest CM12 is receiving errors flashing with some recovery versions and must be installed via adb / fastboot. Article was not specific on the reason but may be the cause.
Added updates to version 3.4.42 for both 5.1.0 and under. The 5.0.2 zip should work for all stock and AOSP Roms from 5.0 - 5.0.2. Because of changes in 5.1.0 boot.img 5.1.0 will not boot when used with a lower Android Version.
Slightly disappointed as today had planned on posting full Starship Rom but now updating for 5.1.0 so maybe another week maybe two
So any details on what this kernel does? Or is our just close to stock?
CM12 Kernel is on hold until 5.1.0 version update. No reason testing anything new until can confirm everything will still work next week. Also figures the same week I had planned on posting the full Starship Rom the 5.1.0 update hit so now am back in testing optimizing phase for a bit longer.
3.30.2015 update
Linux version has been updated to version 3.4.55
All MR1 changes added to the 5.1.0 AOSP Kernel have been merged into the Kernel
https://github.com/Starship-Android...mmit/8ed8c47ff15f1c5fdd6707f7a52f76110aed6cbf
4.6.2015 update
Not much on the AOSP/Stock side. Wanted to post a cm12 update so decided to post the AOSP/Stock kernel earlier than I would normally with a few Linux version update patches. With that said updating the Kernel only takes a minute or so and not like asking to flash a new Rom. Kernels are easy and these days faster to flash than g-apps. Also used the 5.1.0_r3 source to compile the boot image for 5.1 instead of 5.1.0_r1 source I had been using. Honestly though did not check if anything changed that is packed into the boot.img along with the Kernel between r1 & r3 so may or may not make any difference what so ever.
Forgot, marked the cm-12.1 kernel as beta just because cm-12.1 is pretty much beta. Otherwise the Starship 12.1 Kernel is the Starship CM12 Kernel merged with the Cyanogen 12.1 Kernel . Not that the two had been far apart to start but the 12.1 CM Kernel merged into the Starship cm12 kernel clean as a whistle with 0 conflicts. Was pretty happy about that so going foreword will just be working on the 12.1 Kernel with the Starship cm-12 Kernel soon going the way of the 5.0 - 5.0.2 Stock/AOSP Starship Kernels.
Now finally since the actual Starship Rom I have been working on since the darn preview release ending as mostly caf based with CM-12.1 coming together can start updating from 5.0.2 into 5.1 as had just finished going over the first draft and was about to post when the 5.1 update hit. Otherwise wanted to post the first draft and then go over the entire Rom a second time looking over the theme images, features and optimizations with a magnifying glass.
Have updated both Stock / AOSP and cm-12.1 Kernels up to Linux 3.4.65 with a few other additions and weeding. Has and been running pretty sweet on both so far.
Stock / AOSP 3.4.65 Kernel boot.img has been compiled using the 5.1.1 AOSP Source and tested on both 5.1.0 & 5.1.1 with no issue and as mentioned above running pretty sweet.
I cant install on aicp 5.1.1
Sent from my Nexus 5 using XDA Premium HD app

[Questions] Kernel source issues when compiling LOS/TWRP

Hello guys.
This question is specially for devs or advanced users with development skills.
My question is related to the kernel source of one of my devices, Huawei Mediapad T1 10 (codename: hwt1a21l). I got the kernel source from the oficial Huawei website and uploaded it to a github repo. My device, which has a msm8916 chiset, doesn't have any development (roms, recoveries, device tree, etc) and his rom, EMUI 3.0, is based on Kit Kat 4.4.2.
I have been trying to bring development for this tablet many months ago because the stock rom is too deprecated for the hardware that has, with the msm8916 there is a huge potential to bring it a lot of development.
Well, i'm going to summarize my problems when trying to bring development for the device:
To get started development, for example a LineageOS build i needed a solid base to start with: device tree, propietary blobs and kernel source, so i got all of them. I ported the device tree from another one very similar to mine (with the same chipset), extracted the propietary blobs with the build tools from the source and got the kernel source from the Huawei website. So everything seemed to be good, but when i start the build process with my Linux machine (repo sync > source build/envsetup.sh > breakfast hwt1a21l > brunch hwt1a21l) i always receive thousands of build error by the kernel source, and i have been fixing (or at least avoid) a lot of them but it never ends, so i don't know if it's worth to keep trying to "fix" them or if i'm wasting my time.
So, what i have been trying to do: i have been trying to build a LineageOS 14.1 and TWRP recovery with my device tree This: Mustang-ssc/android_device_huawei_msm8916-common ported from this one from @dianlujitao : dianlujitao/android_device_huawei_msm8916-common and the specific kernel source for my device downloaded from the Huawei website Mustang-ssc/android_kernel_huawei_hwt1a21l. Here ends the summary.
So after a lot of hours, days and nights over the last months trying to make progress with this and not getting any help from the few devs i asked after seeing my lack of progress i decided to publicly ask for help.
The questions:
1. I have the official kernel source (Mustang-ssc/android_kernel_huawei_hwt1a21l) which i didn't have success to compile it, and then i saw the kernel source from a device almost identical to mine (same chipset, brand, ram, ...) (dianlujitao/android_kernel_huawei_msm8916). Can i use that kernel source as a base for my device after porting the specific configurations of my official kernel source (defconfig, drivers, libraries)? That one is much more updated and probably optimized than mine, but i don't know if it's possible to adapt a kernel source from other device using your kernel source.
2. This may be a dumb question: my device has Kit Kat 4.4.2. Is there any link between the kernel source and the android version the device has? I mean, i don't know if i should do something to adapt my kernel source for newer android versions (Marshmallow, Nougat) of if it's ok to just build with it without any change.
If you read it all, congratulations, you're awesome
Still waiting for a reply

What Steps Do You Take To Upgrade A Kernel?

So the phone manufacturer has provided kernel source and lets assume that it compiles and deploys fine.
What are the steps to upgrade the kernel to a newer version?
Lots of threads that I read suggest looking for another kernel that is based on a similar device and using that.
However, what happens if there is no similar device?
What steps do you take to upgrade a kernel in this case?
Would I just find the equivalent base in the android kernel source and git diff and patch each commit until I got to the version I wanted then try to fix any compile errors?
I can't seem to find a thread with the actual fine details of the kernel upgrade process.
I didn't get round to upgrading my kernel.
Does anyone have a developers guide on the steps to update your kernel source code?

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