How to build a Linux kernel and flash it to the phone

Since the launch of the unlock boot loader site, we have received a lot of really great feedback. The Sony Ericsson Developer Program wants to continue to build on this open dialogue with external developers.

Developers and advanced users can now unlock the boot loader, which is the first step to be able to flash your own image. Now we have seen quite a few comments in different forums like the XDA forum, where developers run into problems when building their own image, and and trying to flash the image using Fastboot. With the help of our Master Software Architect, James Jacobsson, we put together a short article on how to do this.

Before moving on, we’d like to remind you again that there is no turning back when unlocking the boot loader. You may void the warranty of the phone, and you will not be able to revert the phone to a locked or original state if you unlock it.

What is the Linux kernel?
The Xperia™ line of smartphones run on the Android™, the mobile operating system based on the Linux kernel. Though it is only a small part of the operating system, the kernel ensures that all other processes in the system are synchronized to work together properly.

Why rebuild the kernel?
Rebuilding the kernel enables end users to make modifications to their devices that are normally not intended by the device manufacturer, such as theming the device by changing system icons and removing/modifying system components. Please note that Sony Ericsson is not recommending this.

Considerations before building your own kernel and reflashing your device
As mentioned in the beginning of this article, the first step is to unlock the boot loader. When the boot loader is unlocked, the sensitive data is removed, such as DRM certificates, and the user partition of the file system is wiped out. But all other functionality, such as the camera and other drivers, is left intact. Please note that content, like music files, that require the DRM certificate will not be accessible any more. But most importantly, you may void the warranty of your phone if you decide to unlock it. Aside from the considerations mentioned above, the functionality is there, just waiting for you to take advantage of it. So, if you’re ready, here’s how to get started.

Building the kernel
It takes a few main steps to build the kernel. Below we’ll show you how to build a Linux kernel and flash it onto the device.

Step A – Download the necessary software
Download the following software to get started:

  • The kernel source code can be downloaded from the copyleft archives on Sony Ericsson Developer World. You can use the file called 3.0.A.2.181_182.tar.bz2 for our Android™ Gingerbread devices. This is the source code for the Linux kernel as used in the Xperia™ PLAY.
  • The Fastboot client which is part of the Android SDK. This is the standard Android flashing utility. This allows you to flash the image you are about to create onto the device.
  • The Init RAM disk. The initial RAM disk (also known as the initrd) is the initial filesystem that the kernel will mount and start running processes off. You can configure the Init RAM disk to grant root access. How you create or download your own Init RAM disk is beyond the scope of this article.
  • The ARM cross-compiler. A cross-compiler is used to build ARM binaries on a different architecture, such as x86. This allows you to compile software (such as the kernel) into a format that the device can run. We recommend getting the CodeSourcery Lite compiler, especially the GNU/Linux variant, as you’ll need that if you want to build binaries for a full-blown Linux system on the device later. However, any EABI ARM compiler capable of compiling the Linux kernel should be enough for this step.

Step B – Building the kernel
To build the kernel, you first need to unpack the kernel. Once you’ve unpacked the kernel, you need to configure it, and then build it. The example below is based on you using the file called 3.0.A.2.181_182.tar.bz2.

1. Go into the kernel directory:

cd kernel

2. Configure the kernel:
ARCH=arm CROSS_COMPILE=/opt/arm-2010q1/bin/arm-none-eabi- make semc_zeus_defconfig

Note: Replace:

with where you installed your cross-compiler. Also, this example is for Xperia™ PLAY. Replace:

with the following values depending on what device you want to configure it for:

Xperia™ PLAYsemc_zeus_defconfig
Xperia™ arcsemc_anzu_defconfig
Xperia™ neosemc_hallon_defconfig

3. Build the kernel:

ARCH=arm CROSS_COMPILE=/opt/arm-2010q1/bin/arm-none-eabi- make


with where you installed your cross-compiler. Once done, you should have a compressed kernel-image in arch/arm/boot/zImage.

Step C – Getting a RAM disk
The RAM disk is the initial filesystem the kernel will mount before transferring control to userspace. How you create your own root filesystem is beyond the scope of this article, but you can use the following instructions to pack/unpack the file.

Unpacking (you have ramdisk.img, and want to create a directory of files out of it):

gzip -d - < ramdisk.img > cpio -idm

Packing (You have directory of files, and want to create ramdisk.img from it):
find . | cpio --quiet -H newc -o | gzip > ramdisk.img

Step D – Assembling the boot.img
Now that we have all the parts we need to create a flashable file. The next stop is to package the parts. To do this, you’ll need the program mkbootimg, which is part of the standard Android tree. If you don’t feel like compiling all of Android to get this tool, it is available to download from various trusted sites on the Internet.

Once you have the tool, this is the command to combine your kernel and RAM disk into a flashable file:

mkbootimg --base 0x00200000 --kernel kernel/arch/arm/boot/zImage --ramdisk ramdisk.img -o boot.img

Step E – Flashing the file
You should flash the file using Fastboot. If you’ve unlocked the boot loader on your device, you already have Fastboot.

1. To flash the boot.img file, use the following the command:

fastboot –i 0x0fce flash boot boot.img

2. Now, it will prompt you to connect your device. To do so, follow these simple steps:

  1. Make sure your device is powered down.
  2. Hold down the Search button (Xperia™ PLAY only) or the Back button (all other Xperia™ devices). The device’s notification light should shine blue to confirm it’s in Fastboot mode.
  3. Connect the USB cable.
  4. Flashing should now start and complete.

3. As a last step in the process, you need to reboot the device. You can either remove the USB cable and battery to power the device down. If you prefer, you can instead issue the following command (either method will work):

fastboot –i 0x0fce reboot

Important information!
Sony Ericsson does not guarantee any support on this, but we will monitor the Building the Linux kernel for Xperia phones thread on the XDA Developers forum. However, we cannot guarantee an answer for every question asked in this forum.

Additional information for experienced Linux kernel experts
The kernel is pretty standard, all the regular things you’re used to is there, and available to use. Things that are different are the memory config and the kernel commandline. The memory config is hardcoded (i.e., ATAGs aren’t used for this). It’s set in the board-file for your target, such as kernel/arch/arm/mach-msm/board-semc_zeus.c in the function msm7x30_fixup. The kernel commandline is also not fetched from the boot.img file, but compiled into the kernel (CONFIG_CMDLINE). Some arguments are also added from the boot loader.

Additional information if porting non-Linux format files to the device
The boot loader will accept any reasonably formatted boot.img file. For example, at the Android Kernel Git, you will see the format of the boot.img file. This allows you to create a boot.img file containing two loadable files (kernel+ramdisk), which will get loaded into RAM. Once the boot loader is loaded, it passes the control to the first instruction of the loaded kernel image. After control is passed, the kernel can rely on the data contained in the RAM disk already being loaded.

More information: 

Comments 91

Sort by: Newest | Oldest | Most popular

  1. Pingback #1

    […] the boot loader for 2011 Xperia™ phones. We then moved on to explain how to build your own Linux kernel. As a third step, we have now supported the FreeXperia group. The reason for this is that we firmly […]

  2. Pingback #2

    […] SonyEricsson. Terutama semenjak SonyEricsson menyediakan fasilitas untuk oprek-oprek, bahkan mendukungnya. Apalagi, saya sebenarnya penyuka HP SonyEricsson. Itu sebabnya seperti kata orang bule, “no […]

  3. Pingback #3

    […] su propio kernel de Linux e instalarlo en algunos de sus celulares (Los invito a leer: “How to build a Linux kernel and flash it to the phone” en el blog de Sony). Esta actitud es precisamente la que le aumentaría la popularidad en […]

  4. By Anonymous


    The X10_mini_X10_mini_pro_Donut_1.2.A.1.174.tar.gz archive is damaged… Please check it.

    • By Tobias Nilsson


      Thanks for noticing, we have now replaced it. Feel free to download again!

  5. By Anonymous



    Great idea, but can you please check X10_mini_X10_mini_pro_Donut_1.2.A.1.174.tar.gz archive.
    It could not be extracted anymore.

    I have tried to download it from many locations and always the result is same – gzip can’t extract and file contains more than 70% zeroes instead of data.


  6. Pingback #7

    […] build a Linux kernel and flash it to the phone May 18, 2011 By Leave a Comment Just read about this at sony ericsson […]

  7. By Rahul Yashwant Doiphode


    this initiative is really impressive!!!

    congratulations to SE for recognizing the developer community and sharing this information!!!

    will the expected GB upgrade for X10 be based on kernel 2.6.32? it would be really great if SE can release compatible 2.6.32 sources for X10 as the latest Xperia lineup already uses 2.6.32 kernel
    another thing, will it be possible for SE to incorporate removal of FPS cap on X10 (currently limited to 30fps) or raise it to 60fps (like the current Xperia lineup)? it will great improve the user experience and performance of the Xperia X10, as currently, due to this 30 fps limit, even when scrolling through menus there is a noticeable lag…

  8. By modi


    what about latest xperia x8 kernel?

  9. By Iceman


    @Meepo – I think you need to read SE’s comments again.. You have misunderstood the point.
    @SE – I’ll ask my question again – We’re looking for a recovery solution over on XDA – like CWM or XRecovery.. can you help support that please?

  10. By Titan


    So happy with SE now, they are going in the right direction, i also hope with the gingerbread release for x10 it also brings an option of unlocking the bootloader easily. Also i’m very happy that SE is looking in XDA forums.

  11. By Peter


    I haven’t looked too far into this, but I definitely want to voice my support for this.

    I have sworn by older Sony Ericsson handsets, but moved to a Samsung Captivate for the AMOLED screen, and aside from the screen it’s been a mistake. With news like this, I’m pretty sure my next one will be Sony Ericsson.

  12. By Hugo


    Well, I bought my Xperia X10 because Sony Ericsson have announced that it will be updated to gingerbread. I don’t know if Xperia X10 can go much farther unlocking the bootloader, but I think we should have the option to try. Devs are working hard to unlock the bootloader of Xperia X10 and I think Sony Ericsson should support them.

  13. By Meepo


    Bus 0000 vendor 0000 product 0000 version 0000
    location phys= sysfs=/devices/virtual/input/input0 uniq= Handlers=kbd event0 cpufreq B:EV=3 B:KEY= 4 0 0 0 0 0 0 0

    Bus 0000 vendor 0000 product 0000 version 0000
    Location sysfs = devices/virtual/spi_qsd.0/spi0.0/input/input1
    handlers=event1, cpufreq
    KEY=400 0 0 0 0 0 0 0 0 0 0
    ABS=650000 3

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name=”es209ra_keypad”
    P: Phys=
    S: Sysfs=/devices/virtual/input/input2
    U: Uniq=
    H: Handlers=kbd event2 cpufreq
    B: EV=3
    B: KEY=20 900000 0 40000000 1c0040 0 0 0

    I: Bus=0000 Vendor=0000 Product=0000 Version=0000
    N: Name=”compass”
    P: Phys=
    S: Sysfs=/devices/virtual/input/input3
    U: Uniq=
    H: Handlers= event3 cpufreq
    B: EV=9
    B: ABS=305ff

    I: Bus=0000 Vendor=0001 Product=0001 Version=0001
    N: Name “8k_handset”
    P: Phys=
    S: Sysfs=/devices/virtual/input/input4
    H: Handlers=kbd event4 cpufreq
    U: Uniq=
    B: EV=23
    B: KEY= 4 0 0 0 100800 0 0 0
    B: SW=4

    I: Bus=0003 Vendor=0000 Product=0000 Version=0004
    N: Name=qwerty
    P: Phys=
    S: Sysfs=/devices/virtual/input/input6
    U: Uniq=
    H: Handlers=kbd event5 cpufreq
    B: EV=b
    B: KEY=400 0 70000 fffffff fffffff fffffff fffffff fffffff fffffff fffffff
    B: ABS=1000003

    Key adresses and folders for the module keys.

  14. By Meepo


    Here the X10 bootloader if anyone is interested 🙂

    dev: size erasesize name
    mtd0: 00440000 00020000 “appslog”
    mtd1: 06f40000 00020000 “cache”
    mtd2: 160a0000 00020000 “system”
    mtd3: 1d100000 00020000 “userdata”
    mtd4: 002c0000 00020000 “bootloader” <<"RIGHT THERE!
    mtd5: 017e0000 00020000 “amss”
    mtd6: 00b00000 00020000 “amss_fs”
    mtd7: 00440000 00020000 “fota0″
    mtd8: 00440000 00020000 “fota1″
    mtd9: 00c40000 00020000 “recovery”
    mtd10: 01440000 00020000 “dsp1″
    mtd11: 00c40000 00020000 “boot”