I'm making AndroPlus Kernel but when you want to build custom stock kernel for Lollipop, you'll need some changes.
So I'm sharing my how to
If you want to build with other toolchain, just read ramdisk changes in 4. and cmdline changes in 7.
First of all, this official tutorial will help you a lot.
Prerequisites
You are running Linux or Mac with git commands
FTF for the version you want to build
* If your system doesn't contain commands in my tutorial, please search and install.
1. Put toolchain to your home
Download Linaro GCC 4.9.1-2014.04 Toolchains (A15) from this thread
and copy arm-cortex_a15-linux-gnueabihf-linaro_4.9.1-2014.04.tar.xz to your home,
then run these commands:
* You can change location to everywhere you like
2. Download the kernel source
Sony has official Github but they are too slow to update kernel source...
Download kernel source from here and run these commands:
* Change dir name and file name to extract
3. Prepare ramdisk
Make ramdisk_pack dir in home and extract kernel.sin from FTF to ramdisk_pack dir.
Download this scripts and mkbootimg,
then extract them and set 755 (rwxr-xr-x) permission.
4. Unpack ramdisk
Run runme_1unpack.sh to unpack ramdisk.
It will create kernel.sin-ramdisk dir and some files.
5. Repack ramdisk
Run runme_2repack_mod.sh.
This will patch and repack your ramdisk.
In my script, I'm disabling sony_ric and change some lines to fix unknown baseband.
After that, you'll get [name]-ramdisk.cpio.gz.
Rename it to ramdisk.cpio.gz.
6. Prepare kernel build tools
Copy ramdisk.cpio.gz to ~/custom_kernel/final_files dir,
then download dtbToolCM from here and mkbootimg from here
and put them in ~/custom_kernel/final_files dir and set 755 (rwxr-xr-x) permission.
7. Patch some files to build with Linaro GCC 4.9.1
Open terminal in ~/custom_kernel/kernel_src, then run
8. Build kernel
Download build script from here and set 755 (rwxr-xr-x) permission.
This script is for building Z3 (leo), so please change words
msm8974pro-ac-shinano_leo.dtb
shinano_leo_defconfig
boot_Z3.img
to something you want to build.
You can find defconfig in /arch/arm/configs.
In my script, I set cmdline
"androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 vmalloc=300M dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y".
This fix unknown baseband on Lollipop kernel.
After modifying script, run
9. Done!
If build goes well, you'll get boot_Z3.img.
Flash it with
If you get some error, please search with error message.
Credits:
Sony
DooMLoRD
Cyanogenmod
Christopher83
russel5
and other people involved
So I'm sharing my how to
If you want to build with other toolchain, just read ramdisk changes in 4. and cmdline changes in 7.
First of all, this official tutorial will help you a lot.
Prerequisites
You are running Linux or Mac with git commands
FTF for the version you want to build
* If your system doesn't contain commands in my tutorial, please search and install.
1. Put toolchain to your home
Download Linaro GCC 4.9.1-2014.04 Toolchains (A15) from this thread
and copy arm-cortex_a15-linux-gnueabihf-linaro_4.9.1-2014.04.tar.xz to your home,
then run these commands:
Code:
cd ~
tar Jxvf arm-cortex_a15-linux-gnueabihf-linaro_4.9.1-2014.04.tar.xz
2. Download the kernel source
Sony has official Github but they are too slow to update kernel source...
Download kernel source from here and run these commands:
Code:
mkdir /custom_kernel && cd /custom_kernel
mkdir /final_files
mkdir /kernel_src && cd /kernel_src
bzip2 -dc 23.1.A.0.690.tar.bz2 | tar xvf -
3. Prepare ramdisk
Make ramdisk_pack dir in home and extract kernel.sin from FTF to ramdisk_pack dir.
Download this scripts and mkbootimg,
then extract them and set 755 (rwxr-xr-x) permission.
4. Unpack ramdisk
Run runme_1unpack.sh to unpack ramdisk.
Code:
./runme_1unpack.sh
5. Repack ramdisk
Run runme_2repack_mod.sh.
Code:
./runme_2repack_mod.sh
In my script, I'm disabling sony_ric and change some lines to fix unknown baseband.
Code:
# Disable sony_ric
sed -i -e "s/write \/sys\/kernel\/security\/sony_ric\/enable 1/# write \/sys\/kernel\/security\/sony_ric\/enable 0/g" init.sony-platform.rc
sed -i -e "s/mount securityfs securityfs \/sys\/kernel\/security nosuid nodev noexec/# mount securityfs securityfs \/sys\/kernel\/security nosuid nodev noexec/g" init.sony-platform.rc
sed -i -e "s/service ric \/sbin\/ric/service ric \/sbin\/ric\n disabled/g" init.sony-platform.rc
# Fix for Lollipop kernel
sed -i -e "s/chown tad tad \/dev\/block\/mmcblk0p1/chown root root \/dev\/block\/mmcblk0p1/g" init.sony-platform.rc
sed -i -e "s/chmod 0770 \/dev\/block\/mmcblk0p1/chmod 0777 \/dev\/block\/mmcblk0p1/g" init.sony-platform.rc
sed -i -e "s/user tad/user root/g" init.sony-platform.rc
sed -i -e "s/group tad root/group root root/g" init.sony-platform.rc
Rename it to ramdisk.cpio.gz.
6. Prepare kernel build tools
Copy ramdisk.cpio.gz to ~/custom_kernel/final_files dir,
then download dtbToolCM from here and mkbootimg from here
and put them in ~/custom_kernel/final_files dir and set 755 (rwxr-xr-x) permission.
7. Patch some files to build with Linaro GCC 4.9.1
Open terminal in ~/custom_kernel/kernel_src, then run
Code:
git init
git remote add AndroPlus https://github.com/WedyDQ10/android_kernel_sony_msm8974ac.git
git fetch AndroPlus
git cherry-pick 3fdc1afb44e469417a9885138acfdf1ed356c8ca
git cherry-pick 488cfa625e0402e7c819a9e6240c349ed7bf5b9f
git cherry-pick b0fa0eee571e4587d0a2e256061532158b852253
git cherry-pick 116a674042845179e9ef2d7c2708db0c53e5e605
Download build script from here and set 755 (rwxr-xr-x) permission.
This script is for building Z3 (leo), so please change words
msm8974pro-ac-shinano_leo.dtb
shinano_leo_defconfig
boot_Z3.img
to something you want to build.
You can find defconfig in /arch/arm/configs.
In my script, I set cmdline
"androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3b7 ehci-hcd.park=3 androidboot.bootdevice=msm_sdcc.1 vmalloc=300M dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y".
This fix unknown baseband on Lollipop kernel.
After modifying script, run
Code:
./build_it4_leo
If build goes well, you'll get boot_Z3.img.
Flash it with
Code:
fastboot flash boot boot_Z3.img
Credits:
Sony
DooMLoRD
Cyanogenmod
Christopher83
russel5
and other people involved
Last edited: