FORUMS
Remove All Ads from XDA

[Tutorial] Kernel building instructions for Xperia devices

13,194 posts
Thanks Meter: 39,783
 
Post Reply Email Thread
hello folks!

i have been working on kernels for various xperia devices since the Xperia X10... i will update this thread with information on how to build kernels for various xperia devices...


Sony (Ericsson) started off helping the developer community with information on how to build kernels:
http://developer.sonymobile.com/2011...-linux-kernel/

do read the above post, though its slightly old (2011), its really good! Since then Sony has released various devices which use a variety of chipsets and each chipset has different ways to build bootable kernel...

the objective of this thread is to provide brief instructions for some of these chipsets across the various device generations to build bootable kernels...

this will not cover how to build working ramdisks... you can always use the stock ramdisks from kernel.sin... here is how to get stock ramdisk out from kernel.sin...




Toolchains:

I have tested various toolchains for building kernels and very few work correctly on the kernel sources to get bootable kernel.

The toolchains which worked for me are:
  • arm-eabi-4.4.3 - GCC 4.4.3 toolchain from CyanogenMod repo
  • arm-eabi-linaro-4.6.2 - GCC Linaro 4.6.2 (2011.10) toolchain
  • arm-linux-androideabi-4.7 - GCC 4.7 from Google repo

all of these are posted on my git repo:
https://github.com/DooMLoRD/android_prebuilt_toolchains

sometimes the kernel sources need to be modified slightly to support compiling using these toolchains. I have mentioned the necessary patches where-ever applicable.




Instructions for various generation of devices:

Xperia 2014 (H1) - msm8974ab - Xperia Z2

Xperia 2013 (H2) - msm8974 - Xperia Z1, Z Ultra, Z Ultra GPe, Z1 Compact

Xperia 2013 (H1) - apq8064 - Xperia Z, ZL, ZR, Tablet Z

Xperia 2013 (H1) - msm8960t - Xperia SP

Xperia 2012 (H2) - msm8960 - Xperia T, TX, V

Xperia 2012 (H1) - msm8660 - Xperia S, SL, Ion, Acro S

Xperia 2011 - msm8x55/msm7x30 - Xperia Arc, Play, Neo, Ray, etc
The Following 53 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:36 PM |#2  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
reserved for later
The Following 4 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:36 PM |#3  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for MSM8x55/MSM7x30


Latest sources available at:
http://developer.sonymobile.com/down...ld-4-1-b-1-13/


Recommended toolchain:
GCC 4.6 Linaro


Fix Makefile for 4.6 Toolchain:
Code:
KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
       -Werror \
to:
Code:
KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
       -Wno-unused-but-set-variable -Wno-uninitialized \


Supported boards on this platform:
  • zeus - Xperia Play, Xperia L
  • mogami - Xperia Arc, Arc S, Ray, Neo, etc


Building kernel (zImage):

for Xperia Arc (anzu):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make semc_anzu_defconfig
for Xperia Play (zeus):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make semc_zeus_defconfig

build zImage
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make  -j8



Instructions for building boot.img


first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to...30_mogami_zeus


Sony used the standard boot.img format for this chipset devices


building boot.img

use the following command:
Code:
./mkbootimg --base 0x00200000 --kernel zImage --ramdisk ramdisk.cpio.gz -o boot.img



Special notes
  • Sometimes the compiled kernel will just not boot, will show blank screen. Workaround is, ramdisks needs to be filled with filler so that total size is bigger.
  • boot.img can be hotbooted (fastboot boot boot.img)



regards,

DooMLoRD
The Following 15 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:38 PM |#4  
XperianPro's Avatar
Senior Member
Flag Mars
Thanks Meter: 881
 
Donate to Me
More
Novathor?
16th September 2013, 09:38 PM |#5  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for MSM8260/MSM8660


Latest sources available at:

Since I actively develop for a device of this platform (Xperia S) latest sources can found at my git repo:
https://github.com/DooMLoRD/android_...e/sony_sources



Recommended toolchain:
GCC 4.7



Fixes for 4.7 Toolchain:

Makefile fix

defconfig fix



Supported boards on this platform:
  • fuji- Xperia S, SL, Ion, Acro S



Building kernel (zImage):

for Xperia S (nozomi):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make fuji_nozomi_defconfig

build zImage
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make -j8



Instructions for building kernel.elf

first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to...r/msm8660_fuji


Sony shifted to ELF format for this chipset...

They had posted instructions on there website:
http://developer.sonymobile.com/2012...-instructions/
(avoid using those files as they are for GingerBread)


building kernel.elf

use the following command (for JB):
Code:
python mkelf.py -o kernel.elf [email protected] [email protected],ramdisk [email protected],rpm
the additional files required are posted at my build tools repo



Special notes
  • RPM is different for each device and also differs for OS release, so the same RPM wont work on Xperia S or Xperia Ion and GB/ICS/JB each have different RPMs
  • kernel.elf CANNOT be hotbooted (fastboot boot kernel.elf)



regards,

DooMLoRD
The Following 2 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:39 PM |#6  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for MSM8960


Latest sources available at:

Since I actively develop for a device of this platform (Xperia T) latest sources can found at my git repo:
https://github.com/DooMLoRD/android_...e/sony_sources



Recommended toolchain:
GCC 4.6 Linaro



Supported boards on this platform:
  • blue- Xperia T, TX, V



Building kernel (zImage):

for Xperia T (mint):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make blue_mint_defconfig

build zImage
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make -j8



Instructions for building kernel.elf

first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to...r/msm8960_blue


Sony uses ELF format for this chipset...




building kernel.elf

use the following command (for JB):
Code:
python mkelf.py -o kernel.elf [email protected] [email protected],ramdisk [email protected],rpm [email protected],cmdline
the additional files required are posted at my build tools repo



Special notes
  • RPM is different for each device and also differs for OS release, so the same RPM wont work on Xperia T or Xperia V as each have different RPMs
  • kernel.elf CANNOT be hotbooted (fastboot boot kernel.elf)



regards,

DooMLoRD
The Following 4 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:39 PM |#7  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for MSM8960T


Latest sources available at:

Since I actively develop for a device of this platform (Xperia SP) latest sources can found at my git repo:
https://github.com/DooMLoRD/android_...e/sony_sources



Recommended toolchain:
GCC 4.7



Fixes for 4.7 Toolchain:

Makefile fix



Supported boards on this platform:
  • viskan- Xperia SP



Building kernel (zImage):

for Xperia SP (huashan):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make viskan_huashan_defconfig


build zImage
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make  -j8

incase u get errors like:
Code:
 error : /scripts/gcc-wrapper.py
just correct the permissions of that file
Code:
chmod 755 ./scripts/gcc-wrapper.py



Instructions for building kernel.elf

first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to...sm8960t_viskan


Sony uses ELF format for this chipset...




building kernel.elf

use the following command:
Code:
python mkelf.py -o kernel.elf [email protected] [email protected],ramdisk [email protected],rpm [email protected],cmdline
the additional files required are posted at my build tools repo



Special notes
  • kernel.elf CANNOT be hotbooted (fastboot boot kernel.elf)



regards,

DooMLoRD
The Following 6 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:40 PM |#8  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for APQ8064


Latest sources available at:

Since I actively develop for a device of this platform (Xperia Z) latest sources can found at my git repo:
https://github.com/DooMLoRD/android_...e/sony_sources



Recommended toolchain:
GCC 4.7



Fixes for 4.7 Toolchain:

Makefile fix

prima fix



Supported boards on this platform:
  • fusion3- Xperia Z, ZL, Tablet Z, ZR



Building kernel (zImage):

for Xperia Z (yuga):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make fusion3_yuga_defconfig


build zImage
Code:
ARCH=arm CROSS_COMPILE=~/arm-linux-androideabi-4.7/bin/arm-linux-androideabi- make  -j8




Instructions for building boot.img

first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to...pq8064_fusion3


Sony uses slightly different boot.img format for this chipset...




building boot.img

use the following command:
Code:
./mkbootimg --base 0x80200000 --kernel zImage --ramdisk_offset 0x02000000 --cmdline "androidboot.hardware=qcom user_debug=31 msm_rtb.filter=0x3F ehci-hcd.park=3 vmalloc=400M androidboot.emmc=true" --ramdisk ramdisk.cpio.gz -o boot.img
corrected build tools are posted at my build tools repo



Special notes
  • boot.img CANNOT be hotbooted (fastboot boot boot.img)



regards,

DooMLoRD
The Following 13 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:41 PM |#9  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Instructions for MSM8974


Latest sources available at:

I will soon be getting the Xperia Z1 and actively develop for it... i will keep the latest sources at my git repo:
https://github.com/DooMLoRD/android_...s/sony_sources



Recommended toolchain:
GCC 4.6



Fixes for 4.6 Toolchain:

Makefile fix 1

Makefile fix 2



Supported boards on this platform:
  • rhine- Xperia Z1, Z Ultra



Building kernel (zImage):

for Xperia Z1 (honami):
import defconfig
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make rhine_honami_defconfig


build zImage
Code:
ARCH=arm CROSS_COMPILE=~/android-toolchain-eabi-linaro-4.6-2011.10/bin/arm-eabi- make  -j8




Instructions for building boot.img

first get the kernel built... once kernel is built u will get zImage and copy that zImage to the folder containing the build tools...

i have posted the build tools i use here:
https://github.com/DooMLoRD/build_to.../msm8974_rhine


Sony uses slightly different boot.img format for this chipset...




building boot.img

Quote:
Originally Posted by krabappel2548


MSM8974 needs something new to build a kernel, this is called a dt.img. This basically is an img file which holds information about the board pagesize, kernel version and some other kernel related things. You can only use a specific dt.img with a kernel, this file needs to be generated by a binary called dtbTool. This binary can be found in the Cyanogen repo's or you can download a prebuild one in this thread.

to get the dt.img:
Code:
# path to kernel sources
KERNEL_SRC_PATH=~/android_kernel_sony_msm8974/

echo "generating device tree..."
./dtbTool -o dt.img -s 2048 -p {KERNEL_SRC_PATH}/scripts/dtc/ {KERNEL_SRC_PATH}/arch/arm/boot/
once u have the dt.img along with the zImage and ramdisk.cpio.gz use the following command:
Code:
./mkbootimg --base 0x00000000 --kernel zImage --ramdisk_offset 0x02000000 --tags_offset 0x01E00000 --pagesize 2048 --cmdline "androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x3F ehci-hcd.park=3 msm_rtb.enable=0 lpj=192598 dwc3.maximum_speed=high dwc3_msm.prop_chg_detect=Y" --ramdisk ramdisk.cpio.gz --dt dt.img -o boot.img

corrected build tools are posted at my build tools repo



Special notes
  • boot.img CAN be hotbooted (fastboot boot boot.img)



regards,

DooMLoRD
The Following 6 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:42 PM |#10  
DooMLoRD's Avatar
OP Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,783
 
Donate to Me
More
Quote:
Originally Posted by XperianPro

Novathor?

Later I will add info for them too....
The Following 5 Users Say Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
16th September 2013, 09:47 PM |#11  
siankatabg's Avatar
Recognized Developer
Thanks Meter: 7,736
 
Donate to Me
More
Hello doom,I want to ask you something.I manage to port your doomkernel v22 GB for Arc/Arc S to Neo/Neo V and I want permissions from you to share it in Neo forum.Sorry for asking here, but you don't answer me on the PM that I send you.

Sorry for my English.

Sent from my Xperia Neo V using xda app-developers app
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes