[Xperia Z1 Original Android Development] krabappel2548:
== Warning!! ==

This is at your own risk and only for unlocked bootloaders, don't try this on a locked bootloader device!!

I'm not responsible for damage to your device!​

== Info ==

In this post, I would like to explain what kexec-hardboot patch is.

@kernel developers: Feel free to add my patch into your kernels, the patch can be found on my github: Kexec commits. You can just cherry-pick the commits, but I'll update my kernel repo with a new branch so the patch will be only 1 commit.​

== What is kexec? ==

It is syscall of Linux kernel, which allows you to boot another Linux kernel without restarting the device - "Linux boots itself". The functionality is equivalent to fastboot -c *cmdline* boot zImage initrd.img, but without PC and fastboot. It is fairly known thing, so more info at wikipedia and man kexec.

Standard kexec call unfortunatelly does not work on Nexus 4. It freezes somewhere, and it is very difficult to find out where - probably some of the drivers are not shut down/re-initialized properly, it is a commong thing among Android devices, which is why kexec-hardboot was made.​

== What is the difference between normal and hardboot exec? ==

Kexec-hardboot patch adds a real device restart to that process, so that all the drivers can be properly reinitialized. It stores new kernel to RAM, reboots the device as usual, and kernel from boot partition immediately jumps to the one which was stored to RAM before reboot.

Unlike grouper's kexec-hardboot patch, this one only requires the host kernel to be patched. This is one of the improvements I made, and I think it is pretty significant.

To sumarize the process:

kexec --load-hardboot.... is called and kernel it loaded into RAM.

kexec -e is called. Special info is written to memory (to area which is not overwritten on reboot) and the device is rebooted.

After reboot, very early in the boot process, kernel checks if that special info is present in RAM and if so, it loads new kernel from RAM and jumps to it.

Kexecd' kernel starts and boots.

For more info, read the original thread.​

== Instructions: ==

1) Download all required files:

- The host kernel

- the kexec binary

- Kexec script

- kernel files you want to kexec-hardboot

2) Then you need to fastboot flash the host kernel:

fastboot flash boot stock-290-TWRP-kexec.img

3) Put kexec binary, kexec.sh, initrd.img and zImage-dtb inside cache

4) Fire up adb and insert the following commands:

adb shell
su
cd cache
chmod 0755 kexec
sh ./kexec.sh

== Downloads: ==

- Host kernel 4.3 290 with TWRP: Sony 290 kexec host kernel

- kexec binary: kexec binary

- CM kernel to hardboot as test: cm test files

- kexec script: kexec script
​

== Authors: ==

This patch was made by Mike Kasick for Samsung Epic 4G. Since that, it was ported to several devices, one of them is Asus Transformer TF201 - I used patch from TF201 and modified it a bit (basically just changed few SoC specific constants). People at #ubuntu-arm helped me out with that, thanks.

For hammerhead, Tassadar improved the patch a bit - only the host needs to be patched now and Tassadar added support for DTB.

Last but not least for Xperia Z1 and Z Ultra I ported the patch to our sony 4.3 kernel sources. But most work was done by the awesome other devs :)

XDA:DevDB Information

[UB]Xperia Z1, ZU kexec patch v1 [18/01/14], a Tool/Utility for the Sony Xperia Z1

Contributors

krabappel2548

Version Information

Status: Testing

Current Stable Version: V1 and future versio

Stable Release Date: 2014-01-18

Created 2014-01-18

Last Updated 2014-01-18