FORUMS
Remove All Ads from XDA

[dev][kernel][kexec]

186 posts
Thanks Meter: 235
 
By delewer, Senior Member on 23rd October 2013, 06:40 AM
Post Reply Email Thread
2nd January 2014, 06:14 PM |#91  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Quote:
Originally Posted by delewer

just for information...
compressed kernel with lzma his bigger than no lzma lol
4,1 Vs 4,15

so, i thave try :
kexec --load zImage.lzma --mem-min=0x0f00000000 --command-line="$(cat /proc/cmdline)"
debug: Focus 1 - argc '5' ; argv 'bea96754' ; kernel_buf 'b6bdf008' ; kernel_size '3f5414' ; info 'bea96528' ; i '1' ; file_type[i].name 'zImage'
debug: malloc - xmalloc mem_range '4511824'
Could not find a free area of memory of 3fd414 bytes...

lol ... if you could find a way to reduced size ??

Did you reserved and freed memory for kexec? Something like:
Quote:

+#if defined(CONFIG_KEXEC_HARDBOOT)
+static void kexec_hardboot_reserve(void)
+{
+ if (memblock_reserve(KEXEC_HARDBOOT_START, KEXEC_HARDBOOT_SIZE)) {
+ printk(KERN_ERR "Failed to reserve memory for KEXEC_HARDBOOT: "
+ "%[email protected]%.8X\n",
+ KEXEC_HARDBOOT_SIZE / SZ_1M, KEXEC_HARDBOOT_START);
+ return;
+ }
+ memblock_free(KEXEC_HARDBOOT_START, KEXEC_HARDBOOT_SIZE);
+ memblock_remove(KEXEC_HARDBOOT_START, KEXEC_HARDBOOT_SIZE);
+
+ kexec_hardboot_device.num_resources = ARRAY_SIZE(kexec_hardboot_resources);
+ kexec_hardboot_device.resource = kexec_hardboot_resources;
+}
+#endif

Standard kexec not working and allso kexec can boot only kexec patched kernels, so I get them only working using hard kexec, hard worked on them and finaly I had a fully working kexec for Sony Xperia Go, Sola, P and U, maybe this help -> https://github.com/munjeni/android_k.../jb-dev?page=2

I will start working on your work after I get Xperia Z1 Mini! You made a realy interesting thread, I am realy interested in this! Hope we get some progress.

And one more thing, I will backport my Boot Menu to Z1 and Z1S soon as we get kexec working! More info here -> http://forum.xda-developers.com/show....php?t=2418241
The Following 10 Users Say Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
 
 
10th January 2014, 12:17 PM |#92  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Hi, what is a curent status of our things? Is kexec boot kernel? Curent problems is?
The Following 3 Users Say Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
11th January 2014, 02:12 PM |#93  
delewer's Avatar
OP Senior Member
Flag Paris
Thanks Meter: 235
 
More
Quote:
Originally Posted by munjeni

Hi, what is a curent status of our things? Is kexec boot kernel? Curent problems is?

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
The Following 4 Users Say Thank You to delewer For This Useful Post: [ View ] Gift delewer Ad-Free
11th January 2014, 05:17 PM |#94  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Some info related to kernel. Last time when I played with kexec I found something interesting: seccond kernel (ota kernel - dumped from ota partition) booted with kexec! So that mean - host kernel loaded these stock ota kernel (seems ota kernel is allready kexec patched? But all other kernels which I tried was not abble to load by kexec because was not kexec patched! Only kexec patched kernels was abble to boot in host kernel!). So I think before you try to load an kernel you need to patch these kernel. You can try: try to build stock kernel, than see what is missing in .config, than enable missing defconfig things (things needed for kexec - but try to build them as a module - if something fail to build as a module, try to add missing things (there will be a lot of problems aka duplicate symbols, missing symbols...blabla, but I think we can get them working). I will try soon as I get Z1 Compat.

Another thing which I found in ramdisk init script: there was a service aka kexec.dyn (have no idea whats usage of them since there was no these binary in /system/bin). Maybe you can check them in your ramdisk (probably thats related to the ota kernel ramdsk - I not checked).

Do you have a kernel git? Just want to see reboot code.
The Following 3 Users Say Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
11th January 2014, 06:00 PM |#95  
delewer's Avatar
OP Senior Member
Flag Paris
Thanks Meter: 235
 
More
Quote:
Originally Posted by munjeni

Some info related to kernel. Last time when I played with kexec I found something interesting: seccond kernel (ota kernel - dumped from oem partition) booted with kexec! So that mean - host kernel loaded these stock oem kernel (seems ota kernel is allready kexec patched?

Are you sure it's an ota kernel ? Not a part of bootloader you run and launch the stock kernel ? (ota process ??)
If it's really a safe kernel (may be a secured kernel to unbrick device by sony), without sources it's useless... but interresting to see and to test kexec tool

Quote:
Originally Posted by munjeni

But all other kernels which I tried was not abble to load by kexec because was not kexec patched! Only kexec patched kernels was abble to boot in host kernel!). So I think before you try to load an kernel you need to patch these kernel.

I know that. You have my kexec zip patch for stock kernel attached in zip, into last post.(compatible with Doomkernel, because DooMLoRD use the stock sony kernel, and mod it)

Quote:
Originally Posted by munjeni

You can try: try to build stock kernel, than see what is missing in .config, than enable missing defconfig things (things needed for kexec - but try to build them as a module - if something fail to build as a module, try to add them (there will be a lot of problems aka duplicate symbols, missing symbols...blabla, but I think we can get them working). I will try them soon as I get Z1 Compat.

I know that. I have use a lot of sony official sources to adapt kexec module from Sony kexec.
And, of course, i have compil Sony official kernel because you need to build the "dt.img" file.


Quote:
Originally Posted by munjeni

Another thing which I found in ramdisk init script: there was a service aka kexec.dyn (have no idea whats usage of them since there was no binary in /system/bin). Maybe you can check them in your ramdisk (probably thats related to the oem kernel ramdsk - I not checked).

Outch.. nether see that... really interesting...


Quote:
Originally Posted by munjeni

Do you have a kernel git? Just want to see reboot code.

No, i don't have official git...


I use Doomlord Git to have a custom kernel to test (may be i can try with CM11 kernel too, but not now)
I use Sony Zip to install official kernel. I have .257 kernel, and not the last, because i wait for succes before update my stock kernel (i don't want to brick something by accident)

My rebbot code is in the patch (in one of 3 zips).
My patch is not a diff... it's the sources you replace into directories. It's better i thinks to work.
The Following User Says Thank You to delewer For This Useful Post: [ View ] Gift delewer Ad-Free
12th January 2014, 03:02 PM |#96  
DooMLoRD's Avatar
Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,836
 
Donate to Me
More
Quote:
Originally Posted by munjeni

Some info related to kernel. Last time when I played with kexec I found something interesting: seccond kernel (ota kernel - dumped from ota partition) booted with kexec! So that mean - host kernel loaded these stock ota kernel (seems ota kernel is allready kexec patched? But all other kernels which I tried was not abble to load by kexec because was not kexec patched! Only kexec patched kernels was abble to boot in host kernel!). So I think before you try to load an kernel you need to patch these kernel. You can try: try to build stock kernel, than see what is missing in .config, than enable missing defconfig things (things needed for kexec - but try to build them as a module - if something fail to build as a module, try to add missing things (there will be a lot of problems aka duplicate symbols, missing symbols...blabla, but I think we can get them working). I will try soon as I get Z1 Compat.

Another thing which I found in ramdisk init script: there was a service aka kexec.dyn (have no idea whats usage of them since there was no these binary in /system/bin). Maybe you can check them in your ramdisk (probably thats related to the ota kernel ramdsk - I not checked).

Do you have a kernel git? Just want to see reboot code.

Bootloader won't allow booting of kernels off FOTAKernel partition... Though you should be able.to use that space other wise...

Sent from my C6902 using xda app-developers app
12th January 2014, 03:16 PM |#97  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Quote:
Originally Posted by delewer

Are you sure it's an ota kernel ? Not a part of bootloader you run and launch the stock kernel ? (ota process ??)
If it's really a safe kernel (may be a secured kernel to unbrick device by sony), without sources it's useless... but interresting to see and to test kexec tool

Yes I booted ota kernel! Steps was: dumped ota kernel partition, extracted only kernel from dump, created ramdisk image using ramdisk from "stock kernel", separated ota kernel + ramdisk into new directory - for kexec boot, booted these ramdisk and these ota kernel using kexec, got them booted!
The Following User Says Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
12th January 2014, 03:22 PM |#98  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Quote:
Originally Posted by DooMLoRD

Bootloader won't allow booting of kernels off FOTAKernel partition... Though you should be able.to use that space other wise...

Sent from my C6902 using xda app-developers app

Just for info I have erased these partition and I can create new partition there! So allso I think these partition can be mounted for something, for example you can store there recovery ramdisk and an kernel for booting them with kexec! If you realy need more info please search in xperia go forum (sorry, I forgot where I posted them, maybe in general section?!) where I created a thread related to custom partitioning on xperia go (changed userdata, cache...etc size, merged 2 unused partitons, increased data, created custom one...blabla!).

Edit:
found my post -> http://forum.xda-developers.com/show...2418241&page=8
The Following User Says Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
12th January 2014, 03:50 PM |#99  
bulanula's Avatar
Senior Member
Flag London
Thanks Meter: 12
 
More
Quote:
Originally Posted by munjeni

Just for info I have erased these partition and I can create new partition there! So allso I think these partition can be mounted for something, for example you can store there recovery ramdisk and an kernel for booting them with kexec! If you realy need more info please search in xperia go forum (sorry, I forgot where I posted them, maybe in general section?!) where I created a thread related to custom partitioning on xperia go (changed userdata, cache...etc size, merged 2 unused partitons, increased data, created custom one...blabla!).

Edit:
found my post -> http://forum.xda-developers.com/show...2418241&page=8

So what does this mean ?

Is it possible to use this for kexec on other phones like Xperia P ?

I also saw this in my dmesg from Xperia P :

Code:
[ 5.787506] init: cannot find '/system/xbin/kexec.dyn', disabling 'kexec'
Maybe we can put something at that location so the init finds the file and does not disable kexec for kernel ?
12th January 2014, 04:03 PM |#100  
munjeni's Avatar
Senior Member
Thanks Meter: 21,318
 
Donate to Me
More
Quote:
Originally Posted by bulanula

So what does thi...

My kernel already support sola,go,p,u and kexec allready working on these phones! Please find a proper thread to post any question since our thread is for Z1 only! Search in P forum for kexec thread!
The Following User Says Thank You to munjeni For This Useful Post: [ View ] Gift munjeni Ad-Free
12th January 2014, 05:02 PM |#101  
DooMLoRD's Avatar
Inactive Recognized Developer
Flag Pune
Thanks Meter: 39,836
 
Donate to Me
More
Quote:
Originally Posted by munjeni

Just for info I have erased these partition and I can create new partition there! So allso I think these partition can be mounted for something, for example you can store there recovery ramdisk and an kernel for booting them with kexec! If you realy need more info please search in xperia go forum (sorry, I forgot where I posted them, maybe in general section?!) where I created a thread related to custom partitioning on xperia go (changed userdata, cache...etc size, merged 2 unused partitons, increased data, created custom one...blabla!).

Edit:
found my post -> http://forum.xda-developers.com/show...2418241&page=8

Nice

Sent from my C6902 using xda app-developers app
The Following User Says Thank You to DooMLoRD For This Useful Post: [ View ] Gift DooMLoRD Ad-Free
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes