[SOLVED] Help building a custom kernel... - Lenovo Zuk Z2 Pro Questions & Answers

Whatever I do, my custom build kernels fail to boot. There's the ZUK logo very briefly, then device drops to bootloader screen. I'm out of ideas what I'm doing wrong, maybe someone here can give me a hint. :good:
I've tried with current AEX kernel git snapshot and also stock kernel sources. Building using the AEX_defconfig goes ok, I have Image.gz, replace it in previously extracted "stock" boot image and use mkbootimg.py to rebuild the new image. Offsets etc. are all correct (I think), like this: (from AEX)
Code:
kernel=kernel
ramdisk=ramdisk
page_size=4096
kernel_size=9101281
ramdisk_size=2671109
base_addr=0x80000000
kernel_offset=0x00008000
ramdisk_offset=0x01000000
tags_offset=0x00000100
cmd_line='androidboot.hardware=qcom ehci-hcd.park=3 lpm_levels.sleep_disabled=1 [email protected] buildvariant=userdebug'
board=""
format=gzip
But the damn new image won't boot, like described above. There has to be something (probably very stupid) I'm missing...
If I replace my own Image.gz with the originally extracted one and mkboot and so on, it's ok. So I guess it has something to do with my kernel build and/or environment. Are there any subsequent steps needed to do with the compiled kernel Image.gz? Or is it just my kernel config which is wrong? But I'm using the AEX defconfig (n7x-caf_z2_row_defconfig, to be exactly) so this should be fine, no?

Ok, I've got it. I had forgottten (=didn't know about at all) to append the device tree blob (arch\arm64\boot\dts\qcom\msm8996-v3-pmi8996-mtp.dtb) to kernel zImage... Simply cat'ing these together works!

Goodluck bro.

void23 said:
Ok, I've got it. I had forgottten (=didn't know about at all) to append the device tree blob (arch\arm64\boot\dts\qcom\msm8996-v3-pmi8996-mtp.dtb) to kernel zImage... Simply cat'ing these together works!
Click to expand...
Click to collapse
please explain .. what exactly i need to do with that file..

Related

CM9 boot.img source

Hi,
Could anybody tell me which are the bare minimum sources needed to compile a working cyoanogenmod 9 kernel boot.img?
I'm currently trying to compile one on my own but I can't afford to download the whole CM9 source due to the internet contract i have.
Thanks
Nobody? Ok then... May someone please copy and paste their makefile inside the root directory of his Android tree? (the one from wich they issue the command "make -j4 out/target/product/galaxysmtd/boot.img").
Maybe you could try cloning the android_build project and the teamhacksung buildscript project as well. Then adjust the buildscripts to point to the correct toolchain directory...
Boot.img contains the kernel. Therefore you need the kernel sources since at cm9 the kernel is build while compiling cm. You can find that sources at github (in project kernel_samsung_aries or something). You need to put this directory to your root directory of your android build system (there you have the device dir, frameworks, vendor etc). Rename it into kernel/samsung/aries. Then you should be able to build. It has worked like this for i9001, and it should also for i9000
You could also look at the kernel source of semaphore/devil. They use their own build script which does not require the full cm9 source, but only the kernel source. I made an adapted version of their scripts to build my own kernel...
Verstuurd van mijn GT-I9000
I think he already has:
__Pol__ said:
Nobody? "make -j4 out/target/product/galaxysmtd/boot.img"
Click to expand...
Click to collapse
Thanks everybody!
Sorry if the first two posts misled you.
I already have the kernel source. What I need are some instructions in order to build the boot.img from them. I can't download the whole source branch because I'm on a data diet .
Also a copy paste of the main make file is accepted.
I think this could help you:
http://forum.xda-developers.com/showthread.php?p=28096022
It's again for i9001 (sorry, but I own one ), but should also work
I think this could help you:
http://forum.xda-developers.com/show...php?p=28096022
It's again for i9001 (sorry, but I own one ), but should also work
Click to expand...
Click to collapse
Thanks. I've already tried the split_bootimg.pl but it did not work. According to sbuild.sh from semaphore kernel what i need to do is just "cp bzImage boot.img". I had already done it before but my phone did not boot up. It showed the bootloader logo but then nothing so something is wrong with the initramfs. Is the one included with the kernel sources correct or am I missing something?
So you can build the kernel? And just copying the kernel image to boot.img won't work. As you can see in the splitted boot.img from arco or anyone else, there are some other things needed.
I think you need to split it, replace the kernel image (zImage I thinl) and put all files again together (including the other files from the working boot.img).
No warranty on that, but that's what I understood
hahnjo said:
So you can build the kernel? And just copying the kernel image to boot.img won't work. As you can see in the splitted boot.img from arco or anyone else, there are some other things needed.
I think you need to split it, replace the kernel image (zImage I thinl) and put all files again together (including the other files from the working boot.img).
No warranty on that, but that's what I understood
Click to expand...
Click to collapse
Actually I can't split the boot.img because split_bootimg.pl does not work. The problem is in the initramfs and that is why I was asking for some advice about the sources needed. The auto-generated initramfs does not work.
__Pol__ said:
Actually I can't split the boot.img because split_bootimg.pl does not work. The problem is in the initramfs and that is why I was asking for some advice about the sources needed. The auto-generated initramfs does not work.
Click to expand...
Click to collapse
When I tried it, it worked... Are you sure that you have Pearl installed. Which OS do you use?
How do you generate initramfs?
I'm running Debian wheezy, pearl is installed. The script says it has not found android magic. The initramfs is automatically generated by the kernel source. I fear some files are missing here: https://github.com/CyanogenMod/android_kernel_samsung_aries
Do I need to get *bootimg from here?
https://github.com/CyanogenMod/android_device_samsung_aries-common
If yes how do I use these 2 scripts?
Sorry they're not two scripts but a script and a make file. From where does that makefile obtain the variables?
For splitting, did you use a running boot.img, e.g. from CM9 for your device?
You have two possibilities for building a running boot.img:
1) It is builded if you compile CM or AOSP or another ROM from Source (therefore you would need the complete sources)
2) You only build the Kernel and put it in an existing boot.img (for your phone of course) by just replacing the kernel.
For second you need to split an existing boot.img
Hi
Sent from my GT-S5830 using xda app-developers app
hahnjo said:
For splitting, did you use a running boot.img, e.g. from CM9 for your device?
You have two possibilities for building a running boot.img:
1) It is builded if you compile CM or AOSP or another ROM from Source (therefore you would need the complete sources)
2) You only build the Kernel and put it in an existing boot.img (for your phone of course) by just replacing the kernel.
For second you need to split an existing boot.img
Click to expand...
Click to collapse
Well, actually there's a third method. I need the initramfs source, the kernel source and the recovery source. After building I need to pack them together. Until yesterday I had only the sources for kernel and initramfs (?). Now I'll head for some sources for the recovery but I still need the main makefile (inside the Android directory) to know what commands I have to issue.
Sorry guys if I stil can't explain my problem to you. I really appreciate your patience and your helpful tips though.
You could look at devil/semaphore, as they use a complete initramfs, including recovery (both have a slightly different implementation).
Verstuurd van mijn GT-I9000
kasper_h said:
You could look at devil/semaphore, as they use a complete initramfs, including recovery (both have a slightly different implementation).
Verstuurd van mijn GT-I9000
Click to expand...
Click to collapse
Yep! I had a look there and I understood I was missing the recovery. Semaphore uses a custom amde initramfs and recovery whith load of scripts I don't need. I downloaded the CWM source from cyanogenmod git. There is only an Android.mk that obviously won't work. The question still remains: has anybody here downloaded the whole cyanogenmod source? If yes, may they post the makefile here please?
I have the whole CM sources, CM7 and CM9. Atm I can't access them because I'm on travel. I will return next week, maybe then.
Though, I think that it is impossible to extract the needed Makefiles. The Main-Makefile includes another makefile, but from then on several files are included which include again files. I stopped trying to understand it after the first 3 files...

[DEV] Kexec-hardboot

PREAMBLE
Just to clear things up - I'm definitely not responsible for anything. This patch will not work on devices with locked bootloaders.
Tasssadar said:
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.
Click to expand...
Click to collapse
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?
Tasssadar said:
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.
Click to expand...
Click to collapse
What is the difference between normal and hardboot kexec?
Tasssadar said:
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:
kexec --load-hardboot.... is called and kernel it loaded into RAM.
kexec -e is called. Special info is written to memory (to area which is not overwritten on reboot) and the device is rebooted.
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.
Kexecd' kernel starts and boots.
For more info, read the original thread.
Click to expand...
Click to collapse
INSTRUCTIONs
Download kexec-hardboot-yuga.zip and unzip it
Flash my patched host kernel (kexec-kernel-20140808-yuga.zip)
Push initrd.img, kexec, kexec.sh and zImage to /cache
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
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?
xarive said:
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?
Click to expand...
Click to collapse
Sure thing
Gesendet von meinem Xperia Z mit Tapatalk
Nice to see you got a Z now.
Will try this one out definitly
Sweet! Trying this out straight after work!
Beans
I am still not quite clear about dual booting with kexec. Did OP done it before?
Sent from my C6603 using Tapatalk 2
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:
siddhesh1609 said:
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:
Click to expand...
Click to collapse
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.
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?
gouster3 said:
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?
Click to expand...
Click to collapse
Ok... What?
vishal_android freak said:
Ok... What?
Click to expand...
Click to collapse
Is there any arguments for kexec to reboot with another zimage, and exec? i want to run initmr (init file)?
but without ramdisk wipe. (or load ramdisk from kernel partition)?? init file with zimage are there.
when i use "exec /initmr", it will boot, but touch not working, and i have screen-shift bug.
Or. another way. how i can get "hot boot" into some boot.img using kexec on my build-in kernel?

How do you compile a boot.img from a kernel source?

With the Note 3 using device tree (dtb) files, what is the new process to create a bootable kernel image without having to build the entire Android stack along with it? I'm working on porting kexec-hardboot to the CyanogenMod hlte kernel. I've compiled my kernel and it produces a zImage and a zImage-dtb. It also provides several msm8974-sec-hlte-r0X.dtb files in the arch/arm/boot directory which I assume are the compiled device tree images for the various HLTE revisions. I extracted a working kernel using the tools here: https://bitbucket.org/itsmikeramsay/mkbootimg/src and examined the extracted dt.img in a hex editor to find that it appears to contain all of these dtb files together. What tool is used to build this combined dtb image? I tried repacking the kernel I extracted with only my new initramfs (containing the kexecboot binary) and that worked, but repacking it with my new kernel (zImage) along with the old dt.img did not.
EDIT 1: I found this: http://forum.xda-developers.com/showthread.php?t=2469510 Looks like it could be what I'm after.
below, good luck
CalcProgrammer1 said:
With the Note 3 using device tree (dtb) files, what is the new process to create a bootable kernel image without having to build the entire Android stack along with it? I'm working on porting kexec-hardboot to the CyanogenMod hlte kernel. I've compiled my kernel and it produces a zImage and a zImage-dtb. It also provides several msm8974-sec-hlte-r0X.dtb files in the arch/arm/boot directory which I assume are the compiled device tree images for the various HLTE revisions. I extracted a working kernel using the tools here: https://bitbucket.org/itsmikeramsay/mkbootimg/src and examined the extracted dt.img in a hex editor to find that it appears to contain all of these dtb files together. What tool is used to build this combined dtb image? I tried repacking the kernel I extracted with only my new initramfs (containing the kexecboot binary) and that worked, but repacking it with my new kernel (zImage) along with the old dt.img did not.
EDIT 1: I found this: http://forum.xda-developers.com/showthread.php?t=2469510 Looks like it could be what I'm after.
Click to expand...
Click to collapse
I struggled with this for like a month. Download me
This is an updated version of the mkbootimg tools with support for device tree images. I think this is exactly what your looking for. You should be able to just overwrite the zImage and proper headers and it'll boot. Good luck! Message me if you have any issues. The older mkbootimg has issues parsing the device tree tables since it doesn't recognize them.
I got it working. The tools I posted work as well (not sure if they're the same or not, didn't check). My problem was not my build process but that my kernel/ramdisk made boot.img too large (>11.0MB) which made it fail to boot. I enabled XZ compression instead of LZMA and that took 3MB off my kernel size and allowed my build to fit, then it worked fine.
How to use the tools suggested
I was able to use xiaolu/mkbootimg_tools to create a recovery image, and flash my phone successfully. I want to know how to create a boot.img with code that I have compiled myself. I created my own dt.img, thanks to Xiaolu, and placed it in the recovery image mentioned above. I am trying to port a compiled code into my phone.

[CM13] Hammerhead source build stuck at google logo

I'm trying to make a CM13 build for my D821. repo has all the dependencies, device tree and kernel in local manifest and the only thing missing from the tree that make seems to complain about are the bootloader.img and radio.img but I flash them separately anyways.
Even though the build goes successfully and the generated images are much like the ones from the official snapshot (albeit system being smaller in size and missing some packages) it just doesn't boot past the google logo.
I've tried both the generated cm-13.0-20160428-UNOFFICIAL-hammerhead.zip and cm_hammerhead-ota-b324db6001.zip with the recovery.img and they flash fine through storage or sideload but when I reboot the device is stuck at the Google logo.
I've tried flashing all the images separately with fastboot and still the same result so I'm thinking it's a problem with boot.img. I followed all the directions on the wiki to the letter.
Also, repo syncs 100% and my first sync had no interruptions whatsoever and I wasn't using --force-sync so I'm sure I have the full tree without anything missing. Was there maybe some step specific to CM that was left out on the wiki?
EDIT: I tried boot.img from the official snapshot same result. Maybe kernel?
boot.img is the kernel.
You did not mention anything related to proprietary files. Do you have those added to your local_manifest?
CM11 was using get-prebuilts for vendor files, I think this no longer exists in CM12/CM13 and you need to add the files from somewhere else.
Jack Mayerz said:
I'm trying to make a CM13 build for my D821. repo has all the dependencies, device tree and kernel in local manifest and the only thing missing from the tree that make seems to complain about are the bootloader.img and radio.img but I flash them separately anyways.
Even though the build goes successfully and the generated images are much like the ones from the official snapshot (albeit system being smaller in size and missing some packages) it just doesn't boot past the google logo.
I've tried both the generated cm-13.0-20160428-UNOFFICIAL-hammerhead.zip and cm_hammerhead-ota-b324db6001.zip with the recovery.img and they flash fine through storage or sideload but when I reboot the device is stuck at the Google logo.
I've tried flashing all the images separately with fastboot and still the same result so I'm thinking it's a problem with boot.img. I followed all the directions on the wiki to the letter.
Also, repo syncs 100% and my first sync had no interruptions whatsoever and I wasn't using --force-sync so I'm sure I have the full tree without anything missing. Was there maybe some step specific to CM that was left out on the wiki?
EDIT: I tried boot.img from the official snapshot same result. Maybe kernel?
Click to expand...
Click to collapse
U need vendors. Fork github.com/mrtumbles vendor lge into your sourcetree/vendor folder
morphvale said:
boot.img is the kernel.
You did not mention anything related to proprietary files. Do you have those added to your local_manifest?
CM11 was using get-prebuilts for vendor files, I think this no longer exists in CM12/CM13 and you need to add the files from somewhere else.
Click to expand...
Click to collapse
dekefake said:
U need vendors. Fork github.com/mrtumbles vendor lge into your sourcetree/vendor folder
Click to expand...
Click to collapse
Thanks guys, it works perfect now.

Permissive for sm-n7505

Hello, how are you all doing?
So I have tried dozens of ways to set my SELinux to permissive on my Samsung Note 3 Neo SM-N7505 (lollipop 5.1.1) but no success..I have tried:
1-Using apps, no success
2-Unpacking boot.img and editing kernel cmdline, no success (probably because my bootloader is locked not sure)
3-Using setenforce and other commands, no success
4-Using init.d support, no success
HELP ME OUT GUYS!..I really need to change my selinux
Thanks
Anyone?
The SELinux bootparam is disabled in kernel config by default.
I build an forced permissive Kernel for you:https://www.amazon.de/clouddrive/sh...TX3ciUcR3FPbUoaVZb?ref_=cd_ph_share_link_copy
Sources: https://github.com/davidmueller13/kernel_SM-N7505
Just unpack boot.img, replace zImage and repack.
I don't know if it's working without problems, because i dont't own the device and can't test it.
Thank you so much for replying and making the kernel! I really appreciate your hardwork even if it didn't work
I know how to extract boot.img but how do i replace the zlmage and then repack it again ..Please guide me (IN DETAILS LOL!)
Thanks
So I unpacked my boot.img and all I see is ramdisk and kernel..no zImage..where is it?
Why does your zImage has a .bin extension and not .img?
Is the Kernel file in my boot.img the zImage?..if so, should I delete it and replace it with your zImage ( rename it to kernel)?
Thanks
Depending on your Unpacking Tool, the zImage can be named differently. So just rename it to kernel and repack.
Should I change the extension of your zImage?..it is .bin not .img
It should have the same name and extension as the zImage in the unpacked boot.img, otherwise the your unpack tool will not find it.
But i actually didn't gave and see any extension at the file name of my uploaded file.
If you want, your can send me your boot image and i will repack it for you.
Does it contain private informations like my photos lol?
HelpMe101007 said:
Does it contain private informations like my photos lol?
Click to expand...
Click to collapse
No, of course not.It includes only the kernel, the initrd (Ramdisk), on many devices an device tree image and some information like commandline, pagesize etc.
Your User-Apps, App data etc. are on the data Partition (your photos are most likely at data/media).
Here is my boot.img. All I want is SELinux to be permissive nothing else.
And I would really appreciate it if you can make the new boot.img in tar.md5 so I can flash it easily with Odin.
Thanks !
https://www.amazon.de/clouddrive/sh...rRxVAbaPRKIc81SK9H?ref_=cd_ph_share_link_copy
Caused bootloop
Try this first (it's SELinux Enforcing):https://www.amazon.de/clouddrive/sh...kV4YVLHXJq5ewLL5Lb?ref_=cd_ph_share_link_copy
If it works, try this:https://www.amazon.de/clouddrive/sh...bHN6WQ2p0fpGLU0sOd?ref_=cd_ph_share_link_copy
If the first is working, but the second not, we try it with selinux bootparam enabled.
What kind of bootloop. Does the device pass the Splashscreen (Model Number) and show bootanimation?
No it doesnt pass the splash screen
First one is not working
HelpMe101007 said:
First one is not working
Click to expand...
Click to collapse
that's really strange, because it's just straight compiled from Samsungs Kernel Sources with linaro 4.8 (passes without errors) in contrast to the first try with a lot of fixes for compiling with 4.9.
Please try this last one, it's just repacked, so wen can see, if there is the problem:https://www.amazon.de/clouddrive/sh...fC3hJtzBPimxd4OQmW?ref_=cd_ph_share_link_copy
It's really unlikely, but not impossible, that Samsung released broken kernel Sources.
(I also noticed some file size difference of nearly 10 KB).
Maybe the way I am flashing is wrong?..I put your tar in AP in Odin then flash it, correct?
Your untouchedboot caused bootloop as well but a weird one.My phone did make it to the Home screen but then immediately rebooted and kept rebooting at the boot animation ( it passed the splash screen)

Categories

Resources