[TUT] Building your own Xperia Play Kernel - Xperia Play Android Development

Since We have such a fantastic tutorial on how to build your own CM9, I thought I'd add one for building a kernel.
Edit: updated kernel sources for jellybean
First off:
You NEED Linux. DO NOT TRY THIS ON WINDOWS, IT WON'T WORK.
Sources: https://github.com/freexperia/semc-kernel-msm7x30-ics
https://github.com/DarkforestGroup/sony-kernel-msm7x30-ics
https://github.com/DooMLoRD/Xperia-2011-Kernel-2.6.32.9
http://forum.xda-developers.com/showthread.php?t=1556971
http://forum.xda-developers.com/showthread.php?t=1477845
http://developer.sonymobile.com/wp/2011/05/06/how-to-build-a-linux-kernel/
DooMLoRD, KeiranFTW & Atarii.
Prepping:
1) Grab the toolchain I have here (Android NDK R5b), it's the only one I've been able to use that doesn't throw errors when compiling: http://db.tt/hE3TmJJi Doom has provided a better toolchain https://github.com/DooMLoRD/android_prebuilt_toolchains[/QUOTE] you can get it using
Code:
git clone https://github.com/DooMLoRD/android_prebuilt_toolchains.git -b master
(thanks Doom!!)
Building a kernel from fxp sources
1) Terminal for any commands, file explorer for finding stuff & gedit for changes.
2) open up terminal, mkdir (no spaces)
3) cd
4) git clone https://github.com/CyanogenMod/semc-kernel-msm-7x30 -b jellybean (no spaces)
5) cd /semc-kernel-msm-7x30-ics (if you didn't rename it)
6) (If this is after the first time, and lets say a week has past do this step, otherwise ignore) git pull (automatically updates any files)
7) First important step: Find the defconfig that fxp uses. They are located in arch/arm/config. fxp_zeus_defconfig is the name of theirs
8) copy fxp_zeus_defconfig & rename to _zeus_defconfig (for example, mine will be pax_zeus_defconfig)
9) open up your defconfig & put it into another workspace, we'll mess with it later
10) Hop onto DooMLoRD's github, his we'll use for references.
11) Adding governors: https://github.com/DooMLoRD/Xperia-...mmit/bec19001ded34077d7776639834a1229b69e5f87
A1) Well, as I look into this, fxp has a ton of governors not used... (located in /drivers/cpufreq/
A2) Check the Kconfig file to see that they're all in there (they must just not be in the defconfig file)
A3) Edit the deconfig file you created in lines 467-474 removing "#" from any you want to add (and add in any you might've added by adding the line CONFIG_CPU_FREQ_GOV_=y
A4) If you want to add more governors, check out the Commits from DooMLoRD's build to add in when needed (anytime you see a "+" that means line added, "-" means line deleted)
12) Adding IO Schedulers: https://github.com/DooMLoRD/Xperia-...mmit/0ae625f7561c559d4933284f489733bf5eb66e96
B1) Navigate to /block folder
B2) Once again, FXP has a ton of IO Schedulers added, but not used in Play kernel:
B3) Open up Kconfig.ioshced to make sure they're in there (and add any you want)
B4) Edit the defconfig file you created (lines 121-137) & fix it to your liking (same as above)
B5) If you want to add more, see Doom's commits to add 'em
13) Turning off ALS
C1) Navigate to /arch/arm/mach-msm
C2) Open up board-semc_zeus.c
C3) Search for .als_connected (it on line 1349)
C4) Change the variable from 1 to 0
14) Overclocking
D1) open up arch/arm/mach-msm/acpuclock-7x30.c
D2) Lines 96 - 144 contain the PLL2 table, which is used to set clock speeds, note FXP can go all the way up to 2ghz, they just stop it short.
15) Building the Kernel
E1) Save your defconfig file, you'll need it now.
E2) naviage to folder (in terminal)
E3) Type in "ARCH=arm CROSS_COMPILE= ../ramdisk.img
F17) cd ../
17) Putting the ramdisk & kernel together
G1) By now (hopefully) the kernel is done compiling. (time for terminal, you should still be in folder you were above)
G2) cp ~//arch/arm/boot/zImage ./
G3) mkbootimg --base 0x00200000 --kernel zImage --ramdisk ramdisk.img -o .img
18) Flashing it for testing.
H1) Keep your copy of FXP's kernel around, just in case any issues happen
H2) fastboot boot .img
H3) If it boots & works, SUCCESS!! you modified your own custom kernel!
H4) If it doesn't boot (at all, just a vibrate & blank screen for 10-20 seconds) there's a problem with the ramdisk, sometimes it's bad, sometimes is needs filler, overall, it's just a pain in the butt to figure out.
H5) If it boots & bootloops the splash screen, well, that's an issue with the ramdisk again, that possibly, your ramdisk does not match you rom. Recovery, reflash rom & try again.
Courtesy of Atarii reminding me
19) Adding your wifi modules (they get built when you build the kernel) into the ramdisk
I1) Let's pretend that you haven't gotten through step F16, we're gonna add the wifi modules in.
I2) The wifi modules are located in /drivers/net/wireless/
I3) Copy bcm4329.ko to ~/ramdisk/working/modules/
I4) Add in the following lines to init.semc.rc
Code:
#load bcm4329 module
insmod /modules/bcm4329.ko
I5) Now your modules will autoload on boot!
Pax

Related

[Q] Help completing a10 allwinner kernel compiling guide

Hi all,
My aim has been to compile a kernel for an Allwinner a10 F1-LY tablet (pengpod 700) that features PS3 and other gamepad support. I can upgrade my ROM to Cyanogenmod 10 to achieve this but then the hard buttons and screen rotation stop working.
After days of searching, reading and testing, I feel like I am close but need help getting over the line. I am running a virtualbox installation of Xubuntu.
Once I have this running, I will contribute a guide with screenshots back to the community.
My steps:
0. My device is running this ROM, which is JB 4.1.1 with root and CWM 5.5 installed. The image is based on a Seby build, and modified by Magica.
1. Install virtualbox and then 32 bit Ubuntu 13.0.4. Make sure you have 3D acceleration enabled and a decent amount of RAM allocated or it will run incredibly slow.
2. Install guest additions and a shared folder with the windows host machine.
3. Install some packages for later use:
Code:
sudo apt-get install gedit git ncurses5 jre-default
4. Make a folder in the home directory to work from. Open a terminal in it and then install the kernal library:
Code:
git clone https://github.com/linux-sunxi/linux-sunxi linux-sunxi
cd linux-sunxi
git checkout sunxi-3.0
5. Install the cross compile tool chain.
Download http://www.codesourcery.com/sgpp/lite/arm/portal/package7853/public/arm-none-linux-gnueabi/arm-2010.09-50-arm-none-linux-gnueabi.bin
Install with:
Code:
sudo ./arm-2010.09-50-arm-none-linux-gnueabi.bin
6. Setup kernel config.
Code:
make ARCH=arm sun4i_crane_defconfig
make menuconfig ARCH=arm
The second line opens up a GUI for configuring the kernel, where I activated the following options using here as a guide::
Code:
--- Networking support <*>
Bluetooth subsystem support --->
<*> HIDP protocol support
Bluetooth device drivers --->
<*> HCI USB driver
[*] HID Devices --->
Special HID drivers --->
<*> Sony PS3 controller
<*> DragonRise Inc. game controller
[*] DragonRise Inc. force feedback
<*> Pantherlord/GreenAsia game controller
[*] Pantherlord force feedback support
<*> GreenAsia (Product ID 0x12) game controller support
[*] GreenAsia (Product ID 0x12) force feedback support
<*> SmartJoy PLUS PS2/USB adapter support
[*] SmartJoy PLUS PS2/USB adapter force feedback support
I'm not sure if my thinking is correct here, but I went through the config and changed any modular options to included, to avoid the need for additional files to be copied to the device.
7. Compile kernel:
Code:
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
This runs for a long time and will eventually produce a zImage file in the linux-sunxi/arch-arm-boot/ folder.
8. Get original boot.img from device.
To do this I booted into recovery mode and used the backup feature. This made a folder on my external SD card with boot.img and other archives. I then copied boot.img to the shared folder on my windows host.
9. Split original boot.img into zImage and ramdisk, replace zImage
Make a new folder in your home directory to keep this clean. Copy the original boot.img into this folder.
I downloaded and unzipped Adi_Pat's scripts from here. into the new folder.
The boot.img file will be unpacked with:
Code:
./extract.sh
Your zImage will be in kernel/zImage
Your ramdisk will be in ramdisk folder (unpacked)
Click to expand...
Click to collapse
I then deleted the zImage in the kernel folder and replaced it with the one compiled earlier from linux-sunxi/arch/arm/boot/. The ramdisk was left alone.
10. Modify script and repack boot.img
I'm aware that Adi_pat's script is for a different device, so I modified the pack_boot.sh script to suit the a10. Line 31 becomes:
Code:
./tools/mkbootimg --kernel kernel/zImage --ramdisk ramdisk.gz -o out/boot.img --base 0x40000000 --cmdline 'console=ttyS0,115200 tw init=/init loglevel=8' --pagesize 2048
This is based on searching and the the information given when running extract.sh. The updated script can now be executed:
Code:
./pack_boot.sh
A new boot.img is created at out/boot.img.
11. Put new boot.img onto device and flash.
I copied the new boot.img into my shared folder and then onto a SD card. Using a root file explorer on the device, move the boot.img file to the /sdcard directory. Open Novo7 tools and then go to the flash boot.img option.
12. Reboot device
When the device reboots, it hangs on the first Android logo, so clearly something has been done incorrectly. Fortunately I can recover to a working device from the backup in CWM recovery in just a few minutes.
Obviously I'm doing something wrong here, and would appreciate any pointers to get it working.
I have searched and read for days, so I am sorry if I have missed a thread that answers this for me.
Many thanks in advance.
lawgic said:
Hi all,
My aim has been to compile a kernel for an Allwinner a10 F1-LY tablet (pengpod 700) that features PS3 and other gamepad support. I can upgrade my ROM to Cyanogenmod 10 to achieve this but then the hard buttons and screen rotation stop working.
After days of searching, reading and testing, I feel like I am close but need help getting over the line. I am running a virtualbox installation of Xubuntu.
Once I have this running, I will contribute a guide with screenshots back to the community.
My steps:
0. My device is running this ROM, which is JB 4.1.1 with root and CWM 5.5 installed. The image is based on a Seby build, and modified by Magica.
1. Install virtualbox and then 32 bit Ubuntu 13.0.4. Make sure you have 3D acceleration enabled and a decent amount of RAM allocated or it will run incredibly slow.
2. Install guest additions and a shared folder with the windows host machine.
3. Install some packages for later use:
Code:
sudo apt-get install gedit git ncurses5 jre-default
4. Make a folder in the home directory to work from. Open a terminal in it and then install the kernal library:
Code:
git clone https://github.com/linux-sunxi/linux-sunxi linux-sunxi
cd linux-sunxi
git checkout sunxi-3.0
5. Install the cross compile tool chain.
Download http://www.codesourcery.com/sgpp/lite/arm/portal/package7853/public/arm-none-linux-gnueabi/arm-2010.09-50-arm-none-linux-gnueabi.bin
Install with:
Code:
sudo ./arm-2010.09-50-arm-none-linux-gnueabi.bin
6. Setup kernel config.
Code:
make ARCH=arm sun4i_crane_defconfig
make menuconfig ARCH=arm
The second line opens up a GUI for configuring the kernel, where I activated the following options using here as a guide::
Code:
--- Networking support <*>
Bluetooth subsystem support --->
<*> HIDP protocol support
Bluetooth device drivers --->
<*> HCI USB driver
[*] HID Devices --->
Special HID drivers --->
<*> Sony PS3 controller
<*> DragonRise Inc. game controller
[*] DragonRise Inc. force feedback
<*> Pantherlord/GreenAsia game controller
[*] Pantherlord force feedback support
<*> GreenAsia (Product ID 0x12) game controller support
[*] GreenAsia (Product ID 0x12) force feedback support
<*> SmartJoy PLUS PS2/USB adapter support
[*] SmartJoy PLUS PS2/USB adapter force feedback support
I'm not sure if my thinking is correct here, but I went through the config and changed any modular options to included, to avoid the need for additional files to be copied to the device.
7. Compile kernel:
Code:
make ARCH=arm CROSS_COMPILE=/root/CodeSourcery/Sourcery_G++_Lite/bin/arm-none-linux-gnueabi-
This runs for a long time and will eventually produce a zImage file in the linux-sunxi/arch-arm-boot/ folder.
8. Get original boot.img from device.
To do this I booted into recovery mode and used the backup feature. This made a folder on my external SD card with boot.img and other archives. I then copied boot.img to the shared folder on my windows host.
9. Split original boot.img into zImage and ramdisk, replace zImage
Make a new folder in your home directory to keep this clean. Copy the original boot.img into this folder.
I downloaded and unzipped Adi_Pat's scripts from here. into the new folder.
The boot.img file will be unpacked with:
Code:
./extract.sh
I then deleted the zImage in the kernel folder and replaced it with the one compiled earlier from linux-sunxi/arch/arm/boot/. The ramdisk was left alone.
10. Modify script and repack boot.img
I'm aware that Adi_pat's script is for a different device, so I modified the pack_boot.sh script to suit the a10. Line 31 becomes:
Code:
./tools/mkbootimg --kernel kernel/zImage --ramdisk ramdisk.gz -o out/boot.img --base 0x40000000 --cmdline 'console=ttyS0,115200 tw init=/init loglevel=8' --pagesize 2048
This is based on searching and the the information given when running extract.sh. The updated script can now be executed:
Code:
./pack_boot.sh
A new boot.img is created at out/boot.img.
11. Put new boot.img onto device and flash.
I copied the new boot.img into my shared folder and then onto a SD card. Using a root file explorer on the device, move the boot.img file to the /sdcard directory. Open Novo7 tools and then go to the flash boot.img option.
12. Reboot device
When the device reboots, it hangs on the first Android logo, so clearly something has been done incorrectly. Fortunately I can recover to a working device from the backup in CWM recovery in just a few minutes.
Obviously I'm doing something wrong here, and would appreciate any pointers to get it working.
I have searched and read for days, so I am sorry if I have missed a thread that answers this for me.
Many thanks in advance.
Click to expand...
Click to collapse
I am heavily into the allwinner tablets and would like to get CM10 install. I ran into the same issue until I build kernel 3.0.8 but you MUST put the generated NAND.KO file into the ramdisk folder and edit the init.sun4i.rc file to load it before anything else...this should get rid of the issue. I have a serial port I added to my tablet so Its a bit easier to troubleshoot and edit uboot vars when needed. If you would like to collaborate let me know.i have a 95% working android build environment that works for my tablet, only the gsensor is inverted which is a simple fix.
Michael Pizzileo
BinaryDroid
I am working with a Polaroid Tablet (pmid10c) and have been attempting to build and install a newer kernel with no success. Any help/guidance would be great. I am currently working in this thread: http://forum.xda-developers.com/showthread.php?p=46685741#post46685741 please chime in with any advice you may have.
Thanks

[TUT] Introduction into Kernel development

INTRODUCTION INTO KERNEL DEVELOPMENT
PREPARATION
This guide is NOT a full development tutorial! For development of kernels you should be familiar with C. I cannot teach you full C - would be too much for me - but I can show you how to prepare a build environment especially for RAZR Kexec Kernel building! At the end you will find some first steps about how to develop a kernel.
As soon as you have a full dev setup you will be motivated to proceed with learning C - hopefully
For me it worked!
The reason is that I would like to see more people giving it a shot! Kexec is wondeful and it would be great if there are some more people working on kernels.
Please leave me some credits if this tutorial helped you wherever you provide your work! THX!
OVERVIEW
1. Install Linux
2. Setup build environment
3. Initialize Kernel Source
3.1 Branches
3.2 How to compile a kernel
4. Create your first development branch (Add a new Governor)
5. Git Commands
I will tell you the way I started once and guide you through the preparation.
It's important to know how to setup a build environment! The best way to learn about kernel development is to learn by practice!
How to setup a build environment
1. INSTALL LINUX
I suggest Linux Mint 15 Cinnamon (or Linux Mint 15 Mate is good for older for low-spec Systems) - it's free and very easy to install near Windows 7 (dual boot). After the installation you will have a very Windows-like desktop environment which is easy to handle also for beginners. Then you need to learn the Linux Shell!
*of course you can install any other Linux, like Ubuntu. Linux Mint is based on Ubuntu 13.04 and I use it as well.
If your CPU supports 64 bit you should install the 64 bit version! This is impossible also later when it comes to install libraires for development, etc. There are mostly two versions, whether for x32 or x64.
After the installation of Linux you need to imstall related software and depencies.
2. SETUP BUILD ENVIRONMENT
Now, Linux is installed, we begin to setup the build environment.
First install Git which is the main part for using services like Github, etc..
We will install also adb and fastboot!
NOTE
The main installation command for packages in Linux is:
apt-get install (mostly used with 'sudo' ("superuser doers" - admin), then it will be:
sudo apt-get install package-name
You can combine one command to imnstall multiple packages, like:
sudo apt-get install package-name package-name ...
It doesn't matter how much names you enter!
NOTE: Sometimes you will have to confirm the installation of a specific package, means it will ask you for proceed (e.g.: ...this will take xx mb of space (J/n) ?).
Press "j" and enter in this case.
Click to expand...
Click to collapse
Let's start!
Open a shell (terminal) and type:
Code:
sudo apt-get install git android-tools-adb android-tools-fastboot
(you will have to enter your password. Keep in mind that you won't see any input when typing passwords in Linux!)
Now you have installed adb, fastboot and Git!
After this you need to create a working space which means you have to download the full Android source to be able to build your kernel later.
Still in Terminal make sure you're in your user root directory (just type "cd" to get back into your root dir). Now you have to create a new directory for Android sources. Therefor we use the "mkdir" command (make directory). We need to create a folder structure, so we create another folder inside of your new folder:
Code:
mkdir android
cd android
mkdir system
NOTE
This will create: /home/android/system
There is a simpler way to create a folder structure by using on single command. Just add a "-p" to the mkdir command to create multiple directories:
Code:
mkdir -p ~/android/system
NOTE
The "-p" lets you also create directories while being somewhere else!
The "~" symbol is a placeholder for your home folder! It tells the terminal that you want to create the folders in your "home" dir. For better understanding I'll show you the command w/o the placeholder again:
mkdir -p /home/android/system
Click to expand...
Click to collapse
Now you have install the depencies (libraires, etc, needed for compiling Android). So you are still in your terminal and type:
Code:
sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.8-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev openjdk-6-jre openjdk-6-jdk pngcrush schedtool libxml2 libxml2-utils xsltproc
NOTE
These depencies are for 32 bit & 64 bit systems!!
Click to expand...
Click to collapse
Now we need some additional libs because we are using a 64 bit system. Still in terminal install them by using the apt-get command. I will only show you the package names now, so you can practice and see if you have understood it. Install these:
Code:
g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib
NOTE
You can simply use copy&paste
Click to expand...
Click to collapse
Next step is the creation of the repo base directory. It is needed by the repo software which lets you control and use the git repositories on your local machine (your computer). Use the "mkdir" command to create the following directory:
Code:
mkdir -p ~/bin
Now you have to install the "repo command". It's a binary file, so you have to make it "executable" (runable) by using the "chmod" command. Chmod is similar to the "set_perm("...")" command used by updater-scripts (EDIFY script language). It just sets the permissions of a file, i.e. to allow the execution of this file or to make sure the file can be accessed by any people or other programs.
Enter the following to download the "repo" binary and make it executable (runnable):
Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
NOTE
It would be too much to explaing stuff like "Curl", etc..
Click to expand...
Click to collapse
Now we have to make sure that we can call "repo" from anywhere. This means if you're in terminal in for example: $ /home/Downloads and you type "repo" it will tell you usually that "repo" is an unknown command. To avoid this we need to make it generic by adding "repo" to your static PATH (Path of execution). The command:
Code:
export PATH=${PATH}:~/bin
NOTE
if you set an "export" for anything (lkie repo) in your terminal, it will be gone as soon as you exit the terminal or also after a reboot. To keep it in your PATH forever you have to add the "export" to your bashrc file (this file stores your preferred Path commands, it's like a list where you can add whatever you need) to make this change to the path permanent for all future Terminal sessions:
Code:
gedit ~/.bashrc
This will launch a graphical text editor (if it doesn't work, try it with "sudo"). Just copy&paste the following line into it, save it and close:
Code:
export PATH=${PATH}:~/bin
Click to expand...
Click to collapse
Fine! So far we are prepared! Now we have to download the android source!
Still in terminal, type:
Code:
cd ~/android/system/
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
NOTE
"repo init" initializes a repository oy your PC
the Git address is the link to the CM source code repo. YOu just told the computer that you just initialized a CM Git repo in the specifi folder /android/system
Click to expand...
Click to collapse
.
To start the download of all the source code to your computer:
Code:
repo sync
NOTE
This process can take a very long time - depends on your internet connection speed. The source is about 10 GB!!
"repo sync" will be your further command to keep the rpo up-to-date! Just enter it while being in the root dir of the android source (/android/system) at least once a day!
Click to expand...
Click to collapse
Now, when the download has been finished we have to download the prebuilt apps (like terminal emulator, etc):
Code:
cd ~/android/system/vendor/cm
then enter:
Code:
./get-prebuilts
Now there are the vendor files needed! There are two ways to do that: The "easy" way and - sometimes it doesn't work, then you have to use - the "harder" way.
The easy way:
Code:
source build/envsetup.sh
breakfast spyder
NOTE
this will usually download the vendor files (motorola speific device drivers). If you get an error message you have to use the second way (harder way).
Click to expand...
Click to collapse
Click to expand...
Click to collapse
The harder way:
cd to you vendor dir and clone the proprietary files manually:
Code:
cd ~/android/system/vendor
git clone https://github.com/Motorola-OMAP4-CM/proprietary_vendor_motorola.git -b cm-10.2
NOTE
"git clone" will be used always when you want to download a git repository to your computer, so you can work with it locally. e.g on Github.com there is always a clone URL given at the right side of the repo. Just type "git clone <link>" into the terminal to clone this repo.
Click to expand...
Click to collapse
Now open the file explorer (whether by using the mouse or in terminal: nautilus (maybe you you have to install this first) and head to /android/system/vendor.
You will find a folder called "proprietary_vendor_motorola".
Just rename it to "motorola".
NOTE
In the future, everytime you update your repo (repo sync) you will have to update the vendor repo too. Perform this by using "git remote update" command in terminal. Therefore you have to be in /android/system/vendor/motorola, and type:
Code:
git remote update
git pull
Click to expand...
Click to collapse
Congratulations! You have successfully setup your Android build environment!
Now we need the kernel source!
3. INITIALIZE KERNEL SOURCE
So you learned some basics about Git! Proof that you understand it and clone the kernel source repo to your PC! I'll give you the links but you have to clone it yourself! Use the clone URL you find at the following Github repo. Make sure you are NOT cloning into your Android source dir /android/system!)
The source for our 3.0.8 Kernel:
www.github.com/CyanogenMod/android_kernel_motorola_omap4-common
NOTE
Too hard? Let me help you (You can even copy&paste my stuff - but for real learning experience you should try to make it on your own)
Head into this dir:
Code:
cd ~/android
Clone the kernel source:
Code:
git clone https://github.com/CyanogenMod/android_kernel_motorola_omap4-common.git
The new folder will be: ~/android/android_kernel_motorola_omap4-common where your kernel source sits.
When done, you have successfully loaded the kernel source! Fine!
3.1 ---> BRANCHES
Now I am going explain you something about "branches" and how to use them!
A "branch" is a part of almost all git repos. It is very important and also very useful to work with branches!
A typical repository looks like that:
[CODE GIT REPO
|
master branch
/ \
/ \
branch: Test branch: Stable
\ /
\ /
\ /
MERGE changes[/CODE]
The repo contains mostly multiple branches. There is always the "master branch" (can have another name of course, branches can be named like you want) and some lower branches.
The "Master branch" is the main branch!
All other branches are custom and mainly used to test new code or sth else.
Let's say we have a kernel repo! This repo contains the JBX-Kernel. The master branch contains the current STABLE Version of the kernel. Now we want to implement a new feature. But when we use the master branch for development (which is sometimes an experiment) we could potentially break the kernel or its source and make it becoming unusable. Therefore we can use a different branch.
NOTE: A branch is always a copy of this branch where you are while creating a new branch! This means when I am currently in the JBX-Kernel master branch, and I create a new branch from there, then I will get a new branch which includes a full copy of my JBX-Kerne master branch. -- But I can work with it without being scared about breaking my repo!
Then many devs are using a "Merge branch". There we could in example copy all changes (which have been tested successfully before) together into a new branch. This process is called "merging".
Let's say we have finished our new feature inside of a test branch. Now the feature is ready to be built in into the Stable Kernel. Then we merge the test branch into the master branch. Thsi results in an updated master branch which now includes our new feature!
Another possibility to use branches can be found if you want to split our repo into different systems, such like the CM kernel source contains branches for CM10.1 and CM10.2. So there is a branch calld "cm-10.1" and another branch called "cm-10.2".
When you look at the part where we initalized the CM repo, you might notice that the repo URL includes this:
repo init -u git://github.com/CyanogenMod/android.git -b cm-10.2
The line marked with red in the URL points to a specific branch, the cm-10.2 branch.
Now we are still in the kernel source dir!
Because you want to build a 4.3 Kernel we need to be in the right branch for this! There are already branches exisiting in the kernel source (like explained above), it's splitted into different versions (4.2.2 and 4.3).
Still in terminal be sure you're inside your kernel source root dir (~/android/android_kernel_motorola_omap4-common), type:
Code:
git checkout cm-10.2
NOTE
"git checkout" is the command to switch to another branch. But it's also used to create or delete branches. More about that later...
Click to expand...
Click to collapse
The output in the terminal will tell you sth like: "Switched to branch cm-10.2"
(if it's the first time you enter a branch it will download the files first and tell you: "Switched to a new branch cm-10.2". Don't be confused by this. If you try to enter a non-existing branch it will give you an error).
Now you are in the kernel repo, in the 4.3 branch!
Before we start to play with the source code I will show you how to build a kernel! As long as the kernel source is untouched you can be sure that it will work! Also this will make sure you have done everything right so far - as soon as the kernel boots you've built!
3.2 HOW TO COMPILE A KERNEL
To get a first impression about how to build the kernel, please have a deeper look at my personal JBX build script:
https://github.com/RAZR-K-Devs/android_kernel_motorola_omap4-common/blob/JBX_4.3/build.sh
The script is very simple and contains only a few commands which can be used in the terminal as well. For your the script is only interesting until the poiont where it says: "make -j4 TARGET_KERNEL_SOURCE=/home/dtrail/android/android_kernel_motorola_omap4-common/ TARGET_KERNEL_CONFIG=mapphone_OCE_defconfig $OUT/boot.img"
Since the latest Android version and the modified kexec stuff it's not enough anymore to build the kernel only. The PVR source has been moved into the Android source and it must be built together with the kernel in order to get a working (booting) kernel! That's why I don't show you the common way.
In fact you can now build your kernel by taking my build script commands, and enter them - one by one - in your terminal. BUT you have to modify the paths because script was made for use on my computer (so, you probably are not called "dtrail!" ). You have to start in your kernel source dir (this is the location where my build script is being executed). To make it easier for you, I have pasted the script here and changed it so it will work for you. I have removed all comments and echo (output) commands so there are only the related build commands left. I just added comments just for you:
Code:
# THESE LINES (those beginning with #) ARE COMMENTS!!!
# Be in your kernel source: /android/android_kernel_motorola_omap4-common
# this command cleans all leftover files from prior compile (needed)
make mrproper
# We build the kernel and its modules
# enter the Android source dir
cd /android/system
# This command makes sure to use the additional build cache. It will make all fufutre build processes MUCH faster! (YOu have to install ccache first by using apt-get)
export USE_CCACHE=1
# Clean also the Android source dir
make mrproper
make ARCH=arm distclean
# Tell the compiler that we want to build now
source build/envsetup.sh
# Tell the compiler which device we want to build for
lunch cm_spyder-userdebug
# built kernel & modules (This command includes the full path to the kernel course and the used kernel config)
make -j4 TARGET_KERNEL_SOURCE=/home/YOUR_USERNAME_HERE/android/android_kernel_motorola_omap4-common/ TARGET_KERNEL_CONFIG=mapphone_mmi_defconfig $OUT/boot.img
After you entered this your computer will start building. The first compiling process will take longer! But future bui9lds will be built much faster thanks to the use of CCACHE!
CONGRATULATIONS!! You built your first kernel!!
Now we have to create a flashable zip file and flash the kernel to see if it works. >The advanced Linux users from you should have another look into my build script I linked above, there you can see how it automaticall pushes (copy) the fiules into a prepared folder which includes everything needed for a flashable zip and compresses it to a ready zip file!
Other less experienced users can just download my latest JBX-Kernel, unpack it, delete "logo.bin" and do this:
go to (by using mouse or terminal):
Code:
/android/system/out/target/product/spyder
There you will find a file called "kernel" - this is your fresh compiled kernel! Copy it to the unpacked JBX-Kernel folder, into:
Code:
.../JBX-Kernel_whatever.../system/etc/kexec
(and overwrite the previous kernel in there)
Now go to:
Code:
/android/system/out/target/product/spyder/system/lib/modules
There are all the modules you've just built. Copy them to:
Code:
.../JBX-Kernel_whatever.../system/lib/modules
Now compress the folders to a new zip file, copy it to your phone and flash it in recovery!
4. CREATE YOUR FIRST DEVELOPMENT BRANCH (add a new Governor)
to create a new branch locally, be in terminal inside the root of your kernel source, and type:
Code:
git checkout -b BRANCH_NAME
Replace BRANCH_NAME with whatever you want!
Now you created and switched to your new branch! Here you can start plaing with the files!
To develop Linux kernel (Android IS Linux!) you will have to learn C! The kernel is developed in pure C which is the best programming language for drivers (machine controlling).
if you're German I can suggest your the "open Book - C von A bis Z" (Galileo Computing, gratis).
Otherwiase just google for free C books or tutorials.
Take your time, this is not easy in the fist place - but as soon as you are more experienced you will find it more easy!
The best way to learn it is to read and browse others Kernel repos! You are always free to watch my JBX-Kernel Repo! Read the commit messages to see what this commit is for and look at the code-side changes! If you read carefully, and learn C at the same time, you will understand the commits, step by step.
Let me give you some more hints:
Set you some smaller goals and start to reach them one by one! Don't set yourself too high goals, otherwise you will make yourself too much pressure!
Small steps are the way to your success!
Some of you might only want to make some minor changes, such like adding new governors, etc. Therefor you can i.e. use google to find related commits. So open Google and type:
Code:
github kernel omap add governor
We hope that google will show us some repos where the dev(s) wrote commit messages like "Added XXX governor", etc, etc..
In this example Google will put out this:
https://www.google.com/search?q=github+kernel+omap+add+governor
If you click the link you will find the very first result, which leads us to:
https://github.com/broodplank/glass-omap-xrr02
There click on Commits and you will see a commit "Add SmartassV2 governor". Now open this commit, you will find this:
https://github.com/broodplank/glass-omap-xrr02/commit/f959e0e8c16412319e991b26aaa50d8fe3555a4e
There you can see now the FULL commit with all its details! It shows you exactly how to add a governor! The green parts are ALWAYS insertions on Github, while red parts are deletions! SO you can see exactly:
1. WHICH files have been changed
2. WHAT has been changed in these files
3. WHERE in the files were the changes made
4. HOW were these changes performed
Now, if you study this commit for a while, you might know what has to be done in order to add a new governor!
NOTE: The very long files which are COMPLETELY green are NEW FILES!
Let's say you want to take this SMartassV2 governor into your kernel:
You can do it with different ways.
1. Cherry-Pick
For this weay you have to add the "glass-omap-xrr02" repo as remote to your repo. So you get the clone URL and use the git remote command (in your kernel root dir with terminal):
Code:
git remote remove upstream
git remote add upstream https://github.com/broodplank/glass-omap-xrr02.git
Now we must fetch the repos content:
Code:
git fetch upstream
Wait until the fetching process is finished.
Now we need the SHA1 sum of the commits. You go to your browser and look at the commit. The SHA1 is a very large number you can find at the upper right.
In this case this is the SHA1 for the commit "add SmartassV2 governor":
Code:
f959e0e8c16412319e991b26aaa50d8fe3555a4e
So, we need to cherry-pick this commit by typing in the terminal:
Code:
git cherry-pick f959e0e8c16412319e991b26aaa50d8fe3555a4e
Now there are three possibilites! If you see a message about "...conflicts" then it didn't work correctly because your local kernel source files might be a little bit different than those from the remote repo. In this case you open these files with a text editor (gedit) and find the lines with the errors, they are looking like this:
Code:
<<<<< HEAD
..some code...
>>>>>> Add SmartassV2 governor
Compare the files to those in the remote commit in your browser qand correct the issues or just this:
Code:
git cherry-pick --abort
This reverts your cherry-pick and your files are clean and like they were before the cherry-pick!
YOu can add the governor manually by simply looking the remote commit in the browser and copy the green stuff into your local files. Make sure you insert the codes in the right places!!! When you copy it from the green parts you will have to remove EVERY SINGLE "+" at the beginninf of each line!
There is another view in github for files, called "RAW". This will shows the pure file - but also without green/red marks! But in case you add the SMartassV2 governor, you can just search for the keyword "smartass" in the raw view of the file and then copy all lines which are including "msartass" into your local files
The governor itself is a complete new file, so you canswitch to the raw view, right click --> select all --> copy. Then create as new file in the right location (/kernel_source_dir/drivers/cpufreq/cpufreq.c) with the same name like in the commit (cpufreq_smartassv2.c) and paste the whole code into it, save and close.
Don't forget the rest of the code in the other files!!
At last you have to insert the new governor into your kernel configuration! The kernel config is mostly a "defconfig" file!
ALl the related defconfigs we need are located in:
Code:
.../arch(arm/configs
The default defconfig for our RAZR is the:
Code:
mapphone_mmi_defconfig
The defconfig file inlcudedes everything which is built into the kernel later. If you search for keyword "GOV" you will see the other governos, like Hotplug, etc.. YOu can see how they are used in the defconfig file, so add your new governor the same way. This should be:
Code:
CONFIG_CPU_FREQ_GOV_SMARTASS2=y
# CPU_FREQ_DEFAULT_GOV_SMARTASS2 is not set
*The second line is for setting it as default governor.
Thats was it! Now make sure everything was done the right way, save and close all files. In terminal type:
Code:
git status
This shows you info about the current status. In this case it will show you the changed files and the new file(s) in red color.
Now you have to stage your commit:
Code:
git add .
Adds all new/changed/untracked files to the commit, then:
Code:
git commit -m "Added Smartassv2 governor"
Done! Your new commit is staged to the index and can be uploaded! (Uploading is not part of this at the moment! If you want to learn more about git, use Google)
Now repeat the compile process like you did already! See if your new governor is included and working.
For further learning it's a good way to proceed with learning C and read, compare and understand commits from other devs/repos.
Ok, guys! I hope you enjoy the guide and it's helpful for you! I will extend/fix/correct this time by time... for now I'm done!
5. GIT COMMANDS
Here are some basics about using git by Terminal:
git branch -D BRANCH_NAME - Delete a branch
git branch -b BRANCH_NAME - create a new branch (but don't switch to it)
git checkout -b BRANCH_NAME - create & switch to a new branch
git checkout BRANCH_NAME - switch to a exisitng branch
git push origin BRANCH_NAME - upload your changes to your repo on Github (You have to be in that branch you are also uploading to!)
git remote update - checks for the latest changes in the original repo (that one where you took the source)
git pull - after you used "git remote update" use "git pull" to download the changes to your computer
git diff BRANCH_NAME - shows differences between the current branch and any branch
git add . - Adds all your changed files to the index (this is important to upload your changes)
git commit -m "this is my commit message" - USe this after "git add ." to append a message to your changes, so other devs can
see why you did it, etc..
git log - Shows the commit history (the history of changes in this repo) inlcuding the related SHA1 for each commit
git revert SHA1 - this reverts (undo) one spedific commit. The SHA1 sum can be found near the commit messages (whether you
can look the with your browser or by us ing "git log")
git remote remove upstream - Removes the current upstream repository
git remote add upstream <git URL> - Adds a new upstream, useful if you want to take over changes from another repos/devs
git fetch upstream - get the new remote repo's content
git cherry-pick SHA1 - this picks one single commit from your current upstream repo - or from another branch
git cherry-pick --abort - This aborts your curerent cherry-pick, useful if you run into conflicts
Click to expand...
Click to collapse
If you find any mistakes or somethings missing in your mind, PM me or post it here.
Please leave me some credits if this tutorial helped you wherever you provide your work! THX!
CREDITS
*Cyanogenmod - took some single infos from their website
How to build Cyanogenmod for Droid Razr (website):
http://wiki.cyanogenmod.org/w/Build_for_spyder
*Hashcode - for being always helpful and supportive and of course for his great work with dhacker
*Linux, Google, XDA-DEVELOPERS
-- reserved --
Another reserver
MINE
Great write-up @dtrail1,
And I completely agree. I'm always hoping for more devs to jump into kernel development to learn and have fun with their devices.
Deffinitely interested in this. Il be hitting this guide up soon as I pick a better internet provider for Repoing.
Saving your book
Sent from my XT910 using xda app-developers app
Thanks for the write up .
Sent from my XT912 using XDA Premium 4 mobile app
Thanks. Perfect for youngsters like me
Sent from my XT910 using Tapatalk 2
Corrected a typo where a .git extension was missing (and users might not be able to clone the repo without it)
umts_spyder
Thank you dtrail1 for the great guide.
as XT910 owner, i guess that everywhere I see spyder in the code, I should replace it with umts_spyder ?
tester5224 said:
Thank you dtrail1 for the great guide.
as XT910 owner, i guess that everywhere I see spyder in the code, I should replace it with umts_spyder ?
Click to expand...
Click to collapse
No, just use the SPYDER source - otherwise your kernel won't support LTE for the CDMA users. The LTE modules are only built with the SPYDER source, that's why we use it.
But you can repeat these steps with UMTS_SPYDER, it will only download the UMTS depencies then, so you are able to build CM10.2 for the XT910. For the kernel only use SPYDER source.
dtrail1 said:
No, just use the SPYDER source - otherwise your kernel won't support LTE for the CDMA users. The LTE modules are only built with the SPYDER source, that's why we use it.
But you can repeat these steps with UMTS_SPYDER, it will only download the UMTS depencies then, so you are able to build CM10.2 for the XT910. For the kernel only use SPYDER source.
Click to expand...
Click to collapse
So if I understood correctly, the GSM\UMTS and LTE\CDMA are using the same kernel in CM ?
thanks for the reply
tester5224 said:
So if I understood correctly, the GSM\UMTS and LTE\CDMA are using the same kernel in CM ?
thanks for the reply
Click to expand...
Click to collapse
If I understood it correctly in the normal cm there are two different kernels. One for gsm without LTE modules and one cdma with LTE modules. So in case want to build for both you need the cdma version as it has the LTE modules and so cdma users have LTE and as usually gsm users will have there normal network.
Sent from my XT910 using XDA Premium 4 mobile app
Para94 said:
If I understood it correctly in the normal cm there are two different kernels. One for gsm without LTE modules and one cdma with LTE modules. So in case want to build for both you need the cdma version as it has the LTE modules and so cdma users have LTE and as usually gsm users will have there normal network.
Sent from my XT910 using XDA Premium 4 mobile app
Click to expand...
Click to collapse
No, the kernel has no differences! It's about the modules. The kernel is always the same but the mlodules are not. If you build the kernel with UMTS_SPYDER depencies you will get umts baseband modules only. But if you build it with the SPYDER source you will get a working modules for umts and cdma.
:good: got it, thanks
tester5224 said:
:good: got it, thanks
Click to expand...
Click to collapse
It's special for our device. Usually it's enough to build the kernel only w/o using the full 15GB rom sources. But since 4.2.2 some parts of the kernel source were moved into the android rom source (e.g. the PVR (SGX) Sources), so we have to use the full rom source to build a working kernel - otherwise your kernel will cause a black screen on boot.
@dtrail1 Question regarding the script you use to build the kernel.
Your script shows: make mrproper
When I run this command I receive an error message: make: *** No rule to make target 'mrproper'. Stop.
Do you have any advice on where I set the target?
Edit: After continuing with the remainder of the script the last error I receive is: make: *** Waiting for unfinished jobs....
This command is needed to clean out the source directories. The error message is normal, just don't care about.
The second error you wrote about sounds like you tried to build without defconfig.
Make sure you have all related "export" commands AFTER the mrproper/distclean commands.
If you did so, then the error is caused by something else. Please post me the full last few lines of your terminal output, then I can tell you more.
Gesendet von meinem XT910 mit Tapatalk 4
awesome guide brother. thank you. i ll give it a try today

Help adding CIFS support to kernels?

Often I find myself really liking a particular kernel for a particular device. The common problem I have found is that no CIFS support is added to the kernel.
I have donated to several kernel devs. I don't expect anything from them, I just wanted to show my appreciation.
However, usually my CIFS inquiries go unnoticed.
I would like to add CIFS support to other people's kernels for my personal use on my device.
I presume I will have to decompile and recompile kernels in the process?
Here is the specific case that I have :
Current setup:
Phone - Verizon Galaxy Note 2
ROM - Beans build 22 (Touchwiz)
Kernel - Perseus 36
I would like to use Imnuts' PBJ kernel. It doesn't support CIFS, whereas Perseus does.
So in theory I could extract the CIFS modules and inject them into PBJ? Any ideas? Any help would be appreciated. I would also be willing to donate to someone willing to build one for me (mods, let me know if that isn't cool to mention. ) I don't have a Linux box or the current means of acquiring a Linux box until early next year. I am curious if this can be done on Windows 7?
xdadevnube said:
Often I find myself really liking a particular kernel for a particular device. The common problem I have found is that no CIFS support is added to the kernel.
I have donated to several kernel devs. I don't expect anything from them, I just wanted to show my appreciation.
However, usually my CIFS inquiries go unnoticed.
I would like to add CIFS support to other people's kernels for my personal use on my device.
I presume I will have to decompile and recompile kernels in the process?
Here is the specific case that I have :
Current setup:
Phone - Verizon Galaxy Note 2
ROM - Beans build 22 (Touchwiz)
Kernel - Perseus 36
I would like to use Imnuts' PBJ kernel. It doesn't support CIFS, whereas Perseus does.
So in theory I could extract the CIFS modules and inject them into PBJ? Any ideas? Any help would be appreciated. I would also be willing to donate to someone willing to build one for me (mods, let me know if that isn't cool to mention. ) I don't have a Linux box or the current means of acquiring a Linux box until early next year. I am curious if this can be done on Windows 7?
Click to expand...
Click to collapse
There may be a simpler method of doing this using insmod and downloadable cifs.ko module rather then taking the developers kernel source and then compiling it to include the cifs.ko module, using the following steps:
1. Make sure you have the latest version of Busybox installed
2. Download this .7z file and extract it's contents the modules you want are md4.ko and cifs.ko (Even though the .zip says Nexus 10 it should still work on your device).
3. Take the md4.ko module and cifs.ko module and place them in your /system/lib/modules folder (Make sure to mount the /system folder as read/write first and if the /system/lib/modules folder doesn't exist make sure to create it and set the proper permissions which should be the same as the /system/lib folder).
4. Now that you have placed the md4.ko and cifs.ko module in the /system/lib/modules folder run the following command:
Code:
insmod /system/lib/modules/md4.ko
insmod /system/lib/modules/cifs.ko
5. After that completes you should now be able to use the cifs.ko module to perform your desired task.
Let me know if you still have questions I'll be happy to help you out.
shimp208 said:
There may be a simpler method of doing this using insmod and downloadable cifs.ko module rather then taking the developers kernel source and then compiling it to include the cifs.ko module, using the following steps:
1. Make sure you have the latest version of Busybox installed
2. Download this .7z file and extract it's contents the modules you want are md4.ko and cifs.ko (Even though the .zip says Nexus 10 it should still work on your device).
3. Take the md4.ko module and cifs.ko module and place them in your /system/lib/modules folder (Make sure to mount the /system folder as read/write first and if the /system/lib/modules folder doesn't exist make sure to create it and set the proper permissions which should be the same as the /system/lib folder).
4. Now that you have placed the md4.ko and cifs.ko module in the /system/lib/modules folder run the following command:
Code:
insmod /system/lib/modules/md4.ko
insmod /system/lib/modules/cifs.ko
5. After that completes you should now be able to use the cifs.ko module to perform your desired task.
Let me know if you still have questions I'll be happy to help you out.
Click to expand...
Click to collapse
I'm trying to do this on my Nexus 10 with stock 5.1.1 rooted and busyboxed but i get the following error when attempting to insmount the modules:
255|[email protected]:/ # insmod /system/lib/modules/md4.ko
insmod: init_module '/system/lib/modules/md4.ko' failed (function not implemented)
Click to expand...
Click to collapse
modules folder and files are chmod 777, btw.
Did you ever find a solution to this? I'm stuck at the same error message.

[HOW-TO] extract kernel from source, compile, and insert on GPE (510)

How to extract the boot image from your tablet, set up adb, compile a new kernel with cool options, and put it back on your device!
UPDATED for Lolipop 12-4-14
This is a complete guide from start to finish, copy and paste style. If you own a gpe510, or any other AOSP device and a computer running Debian Linux, you can do all of this.
If all you want is the modified kernel, download from here:
Sleekai Kernel For The LG GPad 8.3 V510(GPE)
​
I am hoping people will add to this with new ideas and patches in order to make the GPE a better device. I see the potential for all sorts of neat stuff.
This guide assumes a basic knowledge of linux operating systems. I am using a Debian 64 bit (wheezy stable) to compile my kernel. I have used many, many hours of the day to figure this out properly, with specific thanks going to Pete of Pete's Blog for his image tools.
But first, lets keep this simple. As usual, you are on your own if you brick your device, though I don't see how you could if you are paying attention!
There are dependencies for building your own kernel, and you will definitely want to use a 64 bit system as a 32 bit will not work properly for kitkat.
Here are all of the packages you will need, and they will draw in further dependencies when you install, but these are it! So, here we go:
Open a terminal, su to root and:
Code:
dpkg --add-architecture i386
##This will allow for the use of some 32 bit librarys that we will need for both adb and the kernel compile. Then:
Code:
apt-get update ; apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 libc6-i686:i386 lzop liblzo2-dev libgpm2:i386 git-core git gnupg flex bison gperf libsdl1.2-dev libesd0-dev build-essential zip curl gedit libncurses5-dev zlib1g-dev fakeroot lib32z1-dev lib32ncurses5-dev gcc-multilib g++-multilib
Next, you will need to install adb and have your permissions set up.
In order to do this you will need to go into the developer options on your device to enable debugging on your tablet. Go to settings/about tablet/build number, and tap on build number several times to unlock the developer options.
then:
You will need to create new udev rules for your device in/etc/udev/rules.d on your computer.
Use "lsusb" in your terminal to find the manufactures code of your device. it will show up as a nexus 4, or Google device.
You will need to create a file in your computer in /etc/udev/rules.d/99-android.rules.
You can use gedit if you like:
Code:
gedit /etc/udev/rules.d/99-android.rules
Put the following inside and save, changing the manufactures code as necessary to fit your device, and change “your-login” to your login name on your computer.
Code:
# Google Nexus devices
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", MODE="0666", OWNER="your-login" # Google Nexus devices
18d1 is the manufacturers code.
You will then want to restart udev on your computer:
Code:
service udev restart
you will now have permissions to access your android device from user space.
Now to download adb and get started. You should probably not use adb from the Debian repositories, as it may be an older version. the V510 is using kitkat android and needs the latest build of adb to work properly. It is a good idea to get rid of any old adb files on your computer first. The code below will do just that.
Code:
apt-get purge android-tools-adb android-tools-fastboot
Now download the latest adb bundle from here:
http://developer.android.com/sdk/index.html
Move it into a new directory,
*note -the version number may be different.
Code:
mkdir ~/adb
Code:
cd ~/adb
Code:
unzip adt-bundle-linux-x86_64-20131030.zip
su to root and Move the bundle to /opt:
Code:
mv adt-bundle-linux-x86_64-20131030 /opt/android-sdk-linux-x86_64-20131030
Other google products reside in /opt, this should too. This takes a minute or so on slow machines.
Next we need to link adb to /usr/bin
Code:
ln -s /opt/android-sdk-linux-x86_64-20131030/sdk/platform-tools/adb /usr/bin
Code:
ln -s /opt/android-sdk-linux-x86_64-20131030/sdk/platform-tools/fastboot /usr/bin
We are ready to begin working on the device! first start the adb server and look for your device.
Code:
adb start-server
Code:
adb devices
You will then need to confirm the connection on your tablet screen to allow access from your computer.
Okay, wev'e got this first part set up. it's time to begin working on a kernel!
Lets get started.
I want to extract and build my zimage in $userspace, so open a terminal from /home and:
Code:
mkdir ~/android
Download the source package LG-V510(G-Pad 8.3 Google Play Edition)_Android_KK_V510_11c from here :
https://www.lg.com/global/support/opensource/opensourceList?types=ALL&search=lgv510
and open it to find three folders, including a kernel folder. Move the kernel folder to ~/android and then:
Code:
cd ~/android
Download the current eabi-4.6 Google tool chain to ~/android to cross compile your android kernel:
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.8
When it completes, enter ~/android/kernel and get ready to compile a new kernel from the source code.
Code:
cd ~/android/kernel
Do the following each time you compile another kernel. This insures the correct path.
Code:
export PATH=$PATH:~/android/arm-eabi-4.8/bin
Code:
arm-eabi-gcc --version
you should get:
Code:
arm-eabi-gcc (GCC) 4.6.x-google 20120106 (prerelease)
Copyright (C) 2011 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Continue on! we are not done yet!
Code:
export ARCH=arm
Code:
export SUBARCH=arm
Code:
export CROSS_COMPILE=arm-eabi-
Code:
export KERNEL_DEFCONFIG=palman_defconfig
Code:
make clean
Code:
make palman_defconfig
Doing the above prepares your kernel build environment, while the following code opens a interface to configure the kernel. You can simplify this later however you wish.
But for now,
Code:
make menuconfig
At this point make whatever changes you wish to the config file. for a list of the changes I have made, and that are in the kernel available to download, look in the sleekai kernel thread. (At start of thread, or in my signature).
After saving your changes,
Code:
make
Or conversely
Code:
make -o2
which will optimize the make. I recommend using simply "make" first, as the other may not properly show errors should any occur.
and go make a pot of coffee, and probably drink the whole pot! This will take a while.
At the end you will see that the "zimage is ready"
If you have errors, then you probably have dependency problems. If not, Yay! You compiled your first kernel, but we are not done yet!
The zimage you just produced is stored in /kernel/arch/arm/boot/zImage
To put both the zimage and any modules into a separate folder inside of ~/android so as to make extracting them easier:
Code:
mkdir ~/android/kernel_output
Code:
cp ~/android/kernel/arch/arm/boot/zImage ~/android/kernel_output/zImage
Code:
find ~/android/kernel -name "*.ko" -exec cp {} ~/android/kernel_output/ \;
The above code will find all the modules for your kernel. We don't need them for this tutorial, but it still is mighty handy!
Extract your boot image (boot.emmc.win) for the ramdisk You may also download the stock.zip from the sleekai kernel thread
Now make a backup to transfer to your computer.
Reboot to recovery on your tablet. I'm using TWRP. If you are using something else it should be just as easy.
Code:
adb reboot recovery
Only tick the boot
make a backup to your sd card. I changed the name to boot.bac to keep it simple
reboot
make sure the backup of boot is present using a file explorer. I am using ES File explorer.
On your computer, pull the file using adb
Code:
adb start-server
Code:
adb devices
Code:
adb pull /storage/sdcard1/TWRP/BACKUPS/LG0000606708987/boot.bac /home/sleek
sleek is my user name, replace with yours or use tilde.
What we are after is the "boot.emmc.win" file. We will only need this and the zImage to compile a new boot image and run it on your tablet.
The tools to extract the kernel and ramdisk from the boot.emmc.win you will need the following boot image tools installed on your computer.
So, again, lets keep this simple. All the tools are forked to my github for ease of use.
So lets install the tools! Ready?
As Root:
Code:
mkdir /usr/src/android
Code:
mkdir /usr/src/android/boot
Code:
cd /usr/src/android/
Code:
git clone https://github.com/sleekmason/bootimg-tools.git
Code:
cd bootimg-tools/libmincrypt/
Code:
gcc -c *.c -I../include
Code:
ar rcs libmincrypt.a *.o
Code:
cd ../mkbootimg
Code:
gcc mkbootimg.c -o mkbootimg -I../include ../libmincrypt/libmincrypt.a
Code:
cp mkbootimg /usr/local/bin/
Code:
cd ../cpio
Code:
gcc mkbootfs.c -o mkbootfs -I../include
Code:
cp mkbootfs /usr/local/bin/
Code:
cd /usr/src/android/bootimg-tools/mkbootimg/
Code:
wget https://raw.github.com/sleekmason/bootimg-tools/master/mkbootimg/unmkbootimg.c
Code:
gcc -o unmkbootimg unmkbootimg.c
Code:
cp unmkbootimg /usr/local/bin/
Now everything is in place to make a new boot image for your tablet!
Finishing this up is easy.
As root, we made a directory in /usr/src/android/boot for your boot.emmc.win file to be torn apart:
Code:
cd /usr/src/android/boot
Copy your new zImage and the boot.emmc.win file you extracted from your device.
Note* "/home/sleek" is the path on my computer, and should be changed to reflect yours!
Code:
cp /home/sleek/android/kernel_output/zImage /usr/src/android/boot
Code:
cp /home/sleek/boot.emmc.win /usr/src/android/boot
Now unpack the boot.emmc.win file to get the ram disk
Code:
unmkbootimg -i boot.emmc.win
Now you may remove the current boot.emmc.win file, and the resultant kernel file as we will be making new ones, and rename the zImage file you moved here to "kernel".
Code:
rm boot.emmc.win kernel && mv zImage kernel
Now repack using the command given to you during the unpack:
Code:
mkbootimg --base 0 --pagesize 2048 --kernel_offset 0x80208000 --ramdisk_offset 0x82200000 --second_offset 0x81100000 --tags_offset 0x80200100 --cmdline 'console=ttyHSL0,115200,n8 androidboot.hardware=palman lpj=67677 vmalloc=300M' --kernel kernel --ramdisk ramdisk.cpio.gz -o boot.emmc.win
Note* For 500 users this may be different. Simply use the command from the prompt.
You should now have a brand new boot.emmc.win image in /usr/src/android/boot!!
To push back on your device to test
Code:
adb reboot bootloader
Code:
fastboot boot boot.emmc.win
USING the above will only put your kernel build into memory and should not hurt your device if something goes wrong. Use the command below to make it permanent.
If everything works well, you should see the change you made to the /general/perf-localversion/ in your settings under kernel. from there it's up to you to hack away! make new and unique kernels!
If you want your kernel to survive reboot do;
Code:
fastboot flash boot boot.emmc.win
then:
Code:
fastboot reboot
You can expect a slow bootup on the first go around as your new kernel populates the widgets, etc..
NOTE*For the use of the latest eabi-4.7 google toolchain, you will need the libglibc libraries from the "testing" branch as gcc 4.7 is in testing. I advise completing the guide with eabi 4.6 first before trying 4.7.
The gamma correction though enabled in 4.6, isn't near as good as the native compile using 4.7. If you want the screen to look like it does in my kernels, you will need 4.7
For the eabi-4.7:
Code:
git clone https://android.googlesource.com/platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7
That's it! Good luck! Remember, If you post a kernel you have made, you will need to show your kernel source, etc . . . Git hub is a good choice to keep track of changes you make. Best regards, Sleekmason
If you are a v500 user and want to build your own kernel!
First, read the above post as you will be following the steps listed there.​
There are just a couple of changes that you will need to do, and maybe a riddle to figure out as well. Read on.
You will need to download the v500 source from here: https://www.lg.com/global/support/opensource/opensourceList?superOsCategoryId=CAT00000001&osCategoryId=
Look for the LGV500 kernel source.
Where it says "palman" for the defconfig items, you will want to replace that with the defconfig for the 500, so replace palman with awifi-perf,
like this:
Code:
export KERNEL_DEFCONFIG=awifi-perf_defconfig
Code:
make awifi-perf_defconfig
Important
Follow the guide and build with the Google Toolchain eabi4.6 first
LG compiled for the 500 and 510 using the eabi4.6. It works, and will give you a feel for the process, and allow you to use your kernel.
Note*
I use the google toolchain eabi-4.7 for the sleekai kernels as it changes the gamma to reasonable defaults on the 510 without further tweaking. After compiling a kernel or two to get a feel for it, you should try using the 4.7 toolchain. To do so, you will probably need the libglibc libraries from the "testing" branch. Look it up.
caveat: I recieved a compile error for the v500 when I used the eabi-4.7 . . . . . yeah. You'll have to work that out.
There is a modified anykernel script for emmc devices out there (Search Google or here in xda). You will have to use the anykernel script after making your boot.emmc.win image as fastboot won't work on the 500. There may be another way .... But I don't know what it is.
Edit* There are now two different kernels for the LG GPad 8.3 V500(awifi) located in the development section of the forum.
Best of luck! -sleekmason
Can this be used to create a kernel for the non Google Play Edition Gpad to be able to allow us to install the Google Play edition ROM on it
Sent from my SM-N900W8 using Tapatalk
Canadoc said:
Can this be used to create a kernel for the non Google Play Edition Gpad to be able to allow us to install the Google Play edition ROM on it
Sent from my SM-N900W8 using Tapatalk
Click to expand...
Click to collapse
I would think so. I edited the above to show how to put the image back on your device. You should be able to use any source you wish to compile with. My thoughts are that you might wish to examine the differences in the ram disk if any.
sleekmason said:
Howdy, I would like to share how to download the kernel source for the gpe, compile a new custom kernel, and insert into your LG gpad GPE 510.
...
Click to expand...
Click to collapse
Thanks for the guide. Making GPE kernel was my next step in trying to get the GPE ROM to work on v510.
I just made guide for getting your Android build environment going if you want to use it on your blog or where ever.
http://forum.xda-developers.com/showthread.php?t=2629008
The problem with v500 is that it does not have fastboot so we can not flash kernel like how you can on v510.
@ AndroidUser00110001 Hi! I know that somebody tweaked the Any kernel to work on emmc devices... Maybe it could be adapted? Actually getting the menuconfig and make should be the same process as well as repacking the image. I take it just getting it back on the 500 device is the problem?
I will add your link to this post for setting up a build environment if that is okay.
sleekmason said:
@ AndroidUser00110001 Hi! I know that somebody tweaked the Any kernel to work on emmc devices... Maybe it could be adapted? Actually getting the menuconfig and make should be the same process as well as repacking the image. I take it just getting it back on the 500 device is the problem?
I will add your link to this post for setting up a build environment if that is okay.
Click to expand...
Click to collapse
Is that the koush any kernel? I was going to mess with that too. I just need a small break now. Took a few days to get new system exactly how I want it.
Go ahead and use guide...mo problem at all.
AndroidUser00110001 said:
Is that the koush any kernel? I was going to mess with that too. I just need a small break now. Took a few days to get new system exactly how I want it.
Go ahead and use guide...mo problem at all.
Click to expand...
Click to collapse
Yes, from here: http://forum.xda-developers.com/showthread.php?t=847265
I noted that boot was on block nncblk0p21 on our device, and not 22? better double check that. I tried it Anykernel as well to no avail when getting this set up. Fastboot is Awesome!
It's taxing to get it set up right. Seems like things change very often for the dependencies based on other package changes. I ussually go with testing but redid two partitions with stable. The 32 bit is just going to sit there, which seems kinda silly due to the need for extra packages in 64 to compile for 32 but whatever. Yeah.
AndroidUser00110001 said:
Thanks for the guide. Making GPE kernel was my next step in trying to get the GPE ROM to work on v510.
I just made guide for getting your Android build environment going if you want to use it on your blog or where ever.
http://forum.xda-developers.com/showthread.php?t=2629008
The problem with v500 is that it does not have fastboot so we can not flash kernel like how you can on v510.
Click to expand...
Click to collapse
I don't understand, what are the differences bettween the v500 and v510? they both have the same hardware, but not the same boot partition or something like that?
ayziaa said:
I don't understand, what are the differences bettween the v500 and v510? they both have the same hardware, but not the same boot partition or something like that?
Click to expand...
Click to collapse
The boot on the 500 cannot be fully unlocked.
This is not the appropriate place to ask that kind of question should be asked in general or in troubleshooting. Also, there are already many threads about this same question please use the search utility to find them. Thank you.
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
sleekmason said:
Yes, from here: http://forum.xda-developers.com/showthread.php?t=847265
I noted that boot was on block nncblk0p21 on our device, and not 22? better double check that. I tried it Anykernel as well to no avail when getting this set up. Fastboot is Awesome!
It's taxing to get it set up right. Seems like things change very often for the dependencies based on other package changes. I ussually go with testing but redid two partitions with stable. The 32 bit is just going to sit there, which seems kinda silly due to the need for extra packages in 64 to compile for 32 but whatever. Yeah.
Click to expand...
Click to collapse
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
darkassain said:
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
Click to expand...
Click to collapse
Thank you! Have you successfully used your script to push a kernel onto the 500 Or 510?
I would think this could be very handy for sharing a custom kernel for the 510, but would like to see somebody report a positive test result. Very cool!
sleekmason said:
Thank you! Have you successfully used your script to push a kernel onto the 500 Or 510?
I would think this could be very handy for sharing a custom kernel for the 510, but would like to see somebody report a positive test result. Very cool!
Click to expand...
Click to collapse
yes back before when there wasnt a overclocked kernel i basically used this to push it when i would compile just the kernel (didnt maintain so i now use dyn's)...
yes this is only for the v500 as this has the extra loki step, but it shouldnt be hard to modify so it does not do that extra step
darkassain said:
i was thinking of writing a tutorial about this as well for the v500 but this better than i would have done Well done...
Another tool that i ported to the lg g pad a bit back along with loki-doki...
Quick hint, dont bother with direct mmc naming as qcom (i dont know if the other chip makers do the same thing, as i have only had qcom devices) has given us a simple naming scheme...
should only be used by people who know how to use this,
Click to expand...
Click to collapse
Hi, can you just use a generic anykernel updater script too?
For example to flash a packed boot.img
Code:
run_program("/tmp/busybox", "dd", "if=/dev/block/platform/msm_sdcc.1/by-name/boot", "of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/repack-ramdisk.sh");
run_program("/tmp/mkbootimg.sh");
run_program("/tmp/busybox", "dd", "if=/tmp/newboot.img", "of=/dev/block/platform/msm_sdcc.1/by-name/boot");
mako and flo can do like this.. I think HTC One as well, since they are all similar qcom chipsets maybe this device can too
poondog said:
Hi, can you just use a generic anykernel updater script too?
For example to flash a packed boot.img
Code:
run_program("/tmp/busybox", "dd", "if=/dev/block/platform/msm_sdcc.1/by-name/boot", "of=/tmp/boot.img");
run_program("/tmp/unpackbootimg", "-i", "/tmp/boot.img", "-o", "/tmp/");
run_program("/tmp/repack-ramdisk.sh");
run_program("/tmp/mkbootimg.sh");
run_program("/tmp/busybox", "dd", "if=/tmp/newboot.img", "of=/dev/block/platform/msm_sdcc.1/by-name/boot");
mako and flo can do like this.. I think HTC One as well, since they are all similar qcom chipsets maybe this device can too
Click to expand...
Click to collapse
thanks for reminding me the any kernel uploaded by me won't work as it doesn't parse Loki images xorrectly, I'll upload the correct one once I have access to my pc
darkassain said:
thanks for reminding me the any kernel uploaded by me won't work as it doesn't parse Loki images xorrectly, I'll upload the correct one once I have access to my pc
Click to expand...
Click to collapse
could you please re-post to a different thread rather than hijacking this thread, as your script does not work with the 510 currently and I do not want to go to get confused with my kernel how to. what started out to maybe become relevant apparently will not and so shouldn't be confused with what I'm doing here. I will be happy to try working with your script if you would open up an appropriate thread. Thank you.
Installed kenel and booted. Now to install trickster mod and fix the dang gamma.
gunnyman said:
Installed kenel and booted. Now to install trickster mod and fix the dang gamma.
Click to expand...
Click to collapse
Excellent!! Pleased to know that you are able to use it. Have you changed your gamma settings?
I did on mine and am pleased with the result. I'm using 248, 252, 255 using trickster mod What are you going with?
sleekmason said:
Excellent!! Pleased to know that you are able to use it. Have you changed your gamma settings?
I did on mine and am pleased with the result. I'm using 248, 252, 255 using trickster mod What are you going with?
Click to expand...
Click to collapse
havent messed around too much.
I had a thought about this and I think it would be awesome if we could incorporate faux123's bits for gamma and color control. His fauxcontrol offers much more granular control than trickster.
I'm thankful to have what we have, and THANK YOU for sharing it, but like any good geek I WANTS MOAR!!!!!
gunnyman said:
havent messed around too much.
I had a thought about this and I think it would be awesome if we could incorporate faux123's bits for gamma and color control. His fauxcontrol offers much more granular control than trickster.
I'm thankful to have what we have, and THANK YOU for sharing it, but like any good geek I WANTS MOAR!!!!!
Click to expand...
Click to collapse
me too! I'll look into it. There are other apps besides trickster to give you more control. I think at the kernel level everything we need is unlocked. And yeah, he knows his business like nobody else eh? I'm just persistent.

[HOW-TO] A Guide to KEXEC and HARDBOOT for ARMv7a Boards

What is Kexec?
"Kexec", which is short for 'Kernel Execution' is derived from the Linux Kernel call "exec". It allows the "live" booting of a new kernel "over" the currently booted kernel without taking the device down for a reboot. This is extremely useful on locked bootloader devices, as a user with root authentication can boot a custom kernel without rebooting, and undergoing the security checks enforced by the bootloader. On unlocked devices, it can be used to "multi-boot" kernels on a device without requiring the kernels to be installed to the /boot partition.
Whilst Kexec is extremely useful, it also can be extremely hard to implement, as it needs to take all devices down, and bring them back up along with the new kernel, this can lead to some serious bugs, like devices not working after soft-boot, kernel corruption, device hangs, etc. This make it very device specific, and hard to get fully working, as it requires retrieving kernel crash logs, (often) UART serial output, and a ton of debugging.
What about this whole "Hardboot" thing?
The solution to this was written (initially) by Mike Kassick, who had the idea to "Hardboot" a kernel. Which is when a kernel is loaded into memory, a flag is set, the device is taken down for a full reboot, then the flag is read out by the primary kernel very early in the boot sequence, at which point, the "primary" kernel directly loads the new "secondary" kernel/ramdisk/passes arguements/etc.
This is much easier to implement than the normal Kexec SysCall, as it jumps to the new kernel before most devices are initiated, and in doing this, we allow the secondary kernel to initialize all the devices on its own, and not have to worry about taking them down.
Many people unknowingly make use of Kexec in the form of MultiROM, so, today, I thought I would do a write up on how to use it in practice.
Necessary Components:
* Boot.img (alternatively, the zImage-dtb/ramdisk you want to use)
* Unmkbootimg
* Kexec Binary (can be found in your specific devices MultiROM zip)
* Kexec Hardboot enabled Kernel installed (most custom kernels have it)
* Root Access
Downloads:
All the Binaries I've cross compiled/found can be downloaded here: https://www.dropbox.com/sh/7g5jcofv8j2gwg9/AAA-2b-wLiHq2z0nCMIHSHooa?dl=0
All the Linux Binaries you'll want/need are here: https://www.dropbox.com/sh/qcho8bhaoi8cdkc/AACGvmIQlb_3I9OQtNMqIQwva?dl=0
If you use Windows/Mac, just find the binaries equivalents for your platform.
How to use it?
1. Take the aforementioned Kexec Binary, and place it in /system/bin using ADB or A File Explorer, granting it permissions drwxdr-xdr-x (or chmod 0755 it)
2. Over on your desktop, make sure you have Unmkbootimg in an Executable location, and that you've blessed them as executable (chmod 0755 filename). Then run
Code:
unmkbootimg /path/to/your/boot.img
This will dump a zImage (rename it to zImage-dtb now, for semantics sake), and a ramdisk, labeled initramfs.cpio.gz (Initial RAM File System, in the form of a cpio.gz archive).
Now, put the kernel and ramdisk in a folder on your SD Card via MTP/ADB Push, I called mine "kexecstuffs".
3. Now open a mobile terminal, or an ADB Shell, and run
Code:
su
cd /sdcard/PathToYourFolder/
kexec --load-hardboot zImage-dtb –initrd=initramfs.cpio.gz --mem-min=0x20000000 --command-line="$(cat /proc/cmdline)" --boardname=shamu –dtb
Now, lets dissect the different arguments we are passing to Kexec:
--load-hardboot = Tells Kexec to make use of the Kexec Hardboot kernel function, and take the device down for a full reboot as opposed to soft-booting, like that used in the standard Kexec Linux SysCall
zImage-dtb = Name of your kernel file
--initrd = Points to the ramdisk to be used when booting the new kernel, if not set, the current ramdisk in the /boot partition. Most archive types are supported.
--mem-min = A reasonable value in memory where the kernel is loaded, serves as space for Kexec to do its work
--command-line = What arguments are passed to the new kernel, using "$(cat /proc/cmdline)" allows you to pass the currently booted kernel's arguments to the new kernel, which is what we want in the case of Shamu
--dtb = Defines that the board makes use of an Appended Device Tree, can be passed without a value (which will rely on Tasssdar's “boardname” value), or can have a compressed DTB image as its value
--boardname = Tasssdar's way to handle different DTB styles, we just need to pass “shamu” to it, and it'll use our DTB style
Now that we have successfully loaded the kernel into memory, lets execute it!
4. In that same Mobile Terminal/ADB Shell, run:
Code:
kexec -e
Although this guide is for the Nexus 6 (shamu), it should work all devices supported bu MultiROM, or on any device with a kernel that supports Kexec/Kexec Hardboot.
I hope this helped you to better understand what Kexec is/how to use it.

Categories

Resources