[DEV] Kexec-hardboot

Search This thread

Olivier

Recognized Developer / Retired Forum Moderator
Nov 6, 2011
2,657
6,886
PREAMBLE
Just to clear things up - I'm definitely not responsible for anything. This patch will not work on devices with locked bootloaders.

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 flo, I've improved the patch a bit - only the host needs to be patched now and I also fixed a bug with /proc/atags not reading all tags.

Thanks to omnirom - I used their kernel as a base.
Special thanks to Tasssadar for his kexec-hardboot patch for the Nexus 4. Also thanks to alvinhochun and krabappel2548. I borrowed some of their code. :)


WHAT'S 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 kexec?
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:
  1. kexec --load-hardboot.... is called and kernel it loaded into RAM.
  2. kexec -e is called. Special info is written to memory (to area which is not overwritten on reboot) and the device is rebooted.
  3. 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.
  4. Kexecd' kernel starts and boots.
For more info, read the original thread.



INSTRUCTIONs
  1. Download kexec-hardboot-yuga.zip and unzip it
  2. Flash my patched host kernel (kexec-kernel-20140808-yuga.zip)
  3. Push initrd.img, kexec, kexec.sh and zImage to /cache
  4. Use a terminal to do the following:
    Code:
    adb shell
    su
    cd cache
    chmod 0755 kexec
    sh ./kexec.sh



SOURCEs
Kexec-hardboot patch
Kernel

XDA:DevDB Information
Kexec-hardboot patch for Sony Xperia Z, Tool/Utility for the Sony Xperia Z

Contributors
Olivier

Version Information
Status: Testing

Created 2014-08-08
Last Updated 2014-08-08
 

Olivier

Recognized Developer / Retired Forum Moderator
Nov 6, 2011
2,657
6,886
  • Like
Reactions: xarive

AngelBob

Senior Member
Jun 23, 2013
275
628
Can we load some other kernal on our devices using kexec without unlocking bootloader??
I had a Motorola atrix 2 which used to do this..:fingers-crossed:

No, LB Yuga's are missing kexec, even compiling a external kernel module is not possible as the zimage is missing some required symbols for kexec to work.
 
  • Like
Reactions: shoey63

gouster3

Senior Member
Oct 22, 2014
298
101
Levice
Hi. I want to split two kernels. cyanogenmod and multirom (not for xperia z.)
i have kexec, and it working under multirom kernel.
i have edited one kernel, to load init file from another.
I am trayed zimage from multirom kernel.
Now i cannot run both. i can run cm12 kernel, and rut multirom from there, but cm12 wont boot.
when i used zimage from cm12 kernel, i can boot into cm12, but not in multirom.

is there any command to kexec to load another zimage only, and run another init file?
i have init (cm12) and from there i can use sh commands. i want load initmr (multirecovery) with another zimage file.
is it possible?
 

vishal_android freak

Inactive Recognized Developer / Recognized Contrib
Dec 30, 2012
1,898
5,637
Mumbai
Hi. I want to split two kernels. cyanogenmod and multirom (not for xperia z.)
i have kexec, and it working under multirom kernel.
i have edited one kernel, to load init file from another.
I am trayed zimage from multirom kernel.
Now i cannot run both. i can run cm12 kernel, and rut multirom from there, but cm12 wont boot.
when i used zimage from cm12 kernel, i can boot into cm12, but not in multirom.

is there any command to kexec to load another zimage only, and run another init file?
i have init (cm12) and from there i can use sh commands. i want load initmr (multirecovery) with another zimage file.
is it possible?
Ok... What?
 
  • Like
Reactions: Olivier

Top Liked Posts

  • There are no posts matching your filters.
  • 13
    PREAMBLE
    Just to clear things up - I'm definitely not responsible for anything. This patch will not work on devices with locked bootloaders.

    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 flo, I've improved the patch a bit - only the host needs to be patched now and I also fixed a bug with /proc/atags not reading all tags.

    Thanks to omnirom - I used their kernel as a base.
    Special thanks to Tasssadar for his kexec-hardboot patch for the Nexus 4. Also thanks to alvinhochun and krabappel2548. I borrowed some of their code. :)


    WHAT'S 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 kexec?
    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:
    1. kexec --load-hardboot.... is called and kernel it loaded into RAM.
    2. kexec -e is called. Special info is written to memory (to area which is not overwritten on reboot) and the device is rebooted.
    3. 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.
    4. Kexecd' kernel starts and boots.
    For more info, read the original thread.



    INSTRUCTIONs
    1. Download kexec-hardboot-yuga.zip and unzip it
    2. Flash my patched host kernel (kexec-kernel-20140808-yuga.zip)
    3. Push initrd.img, kexec, kexec.sh and zImage to /cache
    4. Use a terminal to do the following:
      Code:
      adb shell
      su
      cd cache
      chmod 0755 kexec
      sh ./kexec.sh



    SOURCEs
    Kexec-hardboot patch
    Kernel

    XDA:DevDB Information
    Kexec-hardboot patch for Sony Xperia Z, Tool/Utility for the Sony Xperia Z

    Contributors
    Olivier

    Version Information
    Status: Testing

    Created 2014-08-08
    Last Updated 2014-08-08
    1
    I'm sorry I would like to ask a question. If I kexec boot my phone with yuga kernel and cwm, flashes the yuga ROM would it be possible to get dual booting the Yuga ROM?

    Source: http://forum.xda-developers.com/showpost.php?p=19460677&postcount=25
    Pretty old source but would it be possible?
    Sure thing :)

    Gesendet von meinem Xperia Z mit Tapatalk
    1
    Can we load some other kernal on our devices using kexec without unlocking bootloader??
    I had a Motorola atrix 2 which used to do this..:fingers-crossed:

    No, LB Yuga's are missing kexec, even compiling a external kernel module is not possible as the zimage is missing some required symbols for kexec to work.
    1
    Hi. I want to split two kernels. cyanogenmod and multirom (not for xperia z.)
    i have kexec, and it working under multirom kernel.
    i have edited one kernel, to load init file from another.
    I am trayed zimage from multirom kernel.
    Now i cannot run both. i can run cm12 kernel, and rut multirom from there, but cm12 wont boot.
    when i used zimage from cm12 kernel, i can boot into cm12, but not in multirom.

    is there any command to kexec to load another zimage only, and run another init file?
    i have init (cm12) and from there i can use sh commands. i want load initmr (multirecovery) with another zimage file.
    is it possible?
    Ok... What?
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone