I'm keenly waiting for the mtk release, i have a mtk6582 and really need a custom kernel
I feel happy to see these guides until now! There are books available on Embedded Android. Its better to look at them for more options and completion than half cooked information.1. INTRODUCTION:
This is a guide to build your own custom kernel. Although I'm still a "noob" at this,
I've struggled a lot to build one as all the guides which I followed were not very clear.
So I hope this will be clear enough and as noob friendly as possible!
You will learn how to:
- Build a kernel for arm devices (mediatek support soon thanks @kirito9 and maybe arm64)
- Add feature
- Basic use of git
At least don't quote the whole OP...:silly:I feel happy to see these guides until now! There are books available on Embedded Android. Its better to look at them for more options and completion than half cooked information.
Fixed build error
ALSA: pcm : Call kill_fasync() in stream lock
Currently kill_fasync() is called outside the stream lock in
snd_pcm_period_elapsed(). This is potentially racy, since the stream
may get released even during the irq handler is running. Although
snd_pcm_release_substream() calls snd_pcm_drop(), this doesn't
guarantee that the irq handler finishes, thus the kill_fasync() call
outside the stream spin lock may be invoked after the substream is
detached, as recently reported by KASAN.
As a quick workaround, move kill_fasync() call inside the stream
lock. The fasync is rarely used interface, so this shouldn't have a
big impact from the performance POV.
Ideally, we should implement some sync mechanism for the proper finish
of stream and irq handler. But this oneliner should suffice for most
cases, so far.
Change-Id: I5dbc5260abe527261b4b8c4699400b317af8451e
Reported-by: Baozeng Ding <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
- from build.sh explanation1. INTRODUCTION:Quote:
- #!/bin/bash: In the script all lines starting with # are description (so nothing of importance here)
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
Yap @F4uzan have mentionned this, will correct and explain thisI would appreciate it a ton if you could show us how to download and use a different toolchain (especially linaro) to compile the kernel. You did amazing work on this guide!
Super nice tips ! I'll add it and credits you for thisThanks for the awesome guide. I really wish to see a similar guide before few month so that I was able to save a lot of time.
Btw, few more tips for adding kernel name from my side...
1. Add the name after "EXTRAVERSION" (e.g: EXTRAVERSION = -XenomTW-3.2.6) in the 'Makefile' (line 4) which will be found in the root folder..
2. Edit the last two sections ("const char linux_banner[] =" and "const char linux_proc_banner[] =") of 'init/version.c".
e.g. Change this to
some thing like this
It's coming stay tunedI'm keenly waiting for the mtk release, i have a mtk6582 and really need a custom kernel
Thanks for the pointing out this will correct thatCorrection?
#!/bin/sh is called shebang line.
It is meant to all command is running in a shell command, not python, or either else.
Nice thread btw![]()
Hmm I'll try if I can't make videoscan you add some screenshots, please?
I sent you a PM Huge thanks for all these precisionMind if I tune in a bit and have some suggestions up and running?
- A good system specifications isn't really needed for kernel building. The only requirements that I felt is actually required are 64 bit CPU / processor and accompanied by 64 bit Linux (or heck, macOS) distribution, plus a working build tools (gcc, make, etc)
- Cross-compiler / toolchain matters a lot, please add a notice that not every single device kernel will boot (or even compiles) with older or newer GCC
- You don't have to strictly do a make clean and mrproper every time you restart a build, or you're rebuilding the kernel. It's recommended to do, but not a strict requirement.
- It'll be great if there's a notice that the dash (" - ") on the end of the CROSS_COMPILER path and variable is VERY important, if there's no dash, the compiler simply won't work
- Job parameter (-j) can be reduced, it doesn't necessarily means that if you have 4 cores, it has to be 5. Anything less is accepted (and is great for debugging), and more than 5 is also okay (but is severely not recommended)
- The minimum space for a kernel source (and its compiled code) is about 2 GB
- Not all kernel builds zImage, sometimes it builds only Image (not zImage), and sometimes other forms of compressed image
This is not all, but some that I can think of. I appreciate the effort into making the tutorial, however, and this is not a sore criticism but rather a suggestion to improve the tutorial
Ps. I can write more for ARM64 if you're interested
I'll look deeper when I'll have timeI've been learning how to build and modify kernels from source too, the steps here are very similar to what is used in XDA University
I wanna contribute something to your guide too, specifically on pushing commits. Every once in a while I see a commit that goes:
compared toCode:Fixed build error
A proper documentation will go a long way for both new and experienced devs, since Github is in Google's search results. That's how all of the build errors I found are solved, since my device has no devs.Code:ALSA: pcm : Call kill_fasync() in stream lock Currently kill_fasync() is called outside the stream lock in snd_pcm_period_elapsed(). This is potentially racy, since the stream may get released even during the irq handler is running. Although snd_pcm_release_substream() calls snd_pcm_drop(), this doesn't guarantee that the irq handler finishes, thus the kill_fasync() call outside the stream spin lock may be invoked after the substream is detached, as recently reported by KASAN. As a quick workaround, move kill_fasync() call inside the stream lock. The fasync is rarely used interface, so this shouldn't have a big impact from the performance POV. Ideally, we should implement some sync mechanism for the proper finish of stream and irq handler. But this oneliner should suffice for most cases, so far. Change-Id: I5dbc5260abe527261b4b8c4699400b317af8451e Reported-by: Baozeng Ding <[email protected]> Signed-off-by: Takashi Iwai <[email protected]>
Also, cherry-picking commits are the fastest way to implement features into your kernel. The code will be merged automagically and will inform you if there are conflicts.
Yap someone pointed out this earlier, BTW thanks for pointing out thisGreat thread! Really neat and descriptive!
A small note.
- from build.sh explanation
The #!/bin/bash is a convention so the *nix shell knows what kind of interpreter to run. Not just description/comment
No worries.Oh lol thanks![]()
Will correct that in op
I would suggest you to go with your default compiler. You'll have to check the .txt files in your kernel source where you can see the default toolchain to be used. Other, newer or older toolchains will usually not compile the kernel nd throw errors which you'll have to fix nd it's a long work.I would appreciate it a ton if you could show us how to download and use a different toolchain (especially linaro) to compile the kernel. You did amazing work on this guide!
True that!Thanks for the awesome guide. I really wish to see a similar guide before few month so that I was able to save a lot of time.
Btw, few more tips for adding kernel name from my side...
1. Add the name after "EXTRAVERSION" (e.g: EXTRAVERSION = -XenomTW-3.2.6) in the 'Makefile' (line 4) which will be found in the root folder..
2. Edit the last two sections ("const char linux_banner[] =" and "const char linux_proc_banner[] =") of 'init/version.c".
e.g. Change this to
some thing like this
No. What you can do is. Get a server nd then you can use the command line from your Android device to clone nd build kernels.Love the tutorial its simple for my noon brain to understand and I want to try this but don't have a pc, and I don't really want to make and publish kernels, I just want to use a published kernel and edit it for my own use, any advice anyone, is there a linux rom out there or some sort of app that let's me unpack boot .img files and edit them? Yeah I know the risk and I do understand custom kernels and I have been doing this since 2012.
Hey thank you so much for the tip! Any idea what the name of this text file would be? The kernel that i am trying to compile is here https://github.com/Team-M8/android_kernel_htc_msm8974 if you need the source to know this.I would suggest you to go with your default compiler. You'll have to check the .txt files in your kernel source where you can see the default toolchain to be used. Other, newer or older toolchains will usually not compile the kernel nd throw errors which you'll have to fix nd it's a long work.
In this kernel source there isn't text file that show you the toolchain to useHey thank you so much for the tip! Any idea what the name of this text file would be? The kernel that i am trying to compile is here https://github.com/Team-M8/android_kernel_htc_msm8974 if you need the source to know this.
i am currently using google's gcc 4.9 from https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.9 and it works fine. i had tried using a couple of linaro toolchain versions but the compilation failed halfway with one (4.9.4) and it didnt seem to start at all with the 5.2 version (i probably didnt set it up correctly). I wanted to know which one would be supported by this kernel. I havent tried the toolchain on your github though, i will when i have more time since i am a nub at this stuff. (btw more development in m8's aosp dev scene is always appreciated wink wink)In this kernel source there isn't text file that show you the toolchain to use
Try with 4.8 or 4.9 GCC
(I'm also a m8 user although i didn't tried to build a kernel yet for this device )
Envoyé de mon m8 en utilisant Tapatalk
I would love some more info on compiling a kernel with target or maybe if you know a decent place for me to start you could link it up. I have been looking for a solid guide for this for close to a year. I have termux, gnuroot, cctools, and c4droid installed with all the plugins but could never figured them out. I always have my phone with me but never my computer so it would be very convenient. I have a Tmobile note 4 and from what I have gathered it's powerful enough for the task. BTW....this is a great guide....probably the easiest to understand of any and I have read them all. ThanksNo worries.Also, you can add pwd to be used in toolchain's directory so the users can get the path of toolchain easily. Pwd outputs current path or directory you're working in.
I would suggest you to go with your default compiler. You'll have to check the .txt files in your kernel source where you can see the default toolchain to be used. Other, newer or older toolchains will usually not compile the kernel nd throw errors which you'll have to fix nd it's a long work.
True that!
Btw, for newbies it'll be hard to follow the syntax accurately nd it might cause errors if they misplace something.
I would rather suggest to go with mkcompile_h for Linux nd Host.
For Extraversion its fine nd easy so new peeps would be able to follow!
No. What you can do is. Get a server nd then you can use the command line from your Android device to clone nd build kernels.
For the moment only armThis tutorial is only for arm ? No arm64 ?