Post Reply

[UTIL] Kexecboot Bootloader for Galaxy Note i717 - Boot Multiple Kernels

OP CalcProgrammer1

21st July 2012, 10:53 PM   |  #1  
OP Senior Member
Flag Kansas City
Thanks Meter: 720
 
632 posts
Join Date:Joined: Oct 2007
More
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

http://imgur.com/4GYomKX

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.

Download

Get it here: https://mega.co.nz/#F!0ct3EaTD!wHWnGo1M_2smyKdzGMIYmw

The code

Kernel builder: https://github.com/CalcProgrammer1/k...uincyatt_kexec

This repository contains all the things you need to build a flashable kexecboot/kexec-hardboot enabled kernel image. It contains the ramdisk with the kexecboot binary and a script to package a flashable zip file. Included as submodules are the kernel source itself (kexec-hardboot branch, required to build the image) and the kexecboot source (optional, not used by default as you must build it using an ARM system, a pre-built binary is included if you don't want to build your own). The kernel source includes a defconfig called kexec_quincyatt_defconfig that sets the required config options for building a kexec-hardboot kernel.

Kexecboot Configuration File

Kexecboot replaces your boot kernel, so when you power up your phone it will go straight to the Kexecboot screen. The issue is now to provide kernels for kexecboot to boot into. This requires some work on your part, as you will have to store the kernel files (zImage and initrd) in a partition and write a configuration file to tell kexecboot where they are. This configuration file may contain multiple kernels, allowing you to have several different kernels available for the same OS or multiple OSes entirely. If you're coming from an Android system that distributes their kernel as a boot.img, you can use the abootimg program to extract it into a separate zImage and initrd.img binary.

The configuration file must be located on the path /boot/boot.cfg. This is relative to whatever partition/disk you are on, so for instance if you're setting up Android to boot from kexecboot, you would put your configuration file in /system/boot/boot.cfg (/data/boot/boot.cfg would work as well). You can also put a boot.cfg file on your SD card as long as you follow the /boot/boot.cfg path. Kexecboot automatically scans all available partitions for a boot.cfg file before it starts and builds a list of all available kernels across all detected boot.cfg files, so you may have Android in your /system partition and Debian on your SD card and both kernel lists will be shown together.

The Kexecboot web site provides a nice tutorial: http://kexecboot.org/documentation/how_to_write_config

The Note i717 bootloader passes a fairly long string of kernel arguments to the boot kernel. Since kexecboot overrides this for the kexec-booted kernel, you must provide this boot string in your boot.cfg file. Additionally, you may edit or add arguments to the command string here (such as setting console=tty0 instead of the default console=null so you can use the framebuffer console).

For example, here is my /system/boot/boot.cfg for CyanogenMod 11 (with kernel and initrd.img, extracted via abootimg, in /system/boot/)

Code:
# kexecboot configuration file

# CM11 default kernel
LABEL=CyanogenMod 11
KERNEL=/boot/zImage
INITRD=/boot/initrd.img
APPEND="androidboot.hardware=qcom usb_id_pin_rework=true no_console_suspend=true zcache sec_log=0x80000@0x40270008 sec_dbg=0x100000@0x402f000c sec_debug.reset_reason=0x1a2b3c00 pmem_sf_addr=0x7a000000 pmem_sf_size=0x6000000 console=null sec_debug.enable=0 sec_debug.enable_user=0 appsbark=0 msm_watchdog.enable=1 msm_watchdog.bark_time=30 msm_watchdog.bite_time=31 vmalloc=512m hw_rev=12 lpj=67702 androidboot.emmc=true androidboot.serialno=32c245ca androidboot.baseband=csfb"
I'm not sure how much of that you actually need, but you do need at least some of it because with an empty APPEND= it does not boot. You also do have to put the quotation marks around it or else parsing of one of the options will fail.
Last edited by CalcProgrammer1; 5th September 2014 at 04:10 AM.
The Following 21 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ View ]
22nd July 2012, 03:14 AM   |  #2  
lactardjosh's Avatar
Senior Member
Thanks Meter: 303
 
550 posts
Join Date:Joined: Dec 2010
Donate to Me
More
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.
Last edited by lactardjosh; 22nd July 2012 at 06:22 AM.
The Following User Says Thank You to lactardjosh For This Useful Post: [ View ]
22nd July 2012, 05:46 PM   |  #3  
Senior Member
Thanks Meter: 335
 
1,392 posts
Join Date:Joined: Feb 2010
More
Nice work! Thanks for the work you've done thus far. Unfortunately I have no way to help you out other than morale support!
23rd July 2012, 12:16 AM   |  #4  
roloracer's Avatar
Senior Member
Flag Kissimmee
Thanks Meter: 649
 
2,734 posts
Join Date:Joined: Jul 2008
More
Quote:
Originally Posted by lactardjosh

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!!
The Following User Says Thank You to roloracer For This Useful Post: [ View ]
23rd July 2012, 12:59 AM   |  #5  
OP Senior Member
Flag Kansas City
Thanks Meter: 720
 
632 posts
Join Date:Joined: Oct 2007
More
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).
The Following 2 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ View ]
23rd July 2012, 01:04 AM   |  #6  
jwt0044's Avatar
Senior Member
Thanks Meter: 497
 
844 posts
Join Date:Joined: May 2012
More
Quote:
Originally Posted by CalcProgrammer1

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
23rd July 2012, 08:57 PM   |  #7  
gregsarg's Avatar
Senior Member
Flag B.F.E.
Thanks Meter: 3,635
 
4,334 posts
Join Date:Joined: Apr 2011
More
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 !!!!
24th July 2012, 01:01 AM   |  #8  
OP Senior Member
Flag Kansas City
Thanks Meter: 720
 
632 posts
Join Date:Joined: Oct 2007
More
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.
The Following 4 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ View ]
25th July 2012, 03:18 AM   |  #9  
gregsarg's Avatar
Senior Member
Flag B.F.E.
Thanks Meter: 3,635
 
4,334 posts
Join Date:Joined: Apr 2011
More
Quote:
Originally Posted by CalcProgrammer1

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
3rd August 2012, 07:26 PM   |  #10  
OP Senior Member
Flag Kansas City
Thanks Meter: 720
 
632 posts
Join Date:Joined: Oct 2007
More
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

The Following 4 Users Say Thank You to CalcProgrammer1 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes