[Xperia Z1 Original Android Development] delewer:
Thx for your interest.

My current Pb is not in kexec patch (hardboot) itself, or kernel patching. It not a real challege to patch the guest kernel to boot into.

My problem is, i haven't a host custom kernel because my bootloader is locked, and can't be unlocked.

So, to use kexec tool, i must create a kernel module to use kexec function.

Stock Z1 kernel don't have kexec_load function, and the module must recode this part of custom kernel (with little of hardboot patch of course)

Few function are missing in symlink too

Eg,

smp_send_stop function

soft_restart function

setup_mm_for_reboot function

etc...

I use a custom patch to call some stock function, and a internal patch in module itself

Eg :

echo 1 > /proc/sys/kernel/kptr_restrict

grep soft_restart /proc/kallsyms

This, give me the address to call function, i have coded in kexec module

But, i have a last and hard pb to solve i can't found how.

I use EXTERN var adresses to call asm function (famous relocate_kernel.s)

But i don't anderstand why, this cause kernel panic in kexec.

Eg :

if i code (in machine_kexec) :

static unsigned long kexec_start_address;

static unsigned long kexec_indirection_page;

static unsigned long kexec_mach_type;

static unsigned long kexec_boot_atags;

Of course, var are all initilized to 0x0, and can't be used in relocate_kernel (are allway init to 0x0)

No kernel panic at init in machine_kexec.

If i declare

extern unsigned long kexec_start_address;

extern unsigned long kexec_indirection_page;

extern unsigned long kexec_mach_type;

extern unsigned long kexec_boot_atags;

I can see in machine_kexec the vars from relocate_kernel, but i have a kernel panic if i try to modify a var.

Eg :

kexec_start_address = image->start;

Cause a kernel panic.

To test, i force values in relocate_kernel itslef with my calculate values from a hardboot test.

This cause another kernel panic at the first use of relocate_kernel adress

Eg :

extern const unsigned char relocate_new_kernel[];

extern const unsigned int relocate_new_kernel_size;

(force call to test)

void (*my_relocate)(void) = (void *)reboot_code_buffer_phys;

my_relocate();

cause kernel panic (unabled to handle paging request at ...)

void (*my_relocate)(void) = (void *)relocate_new_kernel;

my_relocate();

cause kernel panic (unabled to handle paging request at ...)

So it's very strange, and hard to fix.

To test, i use scripts i call from DualBoot and recovery TWRP

I give you last version i use (with a looooot of display in it, to give me indications for debug)

If you can help...

May be my Pbs are easy to solve by gcc options, but... i don't know where to see..

To compil Tools you must to have a host and guest kernels

Eg (from my include script) "compil-kexec" :

** Pre-requisite : sudo apt-get install gcc-arm-linux-gnueabi

** Pre-requisite : sudo apt-get install android-tools-adb

**

** Pre-requisite : you must compil stock kernel to adapt module for your kexec :

** Pre-requisite : eg - cd Sony_official_kernel_sources/14.1.G.2.257/kernel

** Pre-requisite : eg - export ARCH=arm

** Pre-requisite : eg - export CROSS_COMPILE=/usr/bin/arm-linux-gnueabi-

** Pre-requisite : eg - make rhine_honami_row_defconfig

** Pre-requisite : eg - make

My script do everything for you (transfert to phone by wifi or usb too)

it's include in zip

And here my kernel patch (with last fix)

I don't know if an unlocked stock kernel have the same Pbs (kernel panic when i use extern addresses)

May be a unlocked kernel work perfectly with this kexec module....

I think it's a lot easy with a custom allready patched host kernel like with your xperia P, G etc...

Another thing about kexec tool :

Z1 don't have a atags systems, bootloader speak with kernel.

We use a dt.img (device_tree image)

We use device_tree by R2 asm var as same as atags, but we must log this dt.img in memory.

This log in memory use a magic number with a offset i fix (0x800)

I have create a code to do that in kexec tool (not module).

Thx