Kernel Building Guide for the X8 - XPERIA X8 General

Part 4. A noob's Hope.
or, A noobs Kernel building guide for noobs by a noob.
Linux Gurus and Master Dev's, please feel free to point out any mistakes i make.
We've got lots of ROMs available and frankly, i think we've reached the limit of what could be done. Ofcourse, i could be wrong. we might have a special guy/girl out there who's just finishing off a port of icescream sandwich for the X8.
As it stands, instead of waiting for the latest ROM build, just choose what was best in your experience and stick to it, nothing would change much. I still use the old GX8 ;-)
But, first: let's take our hats off and and humbly give our thanks to those that have paved the way, the dev's that we've bugged (pun), cajoled, bribed (?) and outright threatened to put in into their (ROMs, Kernels,Modules etc) works what we like to have running on our X8's.
in Alphabetical order: (BTW, incase i miss anybody, pls point it out. we don't want any disrespect)
alfsamsung
AnDyx
Blagus
Dare-Devil Inside
Doixanh
DoomLoRd
FrogyFurnetal
FXP team
Master Shpit
Nobodyatall
Ponanovn
Racht
Velnens123
Well on with this simple tutorial:
What's a Kernel? (or, its KERNEL and NOT KERNAL) Simply put, it's the Software Layer in between the ROM and the Hardware. In this case it's Linux 2.6.29. The ROM "Android 'whatever'" is the interface between us users and our beloved X8.
Why 2.6.29 and not a more later kernel? since the Kernel is the go between hardware and the UI, ther drivers for the hardware are there. An analogy will be like Windows 98 drivers will not work (well, sometimes they do) on Windows7 and vice versa. Couple that idea with Google, hence Android, is branched off of the main Linux kernel. Infact, the entire Android kernel code was deleted from the main linux kernel tree.
Besides, look at the title, it's for noobs by a noob. as soon as i figure out how to go to Kernel 2.6.32 or something, i'll update.
Why build your own Kernel? because it's fun!
What you need:
1. Crash Helmet.
2. A desire to possibly brick your X8
3. A fast computer with atleast 20 GB of HD space
4. since you're a noob, you must be using a Windows OS of some sort. If it's still Win3.1 or even Win95 consider upgrading to a faster computer and a more modern OS.i use both a 3.2 Ghz Hexcore AMD with 8Gb of RAM and 2TB HD and a 3.0Ghz Intel Core2 4GB RAM and 500GB HD Both worked fine. I also used a 2.6Ghz Core2, 500GB HD 2GB RAM Laptop and that worked fine as well.
5. Linux based OS. You can have this loaded in your computer a myrad ways, but for us noobs, the easiest will be using Virtual Box (VirtualBox-4.1.6-74713-Win). And, for this tutorial, i set up virtual box with Ubuntu (ubuntu-11.10-desktop-i386). SO, go ahead and download both and install. If you don't know how to find those... you being a noob can only go so far... remember, google is your friend.
7. FXP Kernel Source. It's always a good idea to ask permission first and don't forget to say thanks. > https://github.com/freexperia/semc-kernel-msm7x27. click on the button which says zip.
8. Download this >> https://sourcery.mentor.com/sgpp/li...-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
9. and this, http://dl-www.sonyericsson.com/cws/download/1/103/126/1/1316518401/E15i_eclair_2.1.1.A.0.6.tar.gz
So, see you Saturday.

Reserved
Part 5: The code strikes back!
What are those files we downloaded:
1. FXP Kernel Source for MSM7227
2. Linux-GNU compiler
3. SE 2.1.1.A.0.6 Kernel Source.
What do we do with it?
Assuming you've got your VMBox Ubuntu running,
1. Open Home. This is like windows File Explorer.
2. Make a Folder and call it "Kernel".
3. Copy all your downloaded files into the Kernel Folder.
4. Extract those 3 files by right clicking on the archive and select "Open with Archive Manager".
5. Select "Extract" in the upper part of the Archive Manager window. Click "extract" again on the lower right of the window that appears.
are you done extracting? well, if you are then:
6. let's make our lives a bit easier: Rename the arm-2010q1-202-arn-none-linux-gnueabi-i686-pc folder into just arm-2010q1.
7-8 do the same thing with the other two.... No, not the same name as arm2919q1(noob!) but, for the FXP kernel source folder just rename it to FXP and the original SE Kernel Source folder to SeX8.
9. OK. crash helmets ready? Open up Terminal....
(hint: see that wierd symbol above the Home icon in the taskbar? click on it and in the search space type "terminal")
(hint: you can click and drag the Terminal Icon into the task bar for easier use.)
10. type this in exactly but without the double qoutes, Linux is picky about cases. "sudo apt-get install git unrar libncurses5-dev qt3-dev-tools"
remember your homework?
sudo is a command that basically says "hey, i'ma supauser, do what i tell you!" which in this case is to download and install, git, unrar, ncurse libraries and QT3. To be honest, i haven't found much use for Qmake (QT3).
You might be wondering (especially the command line experts) as to why i switch back and forth between the command line and the Home browser. Well, for us noobs, i find it easier to go with the familiar and spend as little time as possible in a super user terminal. Lot's of things can go wrong with a mis-typed command. As for now twiddle your fingers while we wait for the download and install to finish.
Done?
11. OK. since we're gonna be doing kernel stuff lets get super user access. again enter this with no qoutes: sudo /bin/bash
enter your password. don't worry it won't show those loveable asterisks. press enter. if everything's ok we'll see the command prompt again with a difference of root access ;-)
12. next. let's get to our Kernel directory by : "cd ~/Kernel/FXP" (thanks to dioxanh for the correction)
13. Heres where the fun begins:
we set up the environment by entering the following in Termial(NO QOUTES):
"export ARCH=arm"
"export CROSS_COMPILE=/home/viper001/Kernel/arm-2010q1/bin/arm-none-linux-gnueabi- "
BTW, change viper001 in the crosscompile to your user name
14. configuration definitions. this tells the compiler for what machine, what drivers to include, machine configuration etc to include into your kernel build.
so, if you want to see all the machines, for those with any machine with the MSM7227, (HEY, you with the E16) it is possible to compile a kernel for it also.
in this case, lets use the Home Folder explorer. and double-click on the following folders: Kernel >> FXP>> arch>> arm >> configs.
now we're in FXP's archive for the configuration of arm based machines. isn't it nicely logical.
of interest are two configs. fxp_shakira_defconfig and semc_shakira_defconfig. You can view them in gedit by double clicking. but please do not edit.
15. Back to the terminal. type in: "make fxp_shakira_defconfig"
did you see this after it was done? "# configuration written to .config". that means, so far so good.
16. let's see what we've got. This was the reason we downloaded ncurses. enter "make menuconfig"
Explore a bit, and see the settings, don't change any for now. once your done exit back to the terminal prompt.
17. type in: "make" and depending on your PC, it will take from 10 to 30 minutes. give or take a few hours on a pentium 1. (DIDn't i tell you to upgrade?)
18. If all went well, then in the Kernel >> FXP>> arch>> arm >> boot folder, you'll find the image and zimage files. congratulations, you've compiled your first kernel.
So, in summary once you've got all the stuff together you've got to:
sudo /bin/bash
to get superuser access
export ARCH=arm
ready your environment to compile for the arm based machione
export CROSS_COMPILE=/home/viper001/Kernel/arm-2010q1/bin/arm-none-linux-gnueabi-
ready your environment by specifying the location of your compiler
make "defconfig, menuconfig, oldconfig"
make "defconfig": where defconfig is the default configuration file of a specific machine base on the archive as specified by ARCH.
make menuconfig: give us a pseudo graphical user interface. best used after a make defconfig to do those tweaks.
make oldconfig: you don't want to know. but if your curious just enter it and take a look and waste between 15 to 30 minutes of your life.
make: the final command to get your kernel image.
Here's a few helpfull commands after a failed compile:
make clean
make mrproper

Reserved
Part 6. Return of the Kernel Builder.
You now have the Kernel Image file. so, What do you do next?
Get the IMAGE file in the aforemention folder.
In windows:
Go to Blagus thread on Kernel building. >> http://forum.xda-developers.com/showthread.php?t=1254525
download the unlocking tool if you still don't have it. Don't forget to say Thanks.
download the attached FXPramdisk.zip and extract the ramdisk file inside.
put the image and the ramdisk file into the */sinTools folder of Blagus's utility. note: there's already an existing image and ramdisk in that folder. delete those or save them in another folder.
doubleclick on example_build.cmd and you'll get a result.zip file.
extract the result.elf.sin and rename to kernel.sin. YAY
Now, this is the dirty but most convenient way to wrap things up.
1. make a copy of a working kernel.ftf file.
2. in Blagus's utily, there is a folder called loader with a file inside called loader.sin
3. open up the kernel.ftf file with your favorite archiver. i use 7zip. delete the kernel.sin and loader.sin and then drag and drop your own kernel.sin and Blagus's loader.sin in that kernel.ftf and close.
4. use the flashtool utilty to flash into the X8.
After the flash and powering on, it is always a good idea to clear cache, dalvik cache and the battery stats.
If everything went well and booted to your ROM then you've got yourself the latest build of the FXP ROM.
BUT, HOLD ON!!!!
Don't get that far away look in your eyes as you whisper to yourself "then i am a kernel builder...."
I'll try to say this in my best yoda imitation. "hmmm, hehehehe *cough* *wheeez*.... WiFi, you must compile WiFi.... only then, a Kernel Builder will you be..."
.....
"There are also.... the modules...ramdisk editing..."
See you in Part 1. The Phantom Modules.

It will be very interesting
Thank you!

is there a E16i W8 firmware?

amnher said:
is there a E16i W8 firmware?
Click to expand...
Click to collapse
Check the se developer site. You might get lucky.
EDIT: I actually checked. And there is one for the E16i. The difference between the i and a versions is cdma or GSM. It could just be a matter of using the correct definitions during compile. Let's hope that a kind guru could shed light on this.
Oops. It is an i you're asking for. So go and download this http://developer.sonyericsson.com/wportal/devworld/downloads/download/e16ieclair211a46targz?cc=gb&lc=en
Sent from my TI99 4A

updated.

Part 1. The Phantom Modules
The the early days of the X8 rooting scene. we had two ROM Devs/Porters that gave us an option of going the CM route through MiniCM or the HTC/Motorla route. Now qui-gon and obi... urmm, Racht and Ponanovn did a splendid job in porting these ROMS, especialy since it freed us from Eclair.
But the users wanted more... we wanted multi-touch, we wanted overclock, we wanted netfilters.... heck, lets just say for the price of the X8, we wanted an X10.
Out of the SE deserted android scene, Dioxahn came out with back to back modules that enabled, empowered and brought balance to our X8. (too cheesy?)
But with the advent of X8 Kernel Building, where did these module go? we have to delete the modules from our lib/modules..,.. what happened?
Well, the code they had just went to where they're supposed to be.
It's a frustration that can heard in Dioxanhs words when people asks stuff like dual/multitouch on a synaptics X8 or overvoltage and the like when we can't understand his genius.
to be clear, first and foremost, the modules he made, hijacks and takes over the code built in kernel. Ex. the Kernel might need to know what speed the cpu should be, and there is a code for that, to simplify, as it ask for this code, the OC module intercepts this request and sends its own modified code as an alternative. confused? GOOD.
Overclock:
In ubuntu, go to Kernel >> FXP >> arch >> arm >> mach-msm
double click on acpuclock.c, you will not find the following code as is, since the FXP team disabled the OC from the Kernel. but do a search of :
static void acpuclk_set_div
and you should find a code similar to the OC code that follows but without the items in bold.
DO not modify anything yet. Unless you know what you're doing.
The code below is what enables overclock and is the same instructions inserted by the OC module, it is also the same as in the Google nexus, and alfasamsungs kernel.
static void acpuclk_set_div(const struct clkctl_acpu_speed *hunt_s) {
uint32_t reg_clkctl, reg_clksel, clk_div, src_sel, a11_div;
reg_clksel = readl(A11S_CLK_SEL_ADDR);
/* AHB_CLK_DIV */
clk_div = (reg_clksel >> 1) & 0x03;
/* CLK_SEL_SRC1NO */
src_sel = reg_clksel & 1;
// Perform overclocking if requested
a11_div=hunt_s->a11clk_src_div;
if(hunt_s->a11clk_khz>600000) {
a11_div=0;
writel(hunt_s->a11clk_khz/19200, MSM_CLK_CTL_BASE+0x33C);
udelay(50);
}
src_sel = reg_clksel & 1;
/*
* If the new clock divider is higher than the previous, then
* program the divider before switching the clock
*/
if (hunt_s->ahbclk_div > clk_div) {
reg_clksel &= ~(0x3 << 1);
reg_clksel |= (hunt_s->ahbclk_div << 1);
writel(reg_clksel, A11S_CLK_SEL_ADDR);
}
Over and under voltage:
Now, this is what im busy of at the moment. i'm trying to find the best PLL clock ratio for GPU to CPU stable speeds within the constraints of the voltage. the bold numbers are the voltage identifiers. since the MSM7227 has a range of 1.2 to 1.35 V operating voltage hence the values from 1 to 7. NO OVERVOLTAGE.
BTW, the part is located in the same file acpuclock.c and is at the begining and is also required to set the maximum CPU clock. The values after the 600Mhz are the values i'm playing with since i think FXP has already "tuned" the stock speed perfectly. In alfasamsungs kernel, he didn't include the scales between 600 and 729. which is very logical. why overclock if you ain't going to max,
/* 7x27 normal with GSM capable modem - PLL0 and PLL1 swapped */
static struct clkctl_acpu_speed pll0_960_pll1_245_pll2_1200[] = {
{ 0, 19200, ACPU_PLL_TCXO, 0, 0, 19200, 0, 0, 30720 },
{ 0, 120000, ACPU_PLL_0, 4, 7, 60000, 1, 3, 61440 },
{ 1, 122880, ACPU_PLL_1, 1, 1, 61440, 1, 3, 61440 },
{ 0, 200000, ACPU_PLL_2, 2, 5, 66667, 2, 4, 61440 },
{ 1, 245760, ACPU_PLL_1, 1, 0, 122880, 1, 4, 61440 },
{ 1, 320000, ACPU_PLL_0, 4, 2, 160000, 1, 5, 160000 },
{ 0, 400000, ACPU_PLL_2, 2, 2, 133333, 2, 5, 160000 },
{ 1, 480000, ACPU_PLL_0, 4, 1, 160000, 2, 5, 160000 },
{ 1, 600000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 652800, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 691200, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 710400, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 729600, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 748800, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 768000, ACPU_PLL_2, 2, 1, 200000, 2, 7, 160000 },
{ 1, 787200, ACPU_PLL_2, 2, 2, 160000, 2, 7, 160000 },
{ 1, 806400, ACPU_PLL_2, 2, 2, 160000, 2, 7, 160000 },
// { 1, 825600, ACPU_PLL_0, 4, 0, 206400, 3, 7, 122880 },
// { 1, 844800, ACPU_PLL_0, 4, 0, 211200, 3, 7, 122880 },
// { 1, 864000, ACPU_PLL_0, 4, 0, 216000, 3, 7, 122880 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0} }
};
One of the best things about this is that you can code and configure your "overclock" in acpuclock.c, set the default minmax speed to 122/600 in the defconfig during compile gaining a stock profile and go as high (or low) as you want in the ROM through the CM settings, SetCPU etc. You don't even have to "enable" overclock in the CMsettings.
At any rate, take a break and think about what our devs are doing before you noob them out. ok?
As a guide, i've included my acpuclock.c for your review and comparison to the original se Kernel.
Next. we'll tackle part 2. Touch Screen Wars.
or, they're on the same machine, they look the same... but, (gasps) they're not!!!

Part 2. Touchscreen Wars.
One of the silliest things you'll see on the X8 is the inconsistency in Hardware. We don't know whether it's for cost or different paces of manufacture or maybe parts availability. We even have 4 types of essentially the same machines the E15i and the cdma version E15a. then lately we have the W8 or E16i and E16a. to further compound the issue we even have different touchscreen controllers. And this is what we're gonna look at today.
So, you had fun compiling, played around with the defconfig yet?
well, if not let's take a look at one particular section:
# Input Device Drivers
#
# CONFIG_INPUT_KEYBOARD is not set
# CONFIG_INPUT_MOUSE is not set
# CONFIG_INPUT_JOYSTICK is not set
# CONFIG_INPUT_TABLET is not set
CONFIG_INPUT_TOUCHSCREEN=y
# CONFIG_TOUCHSCREEN_FUJITSU is not set
# CONFIG_TOUCHSCREEN_GUNZE is not set
# CONFIG_TOUCHSCREEN_ELAN_I2C_8232 is not set
# CONFIG_TOUCHSCREEN_ELO is not set
# CONFIG_TOUCHSCREEN_WACOM_W8001 is not set
# CONFIG_TOUCHSCREEN_MTOUCH is not set
# CONFIG_TOUCHSCREEN_INEXIO is not set
# CONFIG_TOUCHSCREEN_MK712 is not set
# CONFIG_TOUCHSCREEN_PENMOUNT is not set
CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI=y
CONFIG_TOUCHSCREEN_SYNAPTICS_I2C_RMI_4X=y
# CONFIG_TOUCHSCREEN_TOUCHRIGHT is not set
# CONFIG_TOUCHSCREEN_TOUCHWIN is not set
# CONFIG_TOUCHSCREEN_USB_COMPOSITE is not set
# CONFIG_TOUCHSCREEN_TOUCHIT213 is not set
# CONFIG_TOUCHSCREEN_TSC2007 is not set
# CONFIG_TOUCHSCREEN_MSM_LEGACY is not set
# CONFIG_TOUCHSCREEN_CY8CTMA300 is not set
# CONFIG_TOUCHSCREEN_CY8CTMA300_SER is not set
CONFIG_TOUCHSCREEN_CYTTSP_I2C=y
CONFIG_TOUCHSCREEN_CYTTSP_CORE=y
CONFIG_INPUT_MISC=y
# CONFIG_INPUT_ATI_REMOTE is not set
# CONFIG_INPUT_ATI_REMOTE2 is not set
# CONFIG_INPUT_KEYSPAN_REMOTE is not set
# CONFIG_INPUT_POWERMATE is not set
# CONFIG_INPUT_YEALINK is not set
# CONFIG_INPUT_CM109 is not set
CONFIG_INPUT_UINPUT=y
CONFIG_INPUT_GPIO=y
CONFIG_INPUT_KEYCHORD=y
# CONFIG_BMA150 is not set
I've extracted this from the semc_shakira_defconfig and you'll see that the synaptics and cyprus are enabled.
The question that comes to mind is why the cyprus have true dual while the synaptics X8 user stuck with only a fake? well, sadly the answer is in hardware. NO, it is not the controller... it is the screen, the touch screen sensor itself. like the synaptic advert says, the clearpad 1000 has 1touch + pinch.
What we can do however, especially if you're not planning to distribute your Kernel, is to disable the support for the driver you're not using.... think of it as payback.
To anybody interested to take a look. the touch screen drivers are located at (if you're using the format from the beginning of this tutorial) */FXP/drivers/input/touchscreen.
Files of interest are:
synaptics_i2c_rmi4.c
cyttsp_i2c.c
Well, it isn't much of a war...
Bring out the droids. or, semi-automating the process.
are you tired yet of entering those exports and stuff? well there's and easier way...
I've attached a file for your convenience (never say i didn't do you guys
favors.) called fxp2.txt. rename it to fxp2.bash and copy this into your Work directory. Which in this tutorial's case would be
/home/(your username/Kernel/FXP/
now, double click on this file from the home folders or type gedit fxp2.bash from terminal (be sure your in the working directory).
edit this file so that the paths are correct. save and close.
enter in terminal: "bash fxp2.bash"
cool, huh.
what did it do? first it cleaned up all the mess from previous compiles, then it set up the environment, then it made the .config and opened up the semi-GUI config editor. you can edit the configs as you want and when you exit the GUI, all you have to do is type in "make" et voila!!!
Speaking of the Configs. i'm sure that by now you've disregarded my warnings of not to change anything yet, and i'm very sure that by now you would have found that you can enable swap, setup support for ext234, set up driver support, net filters. etc. Heck, you might have even figured out how to make a kernel for the W8 by now.
But for the guys who did follow my warnings.... Why did you? That's why you want to compile the kernel... you want to be in charge, you want to be the boss of your own X8... the only thing stopping you is you didn't know how... NOW, YOU DO!!!
on the last chapter we'll be dealing with the Code's Revenge... the ramdisk.

part 3. Revenge of the Code
or that "insert profanity here" ramdisk!!!
Never before in the history of Noobiness has anything been more complicatedly crazy than the ramdisk. i mean, compiling the base kernel image is easy compared to this monster.
But we'll not let this stop us! Crash Helmets ON!!!!
What's the Ramdisk?
A ramdisk is basically a small filesystem containing the core files needed to initialize the system. It includes the critical init process, as well as init.rc, which is where you can set many system-wide properties. This is also where the chargemon (off-line charging) and the recovery systems are located.
we built our kernels using Blagus's ramdisk which is included with the bootloader unlock. so let's start with that:
1. get back to your Home folder. make a working folder for the ramdisk. lets call it "ramdisk" for the sake of this tutorial.
2. in the terminal, type "exit". it's a good idea now to get out of root access or we'll run into trouble later by having different access priorities as we switch between the GUI Home folder explorer and the Terminal based command line.
3. still in terminal, get into the ramdisk folder.
(hint: cd /home/(your username)/ramdisk)
4. copy Blagus's ramdisk into the ramdisk folder. you can rename it to ramdisk.cpio.gz or leave it as is.
5. let's upack the ramdisk by: gunzip -c ramdiskfilename | cpio -i
6. YAY!. now you can edit the ramdisk as you like it. I'll not go into this since it would take another tutorial in itself.
7. once you're done messing around with it. remove all the other stuff from the directory that you don't need, like the original ramdisk file.
re-pack the ramdisk with: find . | cpio -o -H newc | gzip > ../ramdisk.cpio.gz
you'll find the packed ramdisk.cpio.gz file in /Home.
8. rename this as ramdisk again and use as your ramdisk along with the kernel image you've compiled and make a kernel.sin as explained earlier in the tutorial.
We've now come full circle. Thank you for your time. i'll post more as i discover more and update the tutorial as i learn more.
Better yet, it would be great if you guys post something that would benefit all of us.
Additional Stuff that's good to know/have:
Well, that covers the basics of the kernel. but there's a few more things you might need. you know just in case.
Update your JAVA: you need these if your compiling for Froyo or later.
sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner"
sudo apt-get update
sudo apt-get install sun-java6-jdk
If your planning to build android rom, you'll need these:
(As noted by Dioxanh: for froyo and below, use a 32 bit system and a 64 bit system for gingerbread and above.)
32-bit linux installations:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev libncurses5-dev x11proto-core-dev \
libx11-dev libreadline6-dev libgl1-mesa-dev tofrodos python-markdown \
libxml2-utils
64-bit linux installation:
sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \
x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \
libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \
libxml2-utils

Tried to compile it but after make it says:
/bin/sh: /home/root/Kernel/arm-2010q1/bin/arm-none-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
It's because Root home folder is not in /home/root/ it's in /root/

Great tutorial!
Sticky!

Megakaban_ said:
Tried to compile it but after make it says:
/bin/sh: /home/root/Kernel/arm-2010q1/bin/arm-none-linux-gnueabi-gcc: not found
make[1]: *** [kernel/bounds.s] Error 127
make: *** [prepare0] Error 2
Click to expand...
Click to collapse
It simply mean that your crosscompile path is wrong. Check the location of arm-2010q1 via home folders explorer.
make mrproper
And start again from
export ARCH=arm
Sent from my TI99 4A

Now kernel compiled successfully and i tried to change initlogo.
As written here: http://forum.xda-developers.com/showpost.php?p=6775233&postcount=5 i've converted .rle to .bmp and edited it. Now when i converted back to .rle, i got just colour strips.

Megakaban_ said:
Now kernel compiled successfully and i tried to change initlogo.
As written here: http://forum.xda-developers.com/showpost.php?p=6775233&postcount=5 i've converted .rle to .bmp and edited it. Now when i converted back to .rle, i got just colour strips.
Click to expand...
Click to collapse
It's like the OP said, you're bound to lose something in the conversion. Try to search for superangga's init logo conversion thread in Google.
Sent from my TI99 4A

My nick is velnens123! I hate when people spell my nick wrong!
---------- Post added at 03:20 PM ---------- Previous post was at 03:08 PM ----------
Anyway good tutorial, will try it tommorow!

velnens123 said:
My nick is velnens123! I hate when people spell my nick wrong!
---------- Post added at 03:20 PM ---------- Previous post was at 03:08 PM ----------
Anyway good tutorial, will try it tommorow!
Click to expand...
Click to collapse
Oops. Sorry. Can I blame it on the x8 spell checker?
Corrected. ;-)
Sent from my TI99 4A

i've updated post #9, it's a simple look at the defconfig and a tip to make life a bit more easy. pretty sure some guys are already sick and tired of typing and retyping the same code. But hey, doing things repeatedly is a great way to learn. it also turns you into a zombie....

viper001, does your thread realy fits in General forum? I think not...
And your thread needs to be sticky!

velnens123 said:
viper001, does your thread realy fits in General forum? I think not...
And your thread needs to be sticky!
Click to expand...
Click to collapse
Actually, I couldn't decide between gen or dev. But, I'm not developing anything nor is it a question. Lol.
A sticky would be nice. ;-)
Sent from my TI99 4A

Related

[B928] OC kernel 0.1 [one-hit wonder]

This will not be worked on any longer thanks to Huawei's incompetence. I'm glad my main phone isn't by them. I leave my 0.2 diff attached (which did make my phone faster FWIW - and has fsync() control. Not of use to me, but people who use a modified libsqlite would like it...). Feel free to apply it and see if you can somehow fix dhd.ko loading.
Hi,
Not one for names, so this shall be known as "OC kernel" This is built from the ICS U8800pro source that Huawei put out.
Install at your own risk; I take no responsibilty for any damage that may occur through the usage of this kernel.
Features:
ADB as root
Overclocking enabled (thanks to genokolar)
Undervolting interface added (from genokolar, who took it from a SE kernel modder somewhere) - I think SetXperia can use it
SIO I/O scheduler added
SmartassV2 cpufreq scheduler (AnDyX mod) - although I think ondemand does a bit better IMO
sysfs entry to turn off keypad lights (I wrote an applet for this some time back, I'll dig it out later)
Logcat is always enabled now as the ServiceMenu toggle doesn't work anymore
Minimum display backlight is set to 15, but I think Android needs a framework change to use it. You could try RootDim
Kernel actually builds (and Bluetooth works)
ZRAM (+ swap) support. ZRAM is optimized for Android (taken from Siyah kernel). I'll write up the instructions on enabling this later
CIFS as module
Extras:
Change schedulers and phone speed:
Use a tool like No Frills CPU or SetCPU.
Turn off button lights:
Install the ButtonLight widget and add it to your main screen. I've published the source before in another thread; seek it out if you're after its (bad) code.
It's buggy the first few times you run it, but works fine after that.
Dim screen to 14:
The minimum backlight level is now set to 15. RootDim from the Play Store lets you set it to that.
Mount Windows shares:
Grab CifsMounter and point it to the cifs.ko in /system/lib/modules. You may also need to insmod nls_utf8.ko and md4.ko.
Enable ZRAM (taken from Siyah kernel):
(Note I've not used ZRAM so I have nothing to say on its stability, good or bad)
Grab a BusyBox binary from somewhere
Run the following commands:
Code:
echo 90 > /proc/sys/vm/swappiness #You must set the swappiness high to ensure that the compressed RAM is accessed first!
echo $SIZE > /sys/devices/virtual/block/zram0/disksize #Set size to whatever you wish. 100MB is 104857600 = 100 * 1024 * 1024
busybox mkswap /dev/block/zram0
busybox swapon /dev/block/zram0
Dump the lines in install-recovery.sh if you want to be ZRAMMed every time you boot the phone (although in that case, make sure you have
Code:
busybox swapoff /dev/block/zram0 > /dev/null 2>&1 #Use > /dev/null 2>&1 for every busybox command in install-recovery.sh as it will discard any messages outputted
echo 1 > /sys/devices/virtual/block/zram0/reset
before the lines above)
Install:
Flash the attached ZIP in CWM recovery. You should backup your original boot.img and /system/lib/modules first
Source:
Take http://www.huaweidevice.com/worldwi...=toDownloadFile&flay=software&softid=NDY3NTU= and apply attached diff
at last..xaaxxaa!!but why with modules too???whats their use?
pikachukaki said:
at last..xaaxxaa!!but why with modules too???whats their use?
Click to expand...
Click to collapse
'cause I add a new module - cifs (used by CifsMounter if you want to mount Windows shares) - and because the modules that are originally in /system/lib/modules need to be replaced so that they can load with this kernel (I don't know what those modules do, but I'd rather play it safe)
qwerty12 said:
'cause I add a new module - cifs (used by CifsMounter if you want to mount Windows shares) - and because the modules that are originally in /system/lib/modules need to be replaced so that they can load with this kernel (I don't know what those modules do, but I'd rather play it safe)
Click to expand...
Click to collapse
Boot normally change io to sio and smartassv2...1500mhz lets check..good work..i envy you and i want your guide on compiling...xaaxax im off to bed!!
fps is locked!!xaaxax
pikachukaki said:
Boot normally change io to sio and smartassv2...1500mhz lets check..good work..i envy you and i want your guide on compiling...xaaxax im off to bed!!
fps is locked!!xaaxax
Click to expand...
Click to collapse
I'll write it up sometime - but bear in mind I'm not an expert at this
Regarding FPS: do the install-recovery.sh trick
Only thing I modify in initramfs is the ro.secure setting so that ADB can be ran as root
qwerty12 said:
I'll write it up sometime - but bear in mind I'm not an expert at this
Regarding FPS: do the install-recovery.sh trick
Only thing I modify in initramfs is the ro.secure setting so that ADB can be ran as root
Click to expand...
Click to collapse
You did a great job i couldnt even compile the kernel without changes!!you did great!!
the difference is obvious !!
Sent from my U8800Pro using xda premium
Pika When U add This Kernet To ur ROM?
As expected from qwerty12!
Great job!
I'll also request a guide on how to build the kernel like pika asked.
Hope you continue to improve the kernel! A thanks is simply not enough to thank you for your work, but thanks again
husen4u said:
Pika When U add This Kernet To ur ROM?
Click to expand...
Click to collapse
I wont!just d/w it and flash it!simple!
Sent from my U8800Pro using xda premium
Now what you suggest oc ics or kalo gb?
Sent from my U8800pro using xda app-developers app
husen4u said:
Now what you suggest oc ics or kalo gb?
Sent from my U8800pro using xda app-developers app
Click to expand...
Click to collapse
From now on i wont ever go back to GB ever again! if our luck changes and someone release cm9 i will forget what gb is!! there are some small bugs but the rom is usable for everyday!!
Moihack said:
As expected from qwerty12!
Great job!
Click to expand...
Click to collapse
Thank you
I'll also request a guide on how to build the kernel like pika asked.
Click to expand...
Click to collapse
Certainly, sir.
Hope you continue to improve the kernel! A thanks is simply not enough to thank you for your work, but thanks again
Click to expand...
Click to collapse
Unfortunately I won't be working on this anymore unless Huawei get back to my request for the source to the the dhd.ko module (which they may not have to comply with because the license for the module states "Unless you and Broadcom execute a separate written software license agreement governing use of this software" so the U8800pro version may not be under GPL). I made (well, found on the Internet) more optimizations but the Wi-Fi refuses to turn on because the dhd.ko module refuses to load. Only way I can get something working is to build the source that Huawei give or attempt to force other versions of the bcm source to load, but it's unlikely that would work.
--
Anyway, a small guide.
I used an x86_64 laptop running (X)ubuntu 12.04.1 to follow these steps. This page was a great resource.
Prerequisites:
A computer running GNU/Linux (a Mac should work in theory - the same toolchain we use is built for it, too, but I have no idea how OS X works)
git installed (apt-get install --no-install-recommends git-core is enough under Ubuntu)
sudo apt-get install flex bison gperf build-essential libncurses5-dev zlib1g-dev ia32-libs lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib abootimg
Getting ADB working
One of the best things to do is getting ADB set up, as you then have easy communication with the device. It's not essential but you'll just end up wasting time transferring files through other, longer means.
Grab the Linux platform tools ZIP from here: http://www.hariadi.org/android/manually-download-of-android-sdk-tools-and-sdk-platform-tools/. Extract the adb binary from the zip file, preferably to somewhere in your $PATH. chmod 755 it. chown, if necessary.
Next, open http://aur.archlinux.org/packages/an/android-udev/android-udev.tar.gz and, doing all this as root (sudo in Terminal etc.), place 51-android.rules in /lib/udev/rules.d/ (not the best place - but it works), chmod 644 it and chown root:root it.
Next, execute /usr/sbin/groupadd adbusers, followed by gpasswd -a USERNAME adbusers, USERNAME being the user you normally log on with.
Restart (while you can force Linux to see the new group through the, well, newgrp command udev will not "see" the new rule, despite how much you try with udevadm).
That should be ADB set up (give it a test, remembering to enable USB debugging mode on the phone first!).
On to preparing your workarea.
--
Create a new folder in your home folder and cd to it. This folder will house the prebuilt folder of toolchains and other stuff, and the kernel source in a folder of its own.
In this folder, execute git clone --depth 1 https://android.googlesource.com/platform/prebuilt.git and move onto the next step, since the download takes a while. That command grabs the prebuilt toolchain from Google using Git, but doesn't obtain a deep history for each file to make the download quicker.
Open http://www.huaweidevice.com/worldwi...=toDownloadFile&flay=software&softid=NDY3NTU= and save the source to your Downloads directory. After git has finished running, still in the folder with the "prebuilt" folder, execute tar jxf ~/Downloads/HUAWEI_U8800pro<tab - as in actually press tab> and you should have a kernel folder alongside the prebuilt one.
Building the kernel
cd to this new kernel folder.
First things first: make sure that Bluetooth is properly enabled by editing the Makefile. Find the line #ifeq ($(ENABLE_BTLA_VER30),true) and comment out every line in that section except for KBUILD_CFLAGS += -DHUAWEI_BT_BTLA_VER30 so you end up with this:
Code:
#/* < DTS2012020604357 zhangyun 20120206 begin */
# Add Huawei Marco for different BT chip
#ifeq ($(ENABLE_BTLA_VER30),true)
KBUILD_CFLAGS += -DHUAWEI_BT_BTLA_VER30
#endif
#ifeq ($(ENABLE_BLUEZ_VER30),true)
#KBUILD_CFLAGS += -DHUAWEI_BT_BLUEZ_VER30
#endif
#/* DTS2012020604357 zhangyun 20120206 end > */
Commenting out the offending code leaves you with a kernel that builds but a Bluetooth module that won't start up - the same also applies if you try to build with the other define.
You can also make things easier for yourself by replacing the following
Code:
ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
with
Code:
ARCH ?= arm
CROSS_COMPILE ?= ../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-
else you will have to put "ARCH=arm CROSS_COMPILE=../prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin/arm-eabi-" after "make" each time. Remember this as I'll be assuming that you went for the option to edit the Makefile. I also assume that the prebuilt folder is above the kernel one. Adjust CROSS_COMPILE if necessary.
The ARCH variable is self-explanatory, but the CROSS_COMPILE variable (and the toolchain that it's pointing to) need to be set because the standard GNU development tools that apt installs don't produce output that an ARM processor can understand. So you cross-compile: the tools are for the X86 architecture but produce ARM output. 4.4.3 is chosen because the stock kernel is compiled with GCC 4.4.3 (if you run "adb shell cat /proc/version" you'll see). The arm-eabi-4.4.3 folder is chosen over arm-linux-androideabi-4.4.x because it specifies that magic "3" (I know, bad way to decide but it works), and over i686-android-linux-4.4.3 because we don't want to produce code for the PC.
Get the current configuration in use by the stock kernel (as that's a good point to start from - a known working configuration): http://wiki.cyanogenmod.com/wiki/Building_Kernel_from_source#Configure_the_Build
I'd also recommend placing a copy of .config as arch/arm/configs/<your funky name here> so that if .config gets deleted (make clean etc.) you can run make <the name you gave to the file in arch/arm/configs> and have .config come back again.
(cp arch/arm/configs/<the name you gave to the file> .config if you didn't modify the Makefile to specify the ARM arch.)
Run make oldconfig (not always necessary - generally it's invoked if you've applied a patch that introduces a new config option and the option then needs to go into your .config. Run make menuconfig afterwards and customize away.
When you're done, run make -jX - X as in the number of cores you have + 1. So, in my case, with a quad-core processor and HyperThreading enabled on all of them, "make -j9" works for me. If the compile went OK, you'll be left with a message saying that arch/arm/boot/zImage is ready. If not, run "make" without the -jX argument and make should stop where the error occurs. Have fun fixing the error!
Assuming that you have a new, shiny zImage, it's now time to put it into your boot.img.
Updating your boot.img:
Google have tools for this purpose but I've never used them so I don't know how they work. abootimg works fine for this, however.
Pull the current boot.img off your phone: adb pull /.cust_backup/image/boot.img.. I'd recommend creating a backup somewhere.
Create a new directory to store the boot.img in on your computer and run abootimg -x boot.img (if you had fun enabling every option in the kernel, you'll see why I'm telling you to use the -x option first rather than directly use the -u option). Now run abootimg -u boot.img -k <path to your newly built zImage>.
If this succeeds, yay! If not and you're told it's too big for the boot image, then don't worry. Take the size it's saying that the zImage is and convert that number into hex. Edit bootimg.cfg and change the value of the bootsize setting into the number you just converted into hex. We'll now repack again, but this time running abootimg -u boot.img -f bootimg.cfg -k <path to your newly built zImage>. This should work.
Sending the boot.img to the phone
If your ADB is already running as root, you can do the following to upload the new bootimg:
Code:
adb shell mount -o remount,rw /.cust_backup
adb push boot.img /.cust_backup/image/
adb reboot
If not, just reboot into pink screen mode and copy and paste.
Check System Settings and the version number should've changed. Congratulations!
Extras
Installing the modules:
OK, so you decided to build parts of the kernel as a module and you want to actually, y'know, have the modules present on the device. After building the kernel, execute:
make INSTALL_MOD_STRIP=1 modules_install INSTALL_MOD_PATH=<any folder name here>
If you look in that folder, you'll find the modules neatly wrapped up in folders, along with other text files. These text files are useless on a stock ROM because there's no modprobe - you need BusyBox for that. And since we don't want to have them seperated in folders (this is how the stock kernel does it), the files would be wrong, anyway. If you want to use modprobe and have BusyBox installed, you can run depmod on the phone after transferring the modules.
To get the modules into one folder make the directory "modules" in a folder higher-up to where the modules are stored, and then run for i in `find . | grep ko`; do mv "$i" ../modules/; done to move them into that folder.
At this point, I'd just recommend using my OC_Kernel.zip and replacing the modules in that. Or you can adb push them over to the /system/lib/modules folder (after issuing an "adb remount" - assuming that ADB is running as root in the first place).
Making ADB run as root:
As root on your computer, (we want to preserve permissions) use abootimg to split the boot image and extract the contents of the initrd:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames (--no-absolute-filenames is important! I trashed a Ubuntu install by leaving it out - the initrd contains ARM binaries of core Linux programs and if the initrd.img contains an absolute path of "/" then these files will get placed in /)
Make any changes you desire to the initrd. To have adb run as root, just edit /default.prop and set ro.secure to 0. Make sure that the editor you used didn't leave any backup files.
When you're done, run find . -print | cpio -o -H newc | gzip -n -9 > ../initrd.img and this will put the modified initrd folder back into initrd.img.
After that run cd .. ; abootimg -u boot.img -r initrd.img to actually put the initrd.img back into the boot.img.
If you run into a space error, you can do one of three things:
if you only made a single change (like enabling ADB), check to see that there is no backup file (default.prop~) littered about
you can remove the lengthy comments and copyright notices from the files to make space
you can use the trick we used earlier with abootimg to increase the size number in bootimg.cfg for the initrd
Overclocking:
Just look at the acpuclock C file (and possibly relevant cpufreq changes - but I can't remember) in my "OC kernel" diff. Make sure that the option in the kernel config is selected to limit the speeds to the U8800pro's native 1GHz, otherwise the phone will boot at 2GHz!
Rebuilding the Wi-Fi module:
I hope to be able to write this one since it's apparently needed in some cases, but it depends on if Huawei come through
any idea about this error?
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
matteof93 said:
any idea about this error?
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:327: error: rtc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:241: error: othc0_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:250: error: othc1_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:261: error: othc2_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:183: error: misc_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:210: error: thermal_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:270: error: batt_alarm_cell_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
drivers/mfd/pmic8058.c:152: error: pm8058_charger_resources causes a section type conflict
Click to expand...
Click to collapse
Honestly, I have no idea. What toolchain are you using and where was your .config obtained from? Even when the Bluetooth thing was giving me errors, I never once saw that
same toolchain you have used. i have tried with ubuntu 12.04 x64 and ubuntu 10.04 x86 but same problem.....i have obtained my config from my phone using adb command
matteof93 said:
same toolchain you have used. i have tried with ubuntu 12.04 x64 and ubuntu 10.04 x86 but same problem.....i have obtained my config from my phone using adb command
Click to expand...
Click to collapse
I don't know why the same toolchain works on my laptop but not yours :\
Someone with a similar problem (same?) solved it by using an older toolchain: http://forum.xda-developers.com/showpost.php?p=27294383&postcount=7157
thanks thanks thanks.....i saw that post this morning but i did not noticed the post with the solution
UPDATE: NOW KERNEL COMPILED CORRECTLY....this means that tomorrow i know what to do
ZRAM (+ swap) support. ZRAM is optimized for Android (taken from Siyah kernel). I'll write up the instructions on enabling this later
qwerty your owning us some instructions!!xaaxxa
pikachukaki said:
qwerty your owning us some instructions!!xaaxxa
Click to expand...
Click to collapse
Done, check the first post
I also won't be working on this. My email (which does clearly state what I want, even if it's long-winded):
Dear Sir/Madam,
I recently built a kernel for my U8800pro from your sources and it
works fine, except that the Wi-Fi will not start because the dhd.ko
module that comes with the B928 firmware refuses to load into my
modified kernel. After looking around, the bcm4329 source is what I
need to build (usually distributed outside of the kernel); however, it
seems that the U8800pro uses a customized version. After looking at
the strings of the dhd.ko on the B928 firmware, I have seen many
strings that are present in that dhd.ko binary do not appear in:
* bcm_4.218.248.6_7x25_wifi_driver.tar from the Huawei Device website,
despite it having the same version number
* the bcm4329 source in the Qualcomm CodeAurora Git repository
* the bcm4329 source on the NyVIDIA Tegra Git repository
Furthermore, the strings also do not appear in the ICS kernel nor the
Gingerbread one. I can only conclude that Huawei have their own
specialized version of the bcm4329 4.218.248.6 source for the U8800pro
that is distributed outside the kernel. I understand that Qualcomm
allow the option to let the vendor arrange to have the code
distributed under a different license provided that the vendor makes
an agreement beforehand with Qualcomm. Otherwise it becomes GPLed by
default. If Huawei chose to make an agreement, then I have no right to
ask. However, I believe it is still licensed under the GPL for two
reasons:
* Running modinfo on the dhd.ko from the B928 firmware says this:
"license: GPL v2
* Both bcm_4.218.248.6_7x25_wifi_driver.tar.gz and
[S7][SoftWare]S7_Broadcom_BCM4329_4.218.205.0_Open_Source are under
the GPL
I would like to request the source code, please, of the bcm4329
4.218.248.6 source that is modified for the U8800pro if the code is
under the GPL
Best regards
Click to expand...
Click to collapse
was met with the following generic response:
Dear Customer,
Thank you for contacting Huawei device.
This is our website link http://www.huaweidevice.com/worldwide/searchResult.
do?method=execute&searchString=U8800pro where you can download the secure
code for U8800pro to you.
Once again thank you for contacting Huawei device.
Best Regards.
Huawei Device Customer Care Team.
Click to expand...
Click to collapse
Since my U8800pro is not my main phone anymore, I do not have the energy to fight. Nor do I want to work on Huawei's kernel, where you have to be careful about what you change or the Wi-Fi module won't load (and Huawei won't give you the source - which they should do since I'm sure it's under GPL). matteof93 will most likely produce something better or when everyone starts producing their own kernels and make enough improvements to be hit with the same issue as I, they'll start to get more emails and listen
@qwerty at the last command it said that device is busy...also is there any way that you can make it for init.d so it will be easier??thx!!

ZF2 Linux Howto

I've had a bunch of requests on how to run Linux on our ZF2, so this is a quick(ish) howto using some awesome tools out there.
Requirements:
1. Root ( this is necessary for creating a chroot )
2. Busybox ( from the Play Store ) for Linux Deploy and pretty much all root-related software
3. Linux Deploy ( from the Play Store ) for installing Linux
Optional:
1. XServer-XSDL ( from the Play Store ) for X
2. MicroSD card for linux
3. SD Card Partitioning software ( I use Aparted from the Play Store )
Process:
1. Root your phone. Plenty of howto's out there
2. Install Busybox
3. Install Linux Deploy
4. ( OPTIONAL ) Install XServer-XSDL
5. ( OPTIONAL ) If you want pulse audio support, you will need to add a /tmp folder to /data/data/x.org.server/files/img/
6. ( OPTIONAL ) Install Aparted
7. ( OPTIONAL ) repartition your microSD card with partition 1 as exFAT & the 2nd partition as ext4 ( for linux )
7b. Write down the location of your ext4 partition. Most of the time it will probably be /dev/bloc/mmcblk1p2 ( means memory card 1 partition 2 )
8. Start up Linux Deploy
8a. click on Properties ( looks like a download icon on the bottom right )
8b. Under Deploy: Select your Distribution.
8c. Under Deploy: Select your Distribution suite. ( right now there is no hw video acceleration and Mesa's new implementation fails with llvm errors; so if you want software supported glx, then choose an older distro )
8d. Under Deploy: Select i386 or i686 ( do NOT select any of the ARM processors )
8e. ( OPTIONAL ) Under Deploy: change Installation type to Partition if you want to use a real partition off your microSD card.
8f. ( OPTIONAL ) Under Deploy: change Installation path to your real partition, ie /dev/block/mmcblk1p2
8g. ( OPTIONAL ) Under Deploy: Change File system to the filesystem we partitioned the card as, ie ext4
8h. Under Startup: ONLY have SSH checked
8i. ( OPTIONAL ) Under Startup: Check Custom Mounts to mount other filesystems, like the internal SD card, the microSD card exFAT partition or even the /tmp folder for XServer-XSDL for pulse audio
8j. ( OPTIONAL ) Under Startup: Click Mount points to add mount points, here's a quick list:
/storage/emulated/0
/storage/MicroSD
/data/data/x.org.server/files/img/tmp
These 3 mounts would appear as: /mnt/0, /mnt/MicroSD and /mnt/tmp in your chroot linux
9. Install Linux ( it will take around 30 minutes or so )
10. After installation finishes, click Start and Linux Deploy will start up your ssh service.
11. Connect to your phone via ssh with default login/password: android/changeme
12. I HIGHLY recommend changing your password.
13. ( OPTIONAL ) start up XServer-XSDL on your phone
14. ( OPTIONAL ) export DISPLAY=:0 to send all X commands to XServer-XSDL
15. ( OPTIONAL ) Pulse Audio: use your local package manager ( apt-get, rpm, pacman, emerge, etc... ) to install pulseaudio & pulse-alsa packages. This should set the default asound.conf to use pulse audio.
15a. ( OPTIONAL ) edit /etc/pulse/default.pa and add this line at the end:
load-module module-pipe-sink rate=44100 format=s16le channels=2 file=/mnt/tmp/audio-out
15b. ( OPTIONAL) edit /etc/pulse/default.pa and comment out the lines containing module-console-kit, ie:
# .ifexists module-console-kit.so
# load-module module-console-kit
# .endif
15c. ( OPTIONAL ) to start pulse audio before your application: $pulseaudio --start -D
16. Run your Linux executable(s)
Directions on recompiling LLVM, Gold & Mesa for Intel SSE4.1 assisted 3d: http://forum.xda-developers.com/showpost.php?p=62024812&postcount=12
Arch Linux walkthrough: http://forum.xda-developers.com/zenfone2/general/zf2-linux-howto-t3158034/page4#post62916375
Enjoy linux running alongside your phone.
Edit: Compiled libandroid-shmem.so for 64-bit Arch.
Thank you for the in-depth tutorial. How well does this run? In the past I have tried (ARM based devices) and it runs like trash when trying to start applications. Does it run smooth on here?
Christopher876 said:
Thank you for the in-depth tutorial. How well does this run? In the past I have tried (ARM based devices) and it runs like trash when trying to start applications. Does it run smooth on here?
Click to expand...
Click to collapse
It's pretty much native linux, so comparable to whatever's out there. As far as X goes, it's pretty smooth with XServer-XSDL. <-- hands down, the best Android X Server out there.
...and you can further increase the speed of X apps by getting libandroid-shmem.so ; it opens a shared memory location with XServer-XSDL. ( Under the description of XServer-XSDL is a link to download it ) This ONLY works for 32 bit distros at the moment.
ie, $LD_PRELOAD=/lib/libandroid-shmem.so mplayer my_movie & would play the movie with shared memory access.
Actually, I use this setup to start up Qemu-KVM to virtualize windows.
You will have issues with OpenGL, though, because right now I haven't figured out how to access the video card hardware properly. Older Distros, before Mesa moved to llvm, will still allow you to do software rendering & I was able to get around 40-50 fps w/ the test software.
Added to index; thanks for the tutorial!
Good job
I keep getting a message that says couldn't find these debs: 0. And I also get the linux.img already but, its suppose to be a 30 minute install
Sent from My ZE550ML
troy5890 said:
I keep getting a message that says couldn't find these debs: 0. And I also get the linux.img already but, its suppose to be a 30 minute install
Sent from My ZE550ML
Click to expand...
Click to collapse
I would first check your internet & if it still doesn't go, try a different distro.
Depending on which Distro you want to install, I'd recommend going to Google to see how to mount your img and create the chroot from scratch.
So, every OS in VM (Linux, Windows) suffers from lack of full-featured GPU drivers. In other words, every OS in VM on ZF2 stuck with software rendering.
While it can be OK for some office or other non-graphics intensive apps, you can forget about idea to run the games
If i guess right, this situation won't change, because no-one will able to write GPU driver.
sorg said:
So, every OS in VM (Linux, Windows) suffers from lack of full-featured GPU drivers. In other words, every OS in VM on ZF2 stuck with software rendering.
While it can be OK for some office or other non-graphics intensive apps, you can forget about idea to run the games
If i guess right, this situation won't change, because no-one will able to write GPU driver.
Click to expand...
Click to collapse
The problem isn't the GPU driver, though.
This is using the Android kernel. Which means we do have some sort of hardware acceleration on Linux...
Just not full hardware acceleration. I heard it had to do with something in the way this deploys or something like that. Idk~
AkiroX said:
The problem isn't the GPU driver, though.
This is using the Android kernel. Which means we do have some sort of hardware acceleration on Linux...
Just not full hardware acceleration. I heard it had to do with something in the way this deploys or something like that. Idk~
Click to expand...
Click to collapse
For simplicity, i've called 3D accelerated (DirectX, OpenGL) driver as GPU driver.
Of course, there is basic video driver, but that's not enough to play the games.
May be it's possible to use somehow part of android binaries, like OpenGL driver, and then create some other OpenGL driver on top of it (Android API is well documented), to make it compatible with normal Linux. Some kind of wrapper.
At least in theory. This should require a lot of knowledge.
About the "couldn't find these debs: 0", I think it's due to an invalid combination of settings. For instance I get it when selecting GNOME on Ubuntu Precise, but it installs just fine when using Lucid.
That said I can't get GNOME to work with any distro I've tried. Just crashes when starting gnome-session. Guess it needs graphics acceleration?
Also, I don't think busybox is strictly required. At least I've previously managed to install Debian with LXDE without installing busybox.
Update: LLVM & GLES
In order to get GLES( 1 & 2 ) working, you will need to recompile LLVM, Gold & Mesa.
Explanation of the issue:
Without hardware accelerated video drivers, modern linux distros fall back to the software renderer. The current Mesa software renderer tries to make use of all possible intrinsic instructions ( SSE, SSE2, SSE3, SSE4, etc.. ) at link time (LTO). Here's the rub: LLVM doesn't recognize our cpu, so it returns generic x86_64; which doesn't support.. you guessed it, SSE4.1; even though cpuinfo will show that we have SSE4.1 support.
Here's the process:
I. Prepare binutils following this guide: http://llvm.org/docs/GoldPlugin.html
1. download binutils: git clone --depth 1 git://sourceware.org/git/binutils-gdb.git binutils
2. create a separate build directory since you're only going to use the binutils source files. I called mine: mybuild
3. from your build directory: $ ../binutils/configure --enable-gold --enable-plugins --disable-werror
4. from your build directory: $ make all-gold
II. Prepare & Build LLVM following this guide: http://www.linuxfromscratch.org/blfs/view/svn/general/llvm.html
1. Download LLVM 3.6.2: http://llvm.org/releases/3.6.2/llvm-3.6.2.src.tar.xz
2. Download Clang: http://llvm.org/releases/3.6.2/cfe-3.6.2.src.tar.xz
3. Download Compiler RT: http://llvm.org/releases/3.6.2/compiler-rt-3.6.2.src.tar.xz
4. extract LLVM: $ tar xvf llvm-3.6.2.src.tar.xz
5. extract Clang inside the llvm directory -> tools directory: tar xvf cfe-3.6.2.tar.xz
6. rename the directory: $ mv cfe-3.6.2 clang
7. extract Compiler-RT inside the llvm directory -> projects directory: tar xvf compiler-rt-3.6.2.tar.xz
8. rename the directory: $ mv compiler-rt-3.6.2 compiler-rt
III. Modify lib/LTO/LTOCodeGenerator.cpp
1. do a quick search for "yonah", it should appear in bool LTOCodeGenerator::determineTarget
2. After the Darwin check, add the following line: Mcpu = "silvermont";
3. ( Explanation ) Even though our processor is a Moorefield ( Medfield ) processor, it falls under the Silvermont sub-family. Basically, we're telling LTO ( Link Time Optimization ) that it doesn't matter what we're detected as, we're a Silvermont processor.
IV. Modify lib/Support/Host.cpp for Intel processors
1. ( explanation ) if you do a $ cat /proc/cpuinfo you'll see that our family is 6 and our model is 90. So we need to add that to the Atom Silvermont section of StringRef sys::getHostCPUName. Cpuid, though, also detects our model as model 10, so we need to comment out that model under family 6.
2. comment out the case statement under family 6 w/ model 10: // case 10: // Pentium III Xeon processor, model 0Ah ( here we add 2 slashes in front of case 10 )
3. Add 90 and 10 to the Silvermont section of family 6 ( "slm" is shorthand for silvermont ):
// Atom Silvermont codes from the Intel software optimization guide.
case 55:
case 74:
case 77:
case 90:
case 10:
return "slm";
4. To make sure we make LLVM aware of what processor we are, comment out all of the "default: return x86_64..." 's with:
default: return "slm";
// default: return (Em64T) ? "x86-64" : "i686";
5. Comment out "generic" and return "slm" again:
default:
return "slm";
// return "generic";
V. Prepare the LLVM configuration in the llvm directory
1. $ sed -e "s:/docs/llvm:/share/doc/llvm-3.6.2:" -i Makefile.config.in
2. $ sh configure --with-binutils-include=[full downloaded binutils path]/include --prefix=/usr --enable-shared
3. make -j2
4. Go have dinner, watch a movie, drink some coffee; it's going to take a LONG time
5. DO NOT INSTALL IT YET
VI. Prepare Mesa
1. Download Mesa 10.6.2 from mesa: ftp://ftp.freedesktop.org/pub/mesa/10.6.2/mesa-10.6.2.tar.xz
2. extract mesa $ tar xvf mesa-10.6.2.tar.xz
3. inside the mesa directory: $ sh configure --host=x86_64-pc-linux --prefix=/usr CFLAGS=-march=silvermont --enable-gles1 --enable-gles2 --enable-nine --enable-opencl --with-llvm-prefix=[full path to downloaded LLM]/llvm-3.6.2.src/Release+Asserts
4. $make -j2
VII. Install LLVM & Mesa
1. from the llvm directory: $ sudo make install
2. from the mesa directory: $ sudo make install
If everything works, you can download the mesa demo's package from your favorite package manager and be able to run es2gears_x11 w/ XServer-XSDL ( from the App Store ).
On average, I get just shy of 60 fps this way.
You should be able to download virtualgl & turbovnc to get quite a performance boost. VirtualGL uses a fake X environment to render the 3D and passes that on to the 2D X environment. TurboVNC is built on top of VirtualGL, so it's a vncserver that supports pretty snappy gles on and off the phone. I was able to hit around 112 fps w/ es2gears_x11 in a TurboVNC environment. YMMV
At the moment, there is still no GLX support and I'm looking into it, but having our quad core processor w/ SSE4.1 helps w/ the software rendering a LOT.
Does that mean GPU acceleration is close to work or we need GLX (OpenGL for X) ?
The fps you got are in which game/application?
Is TurboVNC faster than VirtualGL?
aziz07 said:
Does that mean GPU acceleration is close to work or we need GLX (OpenGL for X) ?
The fps you got are in which game/application?
Is TurboVNC faster than VirtualGL?
Click to expand...
Click to collapse
Before we can get GPU acceleration, I wanted to make sure LLVM responded w/ the correct cpu since a LOT of software now uses it.
fps was from es2gears_x11, the mesa gles2 demo program.
Connecting to TurboVNC using bVNC ( from the app store ) allowed es2gears_x11 to run around 112 fps
Connecting to TurboVNC from my laptop using Windows TurboVNC viewer allowed es2gears_x11 to run around 68 fps
Using VirtualGL running es2gears_x11 to XServer-XSDL was just shy of 60 fps ( ~58 fps or so ), so either I'm not running it correctly, but XServer-XSDL is limited
The benefit of using XServer-XSDL, though, is that it has built-in pulseaudio support; right now, I'm not setting something right in my /etc/pulse/default.pa configuration file to stream audio to Simple Player ( android app store ).
Edit:
Here's a video of TurboVNC running the lxde windows manager, es2gears_x11, Windows 8 under qemu-kvm and the ePSXe Playstation 1 emulator inside Windows 8.
Hows your ram usage in Android with all those running ??
aziz07 said:
Hows your ram usage in Android with all those running ??
Click to expand...
Click to collapse
Pretty much normal. I think I dip down around 900 megs free or so. ( because I allot 1 gig to Windows 8 )
Amazing accomplishments ycavan, but I'm wondering, can I compile on my desktop machine (Arch Linux x86_64), move the folders to the chrooted installation in my ZenFone, and make install then and there? Am I missing something here? I dabbled with clang, but mostly small stuff (and using Qt in the middle, so I wasn't really doing a whole lotta makefiles or stuff like that ). Also, is there any improvement for this in Mesa 10.6.3?
Thanks!
edit: on my Arch installation I'm getting the warning "configure: WARNING: unrecognized options: --enable-gold" and it can't do the make all-gold. Am I missing something?
pijiman said:
Amazing accomplishments ycavan, but I'm wondering, can I compile on my desktop machine (Arch Linux x86_64), move the folders to the chrooted installation in my ZenFone, and make install then and there? Am I missing something here? I dabbled with clang, but mostly small stuff (and using Qt in the middle, so I wasn't really doing a whole lotta makefiles or stuff like that ). Also, is there any improvement for this in Mesa 10.6.3?
Thanks!
edit: on my Arch installation I'm getting the warning "configure: WARNING: unrecognized options: --enable-gold" and it can't do the make all-gold. Am I missing something?
Click to expand...
Click to collapse
I'm not sure about compiling on your desktop machine, but I doubt it'd be too much of a problem.
re: the --enable-gold warning, did you follow the linked howto? it almost sounds like you didn't grab the correct binutils ( or running configure for some other program )
I'd like to think so. I created a directory, did the clone of binutils into that directory. CDd there, created another directory called "mybuild" (so I could follow the steps perfectly), etc. I'll try again in a little bit and post some pictures with the warning, should they arise again. Thanks!
EDIT: created "mybuild" INSIDE binutils, instead of BESIDES binutls. making it right now. I'd like to, eventually, post a video guide of this build process, with your permission and due credits.
I think that's a wonderful idea!
Sent from my ASUS_Z00AD using XDA Free mobile app

VM For Developing Custom ROMs

Virtualbox Virtual Machine For Custom ROMs​I found the steps necessary to compile a custom ROM a bit daunting.
Also, I have a Windows PC and most of the instructions are around Linux.
Therefore, I created a Vagrant project to automate all the setup. It does the following:
Creates an Ubuntu trusty64 server VM using VirtualBox
Add all the necessary packages
Adds a 'buildbot' user
Creates the local directory structure
Downloads the repo wrapper
Initialises the repo using CM13.0
Syncs the repos (downloads all the source code)
Adds the build commands
Adds Ziyans device tree for Galaxy Nexus
Syncs the device tree
Compiles the code (brunch maguro)
I have attempted to reduce the amount of data downloaded by excluding various groups and only doing a shallow clone i.e no history.
This still downloads 5.5 GB for the main CM source and 0.5 GB for @Ziyans device tree.
As long you have Vagrant and Virtualbox installed, you just clone my repo (or download the zip from GitHub) and type
Code:
vagrant up
and everything will be done for you!
https://github.com/opticyclic/cyanogenmod-vagrant
This was written for a Galaxy Nexus.
If you want to change ROM you need to modify this line:
Code:
exec { 'init repo':
cwd => '/home/buildbot/android/system',
command => '/usr/local/bin/repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0 --depth=1 --groups=all,-notdefault,-device,-darwin,-x86,-mips,-exynos5,-intel,-eclipse,-device',
user => 'buildbot',
group => 'buildbot',
creates => '/home/buildbot/android/system/.repo',
timeout => 0,
require => [ File['chmod repo'], File['create build dirs'], File['create gitconfig'] ],
}
If you want to change device you need to change this line to your device name.
Code:
exec { 'brunch':
cwd => '/home/buildbot/android/system',
environment => ["HOME=/home/buildbot", "USER=buildbot"],
command => "/bin/bash -c 'source build/envsetup.sh;brunch maguro'",
user => 'buildbot',
group => 'buildbot',
timeout => 0,
require => Exec['sync repo'],
}
And make sure the correct device tree is mentioned in the roomservice.xml
NOTE: If you have CPUs or memory to spare then you should increase the VM settings in the Vagrantfile before doing vagrant up.
Code:
config.vm.provider :virtualbox do |vb|
vb.cpus = 2
vb.memory = 4096
UPDATE 2016-05-19: There was previously an issue with the order of the steps and the file owners. It should now run all the way through brunch maguro now.
.....and if I wanted all the source code Ziyan's "AOSP Omap4" , instead CM13 ?
At the moment it isn't complete as I didn't fully understand the last few steps of the CM build process.
However, the key file to change is https://github.com/opticyclic/cyanogenmod-vagrant/blob/master/modules/gnex/manifests/init.pp
I could add an if statement based on a property to use OMAP4 instead.
However, I would need to know the steps/urls that are different to CM.
Its in a much better state now with swap for those without much RAM to spare and a dedicated virtual drive for the code as the base box isn't big enough.
If you have an SSD you are going to see much faster times.
Also if you have the CPUs or RAM to spare you should increase the VM settings in the Vagrantfile before doing vagrant up.
In case you're familiar with Docker, you can also take a look at my docker-cyanogenmod project which does a very similar thing: http://forum.xda-developers.com/showthread.php?t=2650345
Besides this, I think that a project like this should not be limited to a specific device, so you might want to move the thread to the Android Software Development subforum: http://forum.xda-developers.com/android/software

[GUIDE]A Noob Guide On Building Your Own Custom Kernel (ARM & ARM64 & MTK)

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 and mediatek devices (arm64 coming soon)
- Add feature
- Basic use of git
Requirements:
- A computer running any distribution of linux 64 bit (Unbuntu, archlinux etc) as the Primary OS or a Virtual Machine (I used BBQ linux x64)
- Space on your HDD (On my Virtual Machine I set 40GB, set yours according to how many kernels you want to build) The minimum space for a kernel source (and its compiled code) is about 2 GB
- Minimal linux knowledge (Terminal, Commands etc)
- Your Brain
- And finally patience
2. SETTING UP YOUR BUILD ENVIRONMENT:​
- Open your terminal and type "sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2"
(The command can be different depending upon your linux distribution)
- Then type "gcc"
If "gcc" is already installed, you should see "gcc : fatal error : no input file"
- Then type "make"
If "make" is already installed, you should see "make: *** no target specified and no makefile found. stop."
(In your native language)
- Then type "git"
If "git" is already installed, you should see bunch of basic git commands
Now you're almost ready to start building your kernel!
Toolchains:
There are several types of toolchains (GCC, Linaro and few custom made ones)
Warning : Not every single device kernel will boot (or even compiles) with older or newer GCC
- For ARM:
We'll be using GCC 4.7 in this tutorial (link : https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/ )
-Open terminal and type: "mkdir kernel"(Type the name you want, I used "kernel")
-Then type "cd kernel" (the name which you used above)
-Then type "git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7"
-Wait till it finishes.
- For ARM 64:
For ARM 64 you need a 64 bit kernel compiler (there's "aarch64" in the name for telling that's a 64 bit compiler)
Exemple : https://releases.linaro.org/archive/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
3.DOWNLOADING SOURCE FILES FOR YOUR DEVICE:​
Now you have to find a github that contains your kernel source.
Search on Google or XDA to find a kernel github repo for your device.
A kernel github looks like this: "https://github.com/atxoxx/android_kernel_samsung_msm8974/tree/xenomTW"
On the upper left side you can see branch: completed by a name
These are the different versions of the kernel/project (generally can be for testing, android version etc)
QUICK EXPLANATION OF FILES/FOLDERS:
- /arch/arm/configs : contains the config files for device (where you add option like new governors, features etc)
- /output/arch/arm/boot/ : Where zimage is stored (will explain that later)
- build.sh : Script to make the building much easier (will explain how it works later)
- /arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2 : I put the toolchain in my kernel source making it easier to find (your kernel's toolchain name may be different)
If you don't have your kernel source yet, you need to download it.
Open terminal and make sure that you are in "kernel" folder (the one you previously created)
Then type in terminal : "git clone "URL of the github kernel" -b "name of the branch" "
For Example : "git clone https://github.com/atxoxx/android_kernel_samsung_msm8974 -b xenomTW"
Good! Now you have your kernel source!
4.BUILDING:​
For an easier way you can go to the location using your file explorer to : "/home/"name of your session"/kernel"
You'll see two folders (The Toolchain and The Kernel Source)
Go into your kernel source folder.
- For ARM:
Copy paste this:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=$(pwd)/arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2/bin/arm-cortex-linux-gnueabi-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For ARM 64:
Copy paste this:
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm64: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=$(pwd)/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux/bin/aarch64-linux-gnu-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For Mediatek:
Copy paste this:
#!/bin/bash
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
export ARCH=arm ARCH_MTK_PLATFORM=
make "name of defconfig and variant if needed"
make -j4
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- export ARCH=arm ARCH_MTK_PLATFORM=: Defining which kernel architecture type it is (For example arm64 etc) "ARCH_MTK_PLATFORM=" is for specifying which mediatek platform it is
- make _defconfig : Defining which defconfig to use (will explain later)
- make -j4: where the building starts, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
Click to expand...
Click to collapse
Example :
#!/bin/bash
export CROSS_COMPILE=$(pwd)/arm-eabi-4.8/bin/arm-eabi-
export ARCH=arm ARCH_MTK_PLATFORM=mt6580
make pixi4_4_8g1g_defconfig
make -j4
Click to expand...
Click to collapse
When these step are done make sure you are in kernel folder in terminal and type ". build.sh" (the dot at the beginning is essential don't forget it!)
If it compiles without any problems:
Wait till it finishes (it'll say something like "zimage is ready")
If you followed arm and arm64:
Then go to "/Output/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
If you followed mediatek:
Then go to "/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
Caution : Not all kernel build Zimage, it can build image or other compressed image
If in case you have any errors:
Check and see what it says, generally it'll tell you where the error is.
If the text is going too fast reduce the -j number as explained above.
For reference I compile with an AMD Phenom X4 3.4GHz,Samsung HDD and 8GB of RAM and it takes around 10min to build
It is recommanded to type in the terminal "make clean && mrproper" before compiling again​
5.MAKING THE KERNEL BOOT:​
You have 2 solutions here:
1) You can use @osm0sis anykernel method, which is explainded here: "https://forum.xda-developers.com/showthread.php?t=2670512" (A huge shoutout to him!)
OR
2) You can unpack the boot.img (from the same rom (CM, touchwizz,sense etc) and android version) and swap Zimage in it explained here : "https://forum.xda-developers.com/showthread.php?t=2073775" (thanks again to @osm0sis !)
Before flashing the kernel which you've made, backup your "stock" boot.img and Then flash your kernel and see if it boots!
6.HOW TO ADD FEATURE TO KERNEL WORK:​
Here starts the most interesting part! Now let's see how it works:
Basically you can add: Governors, IO Schedulers, Overclock the CPU & Many Tweaks...
Checkout the github section (Section 7) to see how to add them properly.
Here's an exemple for adding a governor (this one is called Intellimm) : https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
The text in the blue box is the commit description (generally tells you about the changelog, general information and who originally made the commit)
The other text boxes tell you about where and which files have been modified/changed.
Everything in green indicates what has been added.
Everything in red indicates what has been deleted.
We can see in the first 2 text boxes that in "arch/arm/configs/" "msm8974_sec_defconfig" and "cm_msm8974_sec_defconfig" have been modified.
Between the lines 140 and 141 of this files this text has been added : "CONFIG_CPU_FREQ_GOV_INTELLIMM=y"
(This line is for enabling Intellimm when you're compiling your kernel)
Same technique applies to the other text boxes (what has been added and deleted and it's location)
Depending on the features you add, more or less files can be modified, added or deleted.
So to sum it up, a Commit let's you see all the changes which have been made and everything else!
7.GUIDE TO GITHUB:​
For this, I'll direct you over to this awsome guide made by @eagleeyetom !
8.GPL (IMPORTANT !!!):​
The Rules as they apply on XDA
As XDA has no legal power to uphold the GPL (and frankly we want to stay as far away from doing so as possible), we can’t force any of our users to abide by the GPL. However it is in XDA’s interests as well as the interests of our developer-base to ensure all GPL-derived materials hosted or linked on XDA comply fully with the GPL.
GPL-derived materials that do not come with the complete sources used to compile the GPL components are considered warez, and will be treated as such under forum rule 6 and 9.
If you use GPL components, but do not make any modifications to them whatsoever, you should provide a link to the original source of your GPL code.
Sources accompanying a release should be complete, and contain all the necessary source code for any modules, scripts or definition files. Complete sources will be defined as those which compile correctly and completely against the platform for which the software is distributed, and which contain any and all modifications made to the released General Public Licenced code. The source code supplied should be the exact version for which the source code is being requested, complete with all modifications.
EXAMPLE: Here’s a bit of code that could be used as a template to post your releases
<Kernel Or Author Name> <Kernel Nr>:
<Source>|<ReadMe>|<Credits>|<Other>
The Very Quick Summary of General Public License (GPL)
The text of the GPL Licence itself will be used to reach any final conclusion regarding any disputes over GPL Licenced materials. The above is a summary of what XDA expects of members using GPL code, and the complete text can be read at the GNU website.
The GPL states that anyone who modifies GPL licenced code is required to make available the sources used to compile it. This is to further improve and encourage collaborative work, as well as to ensure that the best code possible is produced, and to encourage peer-review of all work. This benefits both developers and end users in numerous ways, including:
Allowing anyone to verify the code they are trusting with their data, and its authenticity
Encouraging community collaboration to produce faster fixes and updates, and better code
Helping bring new developments from other devices and fields to your own, letting you benefit from new code that wouldn’t have been available without this sharing.
The GPL imparts great freedom for GPL end users. It ensures innovation is never stifled and no project is dependent upon any single developer.
It is in everyone’s interest for the GPL to be adhered to, as it gives us all better ROMs, better transparency, and a better atmosphere for developers to work together to make great code.
Click to expand...
Click to collapse
THANKS :​
- @ravish_919 : For testing and correcting this guide
- @karkasss : As my friend and support
- @gugu0das : For helping me a lot when I tried to build my kernel
- @eagleeyetom : For his awsome github guide
- @kirito9 : Huge thanks to him for providing mediatek guide !
- @F4uzan : Huge thanks to him for giving me a lot of useful information to fill this guide !
- @sunilpaulmathew : For providing an advanced method to rename your kernel !
- @RendyAK and @DroidThug : For correcting me about "#!/bin/bash"
- All the developers for their hard work !
- XDA and The Community!
TIPS AND TRICKS​
1. You can use a copy of a defconfig file with different setup :
Usage : Use a "stock" one and use another one with esperimental feature for testing without altering original defconfig
Exemple : copy "stock" defconfig and in copied one add a governor see if it compile and work
How to do : Create a second build.sh with modified defconfig name !
2. Change kernel name and version :
Simple method :​Edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Advanced method :​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
const char linux_banner[] =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
To something like this :
const char linux_banner[] =
"Linux version " UTS_RELEASE " (XenomTW)"
"(" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (XenomTW)"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
More to come...
Placeholder
Hey, nice work to see an updated guide. Do you think it will be possible to include Mediatek(MTK) support? I'll provide details through PM how I build my kernel and how MTK differs. I'm still a noob but have compiled enough to merge this guide.
You can probably add a page dedicated to MTK . Guides aren't my forte :").
kirito9 said:
Hey, nice work to see an updated guide. Do you think it will be possible to include Mediatek(MTK) support? I'll provide details through PM how I build my kernel and how MTK differs. I'm still a noob but have compiled enough to merge this guide.
You can probably add a page dedicated to MTK . Guides aren't my forte :").
Click to expand...
Click to collapse
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
3lambda said:
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
Click to expand...
Click to collapse
Nice, I'm a bit under the weather but you can make a placeholder for MTK and send what I know when I'm feeling better.
kirito9 said:
Nice, I'm a bit under the weather but you can make a placeholder for MTK and send what I know when I'm feeling better.
Click to expand...
Click to collapse
No problem take your time hope you'll feel better soon !
@3lambda, thumbs up :good::good: for this awesome guide.
It will be of much benefit to MTK Devs & maybe porters.
Up up bro.
Hoping to share little that I got to know when I started kernel development.
Hoping for the best.
Hoping this guide go far than our expectations
What people think about videos too ?
Like a series of guide
For example one for basic build
One for explaining how to implement a feature
One that explain common issue/bug etc ?
3lambda said:
What people think about videos too ?
Like a series of guide
For example one for basic build
One for explaining how to implement a feature
One that explain common issue/bug etc ?
Click to expand...
Click to collapse
it will be very useful
highly appreciated your contribution to the community thank you
Thank you for this helpful guide! Will be waiting for the "Adding Features" section! Quite the work you have done! :good:
3lambda said:
Of course could be really cool !
I'll credit you etc
Also I'll try later to support arm64 too
Click to expand...
Click to collapse
I got some Unwinding errors related to vmlinux.o and built-in.o
Device_Lenovo A6000
Kernel Sources_ https://github.com/varunhardgamer
repo name- kernel lenovo a6000
used toolchain_ arm-linux-androideabi-4.9 from android NDK
It would be grateful if you can help me
Thanks:good:
The Hard Gamer said:
I got some Unwinding errors related to vmlinux.o and built-in.o
Device_Lenovo A6000
Kernel Sources_ https://github.com/varunhardgamer
repo name- kernel lenovo a6000
used toolchain_ arm-linux-androideabi-4.9 from android NDK
It would be grateful if you can help me
Thanks:good:
Click to expand...
Click to collapse
What error have you ?
Also is your device arm64 ?
Envoyé de mon m8 en utilisant Tapatalk
3lambda said:
What error have you ?
Also is your device arm64 ?
Envoyé de mon m8 en utilisant Tapatalk
Click to expand...
Click to collapse
Unwinding could not be possible
recipe for vmlinux.o failed
device is arm
i guess its related to toolchain and gcc
Will report back after changing toolchain
The Hard Gamer said:
Unwinding could not be possible
recipe for vmlinux.o failed
device is arm
i guess its related to toolchain and gcc
Will report back after changing toolchain
Click to expand...
Click to collapse
Try to use​ GCC 4.7 (with the link i provided in op) instead of ndk
Envoyé de mon m8 en utilisant Tapatalk
3lambda said:
Try to use​ GCC 4.7 (with the link i provided in op) instead of ndk
Envoyé de mon m8 en utilisant Tapatalk
Click to expand...
Click to collapse
Ok, And Thanks for the guide man:good:
Code:
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
This
Will copy the Image file from output folder to the arch/arm/boot folder so the users can find it directly from there.
cp is used to copy something from the command line.
mv is used to rename or move a file.
Anyways nice start & nice guide! :good:
Has.007 said:
This
Will copy the Image file from output folder to the arch/arm/boot folder so the users can find it directly from there.
cp is used to copy something from the command line.
mv is used to rename or move a file.
Anyways nice start & nice guide! :good:
Click to expand...
Click to collapse
Oh lol thanks
Will correct that in op
Linaro
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!
3lambda said:
2. Change kernel name and version :
Simply edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Click to expand...
Click to collapse
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
const char linux_banner[] =
"Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@"
LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")"
" (" LINUX_COMPILER ") %s\n";
Click to expand...
Click to collapse
some thing like this
const char linux_banner[] =
"Linux version " UTS_RELEASE " (XenomTW)"
"(" LINUX_COMPILER ") " UTS_VERSION "\n";
const char linux_proc_banner[] =
"%s version %s"
" (XenomTW)"
" (" LINUX_COMPILER ") %s\n";;
Click to expand...
Click to collapse

[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK)

[GUIDE]A Noob Guide On Building Your Own Custom Kernel on WIN10 (ARM & ARM64 & MTK)
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 and mediatek devices on windows 10
- Add feature
- Basic use of git
Prerequise :
- Updated windows 10 64bits (falls creators update)
- A decent computer with a decent internet speed
- Space on your HDD The minimum space for a kernel source (and its compiled code) is about 2 GB
- Minimal linux knowledge (Terminal, Commands etc)
- Your Brain
- And finally patience
2.Setting UP ENVIRONMENT:​
Installing ubuntu :
1 - Go in Settings -> Update and Security -> For developers and turn on developers mode then
2 - go in Control Panel > Programs > Turn Windows Features On Or Off and enable Windows subsystem for linux
3 - Reboot your computer
4 - launch linux subsystem now and let it download all it need and set up your password (remember it ! you'll need this password later)
5 - Go in microsoft app store and download Ubunutu by canonical group limited
6 - Open ubuntu (a windows with your name and computer name wil appear), congrats you installed ubuntu on windows 10 !
Seting up you environment :
1 - Type "apt-get update" (will update all repo for apps and dependencies)
From here it is nearly the same as my previous guide, but be careful there is some little changes
2 - Type "sudo apt-get install -y build-essential kernel-package libncurses5-dev bzip2" (will install all dependencies to build kernel)
3 - Check if dependencies are correctly installed :
- Then type "gcc"
If "gcc" is already installed, you should see "gcc : fatal error : no input file"
- Then type "make"
If "make" is already installed, you should see "make: *** no target specified and no makefile found. stop."
- Then type "git"
If "git" is already installed, you should see bunch of basic git commands
Now you're almost ready to start building your kernel!
Toolchains:
There are several types of toolchains (GCC, Linaro and few custom made ones)
Warning : Not every single device kernel will boot (or even compiles) with older or newer GCC
- For ARM:
We'll be using GCC 4.7 in this tutorial (link : https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7/ )
-Open terminal and type: "mkdir kernel"(Type the name you want, I used "kernel")
-Then type "cd kernel" (the name which you used above)
-Then type "git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7"
-Wait till it finishes.
- For ARM 64:
For ARM 64 you need a 64 bit kernel compiler (there's "aarch64" in the name for telling that's a 64 bit compiler)
Exemple : https://releases.linaro.org/archive/13.07/components/toolchain/binaries/gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux.tar.xz
3.DOWNLOADING SOURCE FILES FOR YOUR DEVICE:​
Now you have to find a github that contains your kernel source.
Search on Google or XDA to find a kernel github repo for your device.
A kernel github looks like this: "https://github.com/atxoxx/android_kernel_samsung_msm8974/tree/xenomTW"
On the upper left side you can see branch: completed by a name
These are the different versions of the kernel/project (generally can be for testing, android version etc)
QUICK EXPLANATION OF FILES/FOLDERS:
- /arch/arm/configs : contains the config files for device (where you add option like new governors, features etc)
- /output/arch/arm/boot/ : Where zimage is stored (will explain that later)
- build.sh : Script to make the building much easier (will explain how it works later)
- /arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2 : I put the toolchain in my kernel source making it easier to find (your kernel's toolchain name may be different)
If you don't have your kernel source yet, you need to download it.
Open terminal and make sure that you are in "kernel" folder (the one you previously created)
Then type in terminal : "git clone "URL of the github kernel" -b "name of the branch" "
For Example : "git clone https://github.com/atxoxx/android_kernel_samsung_msm8974 -b xenomTW"
Good! Now you have your kernel source!
4.BUILDING:​
For an easier way you can go to the location using your file explorer to : "/home/"name of your session"/kernel"
You'll see two folders (The Toolchain and The Kernel Source)
Go into your kernel source folder.
- For ARM:
Copy paste this:
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm
export CROSS_COMPILE=$(pwd)/arm-cortex-linux-gnueabi-linaro_5.2-2015.11-2/bin/arm-cortex-linux-gnueabi-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For ARM 64:
Copy paste this:
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
mkdir output
make -C $(pwd) O=output "name of defconfig and variant if needed"
make -j4 -C $(pwd) O=output
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export ARCH=arm64: Defining which kernel architecture type it is (For example arm64 etc)
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- mkdir output: Create a directory for storing compiled zimage
- make -C $(pwd) O=output : Defining defconfig for guiding kernel compilation (will explain later)
- make -j4 -C $(pwd) O=output: where the building start, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
- cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage: This one is for moving image into the second path (thanks @Has.007 for this infromation)
Click to expand...
Click to collapse
Example :
#!/bin/bash
export ARCH=arm64
export CROSS_COMPILE=$(pwd)gcc-linaro-aarch64-linux-gnu-4.8-2013.07-1_linux\bin\aarch64-linux-gnu-
mkdir output
make -C $(pwd) O=output msm8974_sec_defconfig VARIANT_DEFCONFIG=msm8974_sec_ks01_skt_defconfig SELINUX_DEFCONFIG=selinux_defconfig
make -j4 -C $(pwd) O=output
cp output/arch/arm/boot/Image $(pwd)/arch/arm/boot/zImage
Click to expand...
Click to collapse
- For Mediatek:
Copy paste this:
#!/bin/bash
export CROSS_COMPILE="path to your toolchain" (it have to end by something like "nameofarch-something-")
export ARCH=arm ARCH_MTK_PLATFORM=
make "name of defconfig and variant if needed"
make -j4
Click to expand...
Click to collapse
Explaination:
- #!/bin/bash: Tells the script to run in shell command
- export CROSS_COMPILE= : Locate where the toolchain is, it has to match the exact path to it and the dash ("-") in the end is really important ! (Almost everyone makes an error at this part!!!)
- export ARCH=arm ARCH_MTK_PLATFORM=: Defining which kernel architecture type it is (For example arm64 etc) "ARCH_MTK_PLATFORM=" is for specifying which mediatek platform it is
- make _defconfig : Defining which defconfig to use (will explain later)
- make -j4: where the building starts, "-j4" is how fast it'll compile, you have to setup this number according to your CPU !
Click to expand...
Click to collapse
Example :
#!/bin/bash
export CROSS_COMPILE=$(pwd)/arm-eabi-4.8/bin/arm-eabi-
export ARCH=arm ARCH_MTK_PLATFORM=mt6580
make pixi4_4_8g1g_defconfig
make -j4
Click to expand...
Click to collapse
When these step are done make sure you are in kernel folder in terminal and type "sudo bash build.sh" then type your password you set up in first launch of linux subsytem
(sudo is important, windows 10 ubuntu seems to handle permission differently than native ubuntu)
The compilation have started
If it compiles without any problems:
Wait till it finishes (it'll say something like "zimage is ready")
If you followed arm and arm64:
Then go to "/Output/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
If you followed mediatek:
Then go to "/arch/arm/boot/" to find your zimage.
Click to expand...
Click to collapse
Caution : Not all kernel build Zimage, it can build image or other compressed image
If in case you have any errors:
Check and see what it says, generally it'll tell you where the error is.
If the text is going too fast reduce the -j number as explained above.
For reference I compile with an AMD Phenom X4 3.4GHz,Samsung HDD and 8GB of RAM and it takes around 10min to build
It is recommanded to type in the terminal "make clean" and "make mrproper" before compiling again​
5.MAKING THE KERNEL BOOT:​
You have 2 solutions here:
1) You can use @osm0sis anykernel method, which is explainded here: "https://forum.xda-developers.com/showthread.php?t=2670512" (A huge shoutout to him!)
OR
2) You can unpack the boot.img (from the same rom (CM, touchwizz,sense etc) and android version) and swap Zimage in it explained here : "https://forum.xda-developers.com/showthread.php?t=2073775" (thanks again to @osm0sis !)
Before flashing the kernel which you've made, backup your "stock" boot.img and Then flash your kernel and see if it boots!
6.HOW TO ADD FEATURE TO KERNEL WORK:​
Here starts the most interesting part! Now let's see how it works:
Basically you can add: Governors, IO Schedulers, Overclock the CPU & Many Tweaks...
Checkout the github section (Section 7) to see how to add them properly.
Here's an exemple for adding a governor (this one is called Intellimm) : https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
The text in the blue box is the commit description (generally tells you about the changelog, general information and who originally made the commit)
The other text boxes tell you about where and which files have been modified/changed.
Everything in green indicates what has been added.
Everything in red indicates what has been deleted.
We can see in the first 2 text boxes that in "arch/arm/configs/" "msm8974_sec_defconfig" and "cm_msm8974_sec_defconfig" have been modified.
Between the lines 140 and 141 of this files this text has been added : "CONFIG_CPU_FREQ_GOV_INTELLIMM=y"
(This line is for enabling Intellimm when you're compiling your kernel)
Same technique applies to the other text boxes (what has been added and deleted and it's location)
Depending on the features you add, more or less files can be modified, added or deleted.
So to sum it up, a Commit let's you see all the changes which have been made and everything else!
7.GUIDE TO GITHUB:​
For this, I'll direct you over to this awsome guide made by @eagleeyetom !
8.GPL (IMPORTANT !!!):​
The Rules as they apply on XDA
As XDA has no legal power to uphold the GPL (and frankly we want to stay as far away from doing so as possible), we can’t force any of our users to abide by the GPL. However it is in XDA’s interests as well as the interests of our developer-base to ensure all GPL-derived materials hosted or linked on XDA comply fully with the GPL.
GPL-derived materials that do not come with the complete sources used to compile the GPL components are considered warez, and will be treated as such under forum rule 6 and 9.
If you use GPL components, but do not make any modifications to them whatsoever, you should provide a link to the original source of your GPL code.
Sources accompanying a release should be complete, and contain all the necessary source code for any modules, scripts or definition files. Complete sources will be defined as those which compile correctly and completely against the platform for which the software is distributed, and which contain any and all modifications made to the released General Public Licenced code. The source code supplied should be the exact version for which the source code is being requested, complete with all modifications.
EXAMPLE: Here’s a bit of code that could be used as a template to post your releases
<Kernel Or Author Name> <Kernel Nr>:
<Source>|<ReadMe>|<Credits>|<Other>
The Very Quick Summary of General Public License (GPL)
The text of the GPL Licence itself will be used to reach any final conclusion regarding any disputes over GPL Licenced materials. The above is a summary of what XDA expects of members using GPL code, and the complete text can be read at the GNU website.
The GPL states that anyone who modifies GPL licenced code is required to make available the sources used to compile it. This is to further improve and encourage collaborative work, as well as to ensure that the best code possible is produced, and to encourage peer-review of all work. This benefits both developers and end users in numerous ways, including:
Allowing anyone to verify the code they are trusting with their data, and its authenticity
Encouraging community collaboration to produce faster fixes and updates, and better code
Helping bring new developments from other devices and fields to your own, letting you benefit from new code that wouldn’t have been available without this sharing.
The GPL imparts great freedom for GPL end users. It ensures innovation is never stifled and no project is dependent upon any single developer.
It is in everyone’s interest for the GPL to be adhered to, as it gives us all better ROMs, better transparency, and a better atmosphere for developers to work together to make great code.
Click to expand...
Click to collapse
THANKS :​
- @ravish_919 : For testing and correcting this guide
- @karkasss : As my friend and support
- @gugu0das : For helping me a lot when I tried to build my kernel
- @eagleeyetom : For his awsome github guide
- @osm0sis For his aswsome anykernel solution
- @kirito9 : Huge thanks to him for providing mediatek guide !
- @F4uzan : Huge thanks to him for giving me a lot of useful information to fill this guide !
- @sunilpaulmathew : For providing an advanced method to rename your kernel ! (again)
- @nathanchance : For a proper kernel naming method
- @RendyAK and @DroidThug : For correcting me about "#!/bin/bash"
- @ahmed.ismael : For helping me, giving feedback and his huge support !
- Microsoft and canonical for the windows linux subsystem documentation
- All the developers for their hard work !
- XDA and The Community!
TIPS AND TRICKS​
1. You can use a copy of a defconfig file with different setup :
Usage : Use a "stock" one and use another one with esperimental feature for testing without altering original defconfig
Exemple : copy "stock" defconfig and in copied one add a governor see if it compile and work
How to do : Create a second build.sh with modified defconfig name !
2. Change kernel name and version :
Simple method :​Edit this line "CONFIG_LOCALVERSION="-" after - in your defconfig
Exemple : CONFIG_LOCALVERSION="-XenomTW-3.2.6"
Advanced methods :​
Method 1 :
1. Go in Makefile in the root folder of your kernel source
2. Add
CONFIG_LOCALVERSION="nameofyourkernel"
LOCALVERSION="versionofyourkernel"
Click to expand...
Click to collapse
Exemple :
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
Click to expand...
Click to collapse
Caution ! Never touch or edit VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION !
Click to expand...
Click to collapse
Method 2 :
1. Go in "scripts/mkcompile_h"
2. Add
LINUX_COMPILE_BY="nameofyourchoice"
LINUX_COMPILE_HOST="nameofyourchoice"
Exemple
Click to expand...
Click to collapse
3. Solve problem with PATH :
If you encounter "IS YOUR PATH CORRECT" problem try in terminal :
"export PATH="pathtotoolchainlocation"/bin:$PATH"
Exemple : export PATH=/home/3lambda/kernel/M8_Kernel/arm-eabi-4.7/bin:$PATH
4. Access ubuntu folders :
Path location to ubuntu folder is : C:\Users"NAME"\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\rootfs\home
Caution ! Editing files here directly from windows may break permission, you'll have to fix them if so (look on google on how to)
More to come...
Edit and update are coming, I may have forgot things let me know
Feed back also appreciated
highly appreciated
thank you
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00
nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
would result in the following output:
Click to expand...
Click to collapse
Thanks for pointing this out
I'll take a look when I'll have time
Nice! Been looking for something like this. XDA feed brought me here.
is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!
tobarreh said:
is it necessary do in win10? or you can simply do it in linux pc without WIN10?
thanks for the post!
Click to expand...
Click to collapse
it should be done on linux
but windows can handle linux as a subsystem now so the guide for people like me who is dumb enough to use windows
seriously skip the ubuntu installation steps on sindows and start building your kernel by following the other steps :good:
Sent from my OnePlus 5 using XDA Labs
nathanchance said:
Good guide although I would say the advanced method for changing the kernel name is making totally unnecessary edits to the source code. There is already a framework in place for configuring the version string however you want. Editing EXTRAVERSION could result in conflicts during stable merges. The version gets generated in the following order:
Code:
$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(CONFIG_LOCALVERSION)$(LOCALVERSION)
VERSION, PATCHLEVEL, SUBLEVEL, and EXTRAVERSION are set in the main Makefile, the first three should never be touched. CONFIG_LOCALVERSION and LOCALVERSION should be what the user sets.
For example:
Code:
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 127
EXTRAVERSION =
CONFIG_LOCALVERSION="-FlashKernel"
export LOCALVERSION="-v1.00"
would result in the following output:
Code:
4.4.127-FlashKernel-v1.00
Click to expand...
Click to collapse
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
3lambda said:
Thanks for pointing this out
I'll take a look when I'll have time
Click to expand...
Click to collapse
Added new kernel naming method by @nathanchance and @sunilpaulmathew, huge thanks to them !
I'll need feedback see if some of these steps aren't clear or if I forgot things
I may also add a video soon and maybe screenshots
Stay tuned
sunilpaulmathew said:
I personally like to define "LINUX_COMPILE_BY" and "LINUX_COMPILE_HOST" in "scripts/mkcompile_h" just like in this commit by @franciscofranco. By adding this
Code:
LINUX_COMPILE_BY="francisco"
LINUX_COMPILE_HOST="franco"
would display "[email protected]"
Click to expand...
Click to collapse
He stopped doing that after I pointed out the same thing can be achieved without any source code edits (since it would change it for everyone building your source)
Code:
export KBUILD_BUILD_USER=francisco
export KBUILD_BUILD_HOST=franco
From: https://github.com/torvalds/linux/blob/master/scripts/mkcompile_h
If I downloaded a zip file of my source code, how do I extract it, since this is no longer just cloning from Git?
https://github.com/gugu0das/android...mmit/7186ee60c171b06ea3a027e8383be392d3186bb1
link is dead . please update this part of the guide as it is the most important part for me . Thanks for this awesome guide. more updates to come
I'm really looking forward to any and all updates on this thread. I'm old and loosing my mind and all my "Re-Memories" too, so I need all the help I can get.... LOL
permission denied
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
execute with 'sudo' make
otonieru said:
execute with 'sudo' make
Click to expand...
Click to collapse
that doesn't help, i did
kwshl said:
* placed the toolchain in home folder *
when i initiate compilation it says permission denied
how do i fix?
Click to expand...
Click to collapse
did you place it by doing a git clone or do a cp command ?
this will lessen the nuisance i hope
otonieru said:
did you place it by doing a git clone or do a cp command ?
Click to expand...
Click to collapse
[email protected]:/mnt/g/linux/oreo# bash k.sh
make: execvp: /home/kwshl/aarch64-linux-android-4.9/bin/aarch64-linux-android-gcc: Permission denied
HOSTCC scripts/basic/fixdep
HOSTCC scripts/basic/bin2c

Categories

Resources