Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,770,363 Members 46,818 Now Online
XDA Developers Android and Mobile Development Forum

[DEV] Kexecboot Bootloader with kexec-hardboot for Multiple Kernels

Tip us?
 
CalcProgrammer1
Old
(Last edited by CalcProgrammer1; Today at 05:49 PM.)
#1  
Senior Member - OP
Thanks Meter 547
Posts: 580
Join Date: Oct 2007
Location: Kansas City
Default [DEV] Kexecboot Bootloader with kexec-hardboot for Multiple Kernels

Well, it only took 2 years lol!

What is Kexec?

Kexec (kernel-execute) is a function of the Linux kernel that allows it to act as a bootloader to boot other kernels. Unfortunately, the standard implementation of kexec doesn't work quite right on most ARM devices due to poor driver support for hardware resets. The workaround is kexec-hardboot, a patch set that allows a kernel to be staged in RAM before performing an actual hardware reset through the phone's bootloader. Upon reboot the kexec-supporting kernel will check the magic location in RAM to see if a previously stored kernel is available, and if so, it will transfer execution to that kernel instead of booting itself.

Why use Kexec

It's a second-stage bootloader. The standard Android bootloader only allows two kernels to be installed at once - boot and recovery. This means that if you want a working recovery, you're only allowed one real OS kernel. If you want to dual-boot (or tri-boot or more) you're screwed. Kexec provides an answer to this. By replacing the boot kernel, kexec (with the kexecboot GUI) acts as a "second stage bootloader" allowing you to boot any number of kernels from any available storage devices. For instance, you have kexecboot in your boot partition and you can keep a kernel for Android installed in your Android system partition as well as an Ubuntu kernel and root filesystem on your SD card and be able to switch between Android and Ubuntu at boot time.

What is kexecboot

Kexecboot is a graphical front-end for kexec. I have modified it to work with the kexec-hardboot patches. It scans all available storage devices for a boot.cfg file in which you define kernels, ramdisks, and kernel commandlines. You control it using volume up and down to move cursor, power to select.

Here is a screenshot:

http://imgur.com/4GYomKX

The code

Here is my modified CM kernel source with the kexec-hardboot patch:

https://github.com/CalcProgrammer1/a...kexec-hardboot

You will need to enable:

CONFIG_KEXEC

CONFIG_KEXEC_HARDBOOT

CONFIG_ATAGS_PROC

Here is my modified kexecboot:

https://github.com/CalcProgrammer1/kexecboot

I'm still cleaning up my kexecboot initramfs which provides a nice GUI for kexec and can act as a complete bootloader. I'll post a link to that plus a prebuilt package after I clean up the random printouts that currently overtake the screen on pressing any buttons.
Samsung Galaxy Note 3 SM-900T 32GB
Samsung Galaxy Note SGH-i717 16GB
HP TouchPad 32GB
Archos 43 Internet Tablet - 16GB + 32GB mSD
Dell Axim X50v - 128MB + 16GB CF
The Following 20 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ Click to Expand ]
 
lactardjosh
Old
(Last edited by lactardjosh; 22nd July 2012 at 06:22 AM.)
#2  
lactardjosh's Avatar
Senior Member
Thanks Meter 303
Posts: 550
Join Date: Dec 2010

 
DONATE TO ME
I'll admit limited understanding of what you're accomplishing here, but seems to me that this could lead to dual booting on the Note. Nice work.

Good luck.
The Following User Says Thank You to lactardjosh For This Useful Post: [ Click to Expand ]
 
Jiggity Janx
Old
#3  
Senior Member
Thanks Meter 331
Posts: 1,391
Join Date: Feb 2010
Nice work! Thanks for the work you've done thus far. Unfortunately I have no way to help you out other than morale support!
2 Verizon G3 io-rooted stock 2 Verizon One MAX rumrunner.us s-off Note 8.0 & 3 2 OG Nexus 7 w/ CM11
 
roloracer
Old
#4  
roloracer's Avatar
Senior Member
Thanks Meter 646
Posts: 2,729
Join Date: Jul 2008
Location: Kissimmee
Quote:
Originally Posted by lactardjosh View Post
I'll admit limited understanding of what you're accomplishing here, but seems to me that this could lead to dual booting on the Note. Nice work.

Good luck.
Pretty much what it comes down to, testing kernels and roms without having to flash into nand. I can't wait for dualbooting from Sd on the Note.

I have ORD , please help!!
. Did I help you? Hit the thanks button!


Samsung Galaxy Note 3: Dynamic Kat! NC2 - 4.4.2
Samsung Galaxy Note: [ROM] JBSandwich CM9
Nexus 10: [ROM] ThunderKat 4.4.2

The Following User Says Thank You to roloracer For This Useful Post: [ Click to Expand ]
 
CalcProgrammer1
Old
#5  
Senior Member - OP
Thanks Meter 547
Posts: 580
Join Date: Oct 2007
Location: Kansas City
My main goal here is native Linux, but if kexec works then you can boot custom Android dev kernels, native Linux kernels, other mobile OS'es, etc. The SGSIII team seems to have found some interesting kexec solutions for the Verizon SGSIII due to its locked bootloader. They've posted a good deal of kexec patches which I'm trying to bring to the Note, including a custom kexec-hardboot option that fully reboots the device into the new kernel (apparently to make sure the radio and such are working).
Samsung Galaxy Note 3 SM-900T 32GB
Samsung Galaxy Note SGH-i717 16GB
HP TouchPad 32GB
Archos 43 Internet Tablet - 16GB + 32GB mSD
Dell Axim X50v - 128MB + 16GB CF
The Following 2 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ Click to Expand ]
 
jwt0044
Old
#6  
jwt0044's Avatar
Senior Member
Thanks Meter 497
Posts: 841
Join Date: May 2012
Quote:
Originally Posted by CalcProgrammer1 View Post
My main goal here is native Linux, but if kexec works then you can boot custom Android dev kernels, native Linux kernels, other mobile OS'es, etc. The SGSIII team seems to have found some interesting kexec solutions for the Verizon SGSIII due to its locked bootloader. They've posted a good deal of kexec patches which I'm trying to bring to the Note, including a custom kexec-hardboot option that fully reboots the device into the new kernel (apparently to make sure the radio and such are working).
Wonderful, wonderful work!!! :thumbup::thumbup::thumbup:

Sent from my SAMSUNG-SGH-I717 using xda premium
 
gregsarg
Old
#7  
gregsarg's Avatar
Senior Member
Thanks Meter 3489
Posts: 4,190
Join Date: Apr 2011
Location: B.F.E.
Uh...It all sounded like this:
dual kernel (i'm gonna brick) kexec will allow (me to brick my phone).....with native linux applications ('im gonna brick my phone cause i'm stupid)....LOL

while i know what your doing, that in no way means i will ever understand it...LOL
But i will thank you in advance for what sounds like a sick mod for our notes...

Many thanks Dev !!!!
" There are Givers, and there are Takers. Be a Giver, and these things will come back to you. "......................g

And please, donate to your favorite developer...
Without them, we'd be writing on rocks with a stick...g
 
CalcProgrammer1
Old
#8  
Senior Member - OP
Thanks Meter 547
Posts: 580
Join Date: Oct 2007
Location: Kansas City
Kexec is actually (if done right) a good way *not* to brick your phone. To run kernels, you usually have to flash them to a restricted boot section of the memory, and if you flash all non-working kernels (to download, recovery, and main) then you have no way to use your phone, as it won't boot up. If you use kexec, your working kernel is safely stored on the boot partition and your development kernels can be wherever, and if it doesn't boot you can just hold down POWER to hard reboot into your good kernel.

The problem is that it doesn't seem to be working, I think I have the kexec support built properly but haven't been able to boot any kernels without it crashing.
Samsung Galaxy Note 3 SM-900T 32GB
Samsung Galaxy Note SGH-i717 16GB
HP TouchPad 32GB
Archos 43 Internet Tablet - 16GB + 32GB mSD
Dell Axim X50v - 128MB + 16GB CF
The Following 4 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ Click to Expand ]
 
gregsarg
Old
#9  
gregsarg's Avatar
Senior Member
Thanks Meter 3489
Posts: 4,190
Join Date: Apr 2011
Location: B.F.E.
Quote:
Originally Posted by CalcProgrammer1 View Post
Kexec is actually (if done right) a good way *not* to brick your phone. To run kernels, you usually have to flash them to a restricted boot section of the memory, and if you flash all non-working kernels (to download, recovery, and main) then you have no way to use your phone, as it won't boot up. If you use kexec, your working kernel is safely stored on the boot partition and your development kernels can be wherever, and if it doesn't boot you can just hold down POWER to hard reboot into your good kernel.

The problem is that it doesn't seem to be working, I think I have the kexec support built properly but haven't been able to boot any kernels without it crashing.
I know you'll crack it ....
And when you do ....you'll be the galaxy note GOD !!!....LOL
your effort is much appreciated Sir ....even if I'm scared to use it , but will anyway ...lol
" There are Givers, and there are Takers. Be a Giver, and these things will come back to you. "......................g

And please, donate to your favorite developer...
Without them, we'd be writing on rocks with a stick...g
 
CalcProgrammer1
Old
#10  
Senior Member - OP
Thanks Meter 547
Posts: 580
Join Date: Oct 2007
Location: Kansas City
So I'm still confused as to why my kexec didn't work. I'm going to build a TouchPad kernel with it enabled and repeat the test on it, since I have a known-good kernel to boot against. I'll let you know how that goes.

Sent from my SAMSUNG-SGH-I717
Samsung Galaxy Note 3 SM-900T 32GB
Samsung Galaxy Note SGH-i717 16GB
HP TouchPad 32GB
Archos 43 Internet Tablet - 16GB + 32GB mSD
Dell Axim X50v - 128MB + 16GB CF

The Following 4 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ Click to Expand ]
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes