X compact stock kernel compilation - Sony Xperia X Compact Questions & Answers

Hi all,
I like to try tweaking and hacking my phone. I've tried some ROMs on my kugo for some time, but I figured I wanted to make my own personalized build. Right now, I'd like to use the 'Night Light' app from F-Droid, which requires KCAL support. In order to enable KCAL I'd need to edit the stock kernel (I know this can be done, it was the case for Genesis Kernel on Nougat).
Hence I'd want to learn to compile a kernel, but I can't get to the end of Sony's tutorial. I've downloaded the kernel source but I am totally lost with defconfig files. How should I configure the kernel ? There is no obvious choice for a defconfig, and I can't get past point #6 in the tutorial..
Given that I've just discovered kernel compilation today, would someone be kind and take some time to maybe point me to useful doc, give me a clue as to what my next step could be, or teach me how they compile kernels for their device ?
Many thanks for any help,
Cheers
TLDR. How to compile a kernel? I have Sony's source for kugo, but don't understand how to configure the kernel compilation.

Related

Kernels

Hello
Can anyone point me to a guide or summary of alternative kernels please?
You can check our work on the nook color linux kernels in this thread here. http://forum.xda-developers.com/showthread.php?t=1370873&page=285
I also have a guide on using the Git and the Gerrit code review down in cyanogenMod central for the nook color linux tree at this thread link here. http://forum.cyanogenmod.com/topic/50994-follow-along-with-me-trying-to-learn-how-to-code/
If you want to help and have experience on building linux kernels feel free to post a follow up in the first link I have posted. We are using the git and the github to commit code for our linux kernel tree. If you need help on getting up and going on using git, look through the second link I gave, I have all of the links on the github for our project and other helpful tips for you to get started. Right now the top developers are committing code to the jellybean branches. <fat tire> is our top developer and github maintainer for the nook color linux kernel tree, you can find him in the first link I provided and can help you also.
Thanks. I'm able to put a kernel together, but i haven't much experience in original development. I'll keep an eye on that thread though!
Right now we are looking for a few debuggers for the Jelly Bean Kernels. You know how to use debuggers? We need to check for kernel opps that are not being caught by the machines. Last year here there was a developer that rooted 2 kernel opps out and submitted them to Gerrit as a patch. Henk Poley , the developer for the Git extentions used his app and rooted out a few kernel opps on the cyanogenMod stable 7.1 at the time. Check out the my link on debuggers if you are not sure how. Not glamous work but it needs done, and I am getting up and ready to go back to school. Might do that if you want to help.
<Eyeballer> here is looking for someone to strip out all the unnecessary phone .apks for the nook color cyanogenMod builds, like the phone.apk and the telephony.apk along with the voicedialer.apk. I was going to get started on doing that but got sidetracked on getting a proper workflow going on the github. That second thread has links on how to submit work and patches down at cyanogenMod.
~~~~~~~~~~~~~~~
If you are up to a more difficult challenge the wi-fi module needs more work on the Jelly bean builds, they are still getting wake lock problems with it. A few months ago the developers disassembled and reassembled the wi fi module and could not find any code conflicts within the driver or the module. They can fill you in on that up in IRC at #nook color if you want to follow up on that.
Wow. Uh, I don't actually use a debugger, I'm pretty new to building kernels. I used to program C++ in Visual Studio, but so far haven't investigated the debugging process. In my own kernels I use printk, and that's about as sophisticated as it gets.
I wish I could help, but I need the device to available at the moment for my young daughter. Good luck with JB. I'll consider helping if my situation changes.

[DEV][TEMPLATE] Kerneller - Modify Ramdisk, dt, zImage, and SELinux on the fly

༼ つ ◕_◕ ༽つIn the name of our great lord Helix!༼ つ ◕_◕ ༽つ
Kerneller, a flashable Zip template for ramdisk modifications
Google what a kerneller is​
Many of you have no doubt heard of osm0sis' Anykernel2 and previously koush's Anykernel. Kerneller is an alternative designed solely around Sony's Xperia lineup, taking into account the 'recovery-inside-ramdisk' situation we've found ourselves in. However, the script should also support other devices such as Nexus. (I say should because I can only test on the Xperia devices I own -- if anyone could help test, I would be very grateful!)
And with the release of Android 5.0 Lollipop, users have been facing a dilemma: To download a permissive or enforcing version of the kernel? Kerneller fixes that issue by combining the two in a single zip using a slightly modified version of keycheck, allowing the user to choose what will be installed at the time of flashing.
Source: https://github.com/someone755/kerneller
Any questions, tips, or comments are welcome!
Credits & Thanks: All authors of the included binaries. osm0sis for AnyKernel2 and porting the binaries. koush for the original AnyKernel concept. Everyone who helped test. Myself5 for the inspiration and oshmoun for the help.
XDA:DevDB Information
Kerneller, Tool/Utility for the OEM Cross Device Development
Contributors
someone755
Version Information
Status: Stable
Created 2015-12-26
Last Updated 2015-12-31
This is something, i was expecting.
Thank you very much.
Black_Eyes said:
This is something, i was expecting.
Thank you very much.
Click to expand...
Click to collapse
I'm glad you like it but I can't say that's the reaction I was expecting lol. Please do let me know if anything bothers you though.
Just by the way, I moved the thing into its own repo and added a small script to compress and sign it. Cheers!
work for lock or un lock?thank you
xsj said:
work for lock or un lock?thank you
Click to expand...
Click to collapse
I'm sorry to say I don't understand the question. This script cannot lock or unlock anything.
It modifies the boot sector of your device. For that to be possible in the first place, you need an unlocked bootloader.
thank you,Im lockbootloader now,and that's what I want to know
Sorry for noob question,but where to download?Cant find the link.Want to try this on my m2 aqua.
mariosenta said:
Sorry for noob question,but where to download?Cant find the link.Want to try this on my m2 aqua.
Click to expand...
Click to collapse
Your best bet would be using 'git clone', though you can also just download the whole repo as a zip file (here, if you're having trouble finding it). Note though that the packing script won't work in Windows unless you have a *nix shell emulator (such as Cygwin or win-bash)!
You can still zip the thing together yourself using 7zip or WinRAR, however it will not be a signed zip (so some recoveries -- like Cyanogen Recovery -- may refuse to flash it, but you could use the bash script to figure out what you have to do in Windows to sign your new zip).
If you do eventually get it to run, I'd be very glad if you could send me the recovery.log of the flash via PM!
TouchWiz?
This tool works on touchwiz Lollipop 5.1.1 Roms or not?
Stock kernel is Enforcing and I tried various methods to make it permissive, nothing works
Pavan l said:
This tool works on touchwiz Lollipop 5.1.1 Roms or not?
Stock kernel is Enforcing and I tried various methods to make it permissive, nothing works
Click to expand...
Click to collapse
I don't know if your device's boot image is assembled using mkbootimg (like Nexus devices). If so, you may be able to.
But you'll need to pack the device tree binary and zImage into the zip (just use unpackbootimg).
So, I'm very confused, I usually build boot.imgs right out of the AOSP source code... how could I leverage this?
HaoZeke said:
So, I'm very confused, I usually build boot.imgs right out of the AOSP source code... how could I leverage this?
Click to expand...
Click to collapse
It's not really meant for people who compile ROMs, but more for kernel devs or testers who only compile the kernel.
Instead of always having to extract the ramdisk from boot images (whenever the ramdisk changes, which we kernel people can't know and check for every single kernel, nor do we care) and then using mkbootimg (meaning you have to release one boot image for every ramdisk you need to support, i.e. if you want to support ROMs with vastly different ramdisk implementations, where mixing ramdisks would cause a bootloop).
With this, you go around the problem. Compile the kernel outside of the ROM tree (which takes a few minutes vs several hours that compiling the entire ROM can take), grab the zImage-dtb (or adjust the script to use zImage + dt.img), and package the thing together. (There are options to also include kernel modules in the zip, and scripts that will compress and sign the zip for you.)
The highlight of this project used to be being able to switch Selinux status when flashing the zip, instead of adding androidboot.selinux=permissive for each boot image, and then uploading two images. Nowadays compatibility of this switch with various devices and Android versions is questionable (I can't test personally because of how limited Xperia devices have become recently -- the 3.10 kernel does not work with enforcing selinux), but the core idea of using it to avoid having to create boot images is still alive and kicking.

[Devs] Looking for a kernel base to work with? Start here.

Hello!
I'm hoping to get custom kernel & rom development up and running quickly for the G5 community, and have created a git repository which provides a kernel source base to start with.
What I've done is taken the v10a release sources and modified them to work with build directories and multiple variants. (should they be unlocked or receive the CodeFire treatment at any time)
Here's where to start: https://github.com/jcadduono/nethunter_kernel_g5/tree/stock-6.0
If you'd like a somewhat updated kernel, the stock-6.0.y branch will be patched from Linux 3.18.y branch at kernel.org, see:
https://github.com/jcadduono/nethunter_kernel_g5/tree/stock-6.0.y
Different from the absolute stock defconfigs, I've made the following changes:
Module signature verification disabled
Unnecessary debugging flags separated into debug_defconfig (use EXTRA_DEFCONFIG=debug_defconfig to enable them)
Flags that were previous set to module (=m) have been set to =y (built-in) in case incompatibilities are unable to load stock modules
Each known variant & target is listed in build.sh comments. The default variant when building with ./build.sh is h850 with debugging disabled.
When using the Makefile, VARIANT_DEFCONFIG=variant_xxx_defconfig adds the additional settings per variant to the target defconfig. (by default stock_defconfig)
build.sh is set up to automatically build a dtb.img after creating the kernel Image.gz based on whichever variant you've built for.
You can use ./menuconfig.sh to modify the stock defconfig, or you can copy the stock_defconfig to another name such as my_defconfig and use TARGET=my ./menuconfig or TARGET=my ./build.sh
It's easier to just set the default target in build.sh/menuconfig.sh - each have their configuration options near the top of the files.
Be sure to edit the config variables in build.sh and menuconfig.sh before using. The VERSION file gets appended to the kernel version shown in `uname` when using build.sh.
The toolchain must be pointed to the correct location before it can build. Be sure to have libncurses5-dev and colordiff packages installed for menuconfig.sh.
For a toolchain, I recommend using the GCC Linaro aarch64 5.3 2016.02 release. You can use basically any aarch64 toolchain though.
Download here: https://releases.linaro.org/compone...o-5.3-2016.02-x86_64_aarch64-linux-gnu.tar.xz
You can start by forking my repository on GitHub and giving it your own name if you like. Extra interesting commits are available in the other branches that you should be able to cherry-pick without issues should you be interested in them.
Looking to test your kernel Image.gz + dtb.img?
Look no further than my LazyFlasher repository!
See here: https://github.com/jcadduono/lazyflasher/tree/kernel-flasher
Simply do:
Code:
git clone -b kernel-flasher https://github.com/jcadduono/lazyflasher.git kernel-flasher
cd kernel-flasher
cp /path/to/Image.gz /path/to/dtb.img ./
make
(simply place your kernel Image.gz (optional) and dtb.img (optional) in the root of the repository and type make!)
And you'll have your own dynamic kernel flashing zip for custom recoveries!
The kernel-flasher repository is capable of great things. You can create scripts in patch.d to do anything you like.
Add files to the ramdisk-patch folder and create a script that copies them into the $ramdisk folder and they will be rebuilt into the ramdisk!
By default, no-verity-opt-encrypt is there as an example.
Using setprop in patch.d scripts allows you to set props in default.prop with ease.
Add functions to patch.d-env to make them globally usable across patch.d scripts.
See other branches for more examples, like how to add f2fs lines to the fstab, or patch for system mode SuperSU.
LazyFlasher is the installer used in the Kali NetHunter project. You can also find more examples in the kali-nethunter GitHub!
Good luck, and happy kernel developing!
Thanks so much for posting this.
Code:
./obligatoryn00bstatement
Sorry for not being too knowledgeable here (yet?) and if this sort of comment doesn't belong.
I am a Computer Science major who really wants to learn some skills to hopefully give back to the community.
Is this an area that I could be of use or should I perhaps spend more time going through material on the XDA-U site?
toefurkey said:
Thanks so much for posting this.
Code:
./obligatoryn00bstatement
Sorry for not being too knowledgeable here (yet?) and if this sort of comment doesn't belong.
I am a Computer Science major who really wants to learn some skills to hopefully give back to the community.
Is this an area that I could be of use or should I perhaps spend more time going through material on the XDA-U site?
Click to expand...
Click to collapse
I'm a little tired and somewhat intoxicated here at 3:45 AM so this is going to be a bit of rambling and so on...
While it's certainly a good idea to study up on what interests you before digging into it, sometimes it really can be easier just to dive in to your hobby.
I'm a high school drop out, never made it through college. Everything I've learned is by taking the great work done by the open source community and reading their code and applying it to other projects. That's the great thing about open source and nonrestrictive licenses. Everything is there for you to figure out, make changes, borrow code, run into problems, and the best part - search for solutions that others have already provided in their struggle to do exactly what you're doing.
Have an idea for a great feature? You can probably find it already implemented in another kernel somewhere.
Find the work someone else has done and modify it to fit your needs, but don't forget to give them credit for their work that you've used!
If you're going to start writing your own code, be certain to keep it tidy and variables/functions with meaningful names and comments so that not only others can understand and learn from it, but that you can return to the same code later on and understand it. Confusing code is how bugs tend to show up and become almost impossible to squash.
What I'm trying to get across here is don't be afraid to not be original. Don't be afraid to use others work to accomplish what you want, so long as they receive some attribution. The quickest way to learn how things work is by understanding what's already there and available to you.
You'll notice that there's projects all over XDA with special features ported from one device to another. Isn't it great having the all the best features people have added to other devices on one really nice device that you have?
PS I've never been on the XDA-U site before, so I can't give an opinion there.
I forgot what I was on about so I'll end this here lol.
?jcadduono you're on fire man thank you for everything you've been doing so far with such little resources.
Sent from my LG-H820 using XDA-Developers mobile app
jcadduono, thanks for the info and wonderful words of wisdom!
I totally agree on what you're saying and my goal is to try diving into this as a hobby. The hardest part for me isn't so much the coding part, but just figuring out a starting point to get grounded and build upon and I feel like what you've provided here is perhaps the starting point I need. Now it's just up to me to push myself in my free time.
Hi, i am new to kernel developing, but i did some roms myself before, so no total linux noob.
I cloned your 6.0.y and want to start from there, but im a little bit lost. Do i need to follow the steps @ github, or is your branch kinda pre setup ?
Toolchain path is also set to the one you gave a link too.
Pinu'u said:
Hi, i am new to kernel developing, but i did some roms myself before, so no total linux noob.
I cloned your 6.0.y and want to start from there, but im a little bit lost. Do i need to follow the steps @ github, or is your branch kinda pre setup ?
Toolchain path is also set to the one you gave a link too.
Click to expand...
Click to collapse
Hopefully once the toolchain path is set you should only need to run ./build.sh to actually build the kernel and dtb.
You may be missing some items for menuconfig.sh, which should just be solved by apt-get install colordiff libncurses5-dev
If building inside a ROM tree, it should be fairly simple for developers to adjust their ROM configs to add more to the kernel make command line, such as VARIANT_DEFCONFIG.
No matter what i do, kernel builds, but no dtb.img will be created. Any ideas where to look / what to test ?
I have stock-6.0.y, and did the h850 one.
Hi, is the stock-6.0.y branch removed?
I didnt find it. and need the right defconfig
greetz
mericon

Custom kernel build (help needed)

I am trying to build a custom kernel for my redmi 2 running on Nexus Experience. I found there kernel source at their github page in nx_kernel_xiaomi_msm8916 . It's the only kernel referring to XIAOMI so I think it is the right one.
I am really new to kernel building. I read some tutorials on the web and tried building one for the stock miui rom but it didn't work out.
So before I start re-building the kernel for Nexus Experience I had some questions. I wanted to add the support for external wifi adapters based on RTL8188CUS. I found the option to enable it. My question is that , By just enabling that feature will my phone just start supporting the adapter out of the box or do I have to add some Modules to it.
And the last question, After I compile the kernel I get this zImage file. I put this file in the anyKernel.zip but I found that I also have to add the wlan.ko file and I couldn't find it....
I really need some help here.

Wireguard module for stock OOS 9.0.14/15?

Hello,
Can anyone suggest a reasonable method to get wireguard support into the stock OOS kernel? I had hoped I could extract the .ko file from a compatible custom rom (9.0.15's kernel is the same as 9.0.14's), but it seems everything is statically linked (I've done kernel work but not on android before).
I also looked into compiling OOS myself with just the wg tweak but got lost in gcc/clang/cross-compilation and gave up after a while. If there's some build automation someone could recommend I steal from that would be really helpful also.
Appreciate any tips!
teslacuted said:
Hello,
Can anyone suggest a reasonable method to get wireguard support into the stock OOS kernel? I had hoped I could extract the .ko file from a compatible custom rom (9.0.15's kernel is the same as 9.0.14's), but it seems everything is statically linked (I've done kernel work but not on android before).
I also looked into compiling OOS myself with just the wg tweak but got lost in gcc/clang/cross-compilation and gave up after a while. If there's some build automation someone could recommend I steal from that would be really helpful also.
Appreciate any tips!
Click to expand...
Click to collapse
If you are rooted, look around there are a couple of custom kernels with wiregaurd support

Categories

Resources