Problems Unpacking/Packing kernel - Galaxy Note 3 Q&A, Help & Troubleshooting

Hi!
I am trying to create a custom kernel for my Galaxy Note 3. I have successfully modified and built the kernel. Now I want to actually test it. I've searched for possible methods to create a boot.img file from my zImage. I've tried
mkbootimg and unmkbootimg
kernel kitchen
I was able to create a boot.img with both methods and both of them failed to boot. I thought I messed up the kernel, BUT then I tried to just unpack a stock boot.img and repack it again - and this also failed with both methods.
Seeing as there are already people who made custom kernels for the Note 3, I'm wondering what I am doing wrong. Also I'm a bit new to this, that may also be a factor. Could someone possibly give a hint what might be going awry? Will of course provide additional information, if required.
Edit: nevermind that, found out I need Snapdragon 800 patched mkbootimg tools. found binary versions of them on github (Can't post link because I'm a new user). unsure where the source code is though.

Related

[Q] Custom ROM developing

Hi just asking if anyone knows any links or archives or anything i can read through, im looking to build my own ROM. any help would be much appreciated and dont mind donating to someone that can help me start to learn.
Thanks
Well, first of all you need to be able to compile Android. This is pretty easy and it's explained directly in the developers google website. If you're not running a Nexus One or a Nexus S, you can't actually compile a working android copy for your own phone "as is" from AOSP. Because of this, you firstly need to change / create some dirs and files in order to add the support for your particular device. I'd start searching on CM repositories for this (I've got the Nexus One and thus I don't have such problems).
After you've compiled Android for your device and your changes (for example root), you'll have some disk images (you can find them all under out/target/product/PHONE_MODEL/, they are the .img files). You can directly flash them via fastboot ("fastboot flash boot boot.img" etc.). You can though create an update.zip file, and this can be made extracting the system.img file in a folder. Remember that you'll have to recreate the symlinks (to toolbox and/or busybox if you want to include it in your build) and set permissions, as zip doesn't save the permissions of the files once compressed.
Thus so far, if you succeed making every single step you should have your ROM on your phone

[DEV] Kernel Compiling

Hi all! I'm not a dev but i really want to do something for this phone so i'm trying to build a custom kernel.... if anyone have tried the same report here the issue, i will do the same!
I have the pre-requisites for compiling a kernel set up. However I am more interested in getting ClockworkMod Recovery working on our phone as that will encourage developers and we can then start looking at getting CyanogenMod 7. I made a topic here asking for help but I haven't received any replies yet.
I have just compiled a kernel but it doesn't work.... this because - i think - i used the initramfs provided by leshak for the i9000.... now i'm trying to extract from phone......
Kernel
Hi Skin1980, I also compiled a (stock) Kernel two weeks ago - problem is, Samsung does not use the "normal" way of storing it in a boot.img file. That is why I wasn't able to push it to the phone or at least fastboot it. I would be glad to hear from you how exactly this is possible, if you find out.
XDA_Bam said:
Hi Skin1980, I also compiled a (stock) Kernel two weeks ago - problem is, Samsung does not use the "normal" way of storing it in a boot.img file. That is why I wasn't able to push it to the phone or at least fastboot it. I would be glad to hear from you how exactly this is possible, if you find out.
Click to expand...
Click to collapse
I used the redbend_ua you can find here to write zImage to bml7.... how do you do with initramfs that is missed when you build the kernel?
Skin1980 said:
I used the redbend_ua you can find here to write zImage to bml7.... how do you do with initramfs that is missed when you build the kernel?
Click to expand...
Click to collapse
Have you managed to extract initramfs with redbend_ua?
If you don't mind, please take a look at this post. There is a step build/tools/device/mkvendor.sh device_manufacturer_name device_name /your/path/to/the/boot.img. Because Samsung doesn't use this boot.img building a recovery looks tricky. Any suggestions would help.
rb210 said:
Have you managed to extract initramfs with redbend_ua?
If you don't mind, please take a look at this post. There is a step build/tools/device/mkvendor.sh device_manufacturer_name device_name /your/path/to/the/boot.img. Because Samsung doesn't use this boot.img building a recovery looks tricky. Any suggestions would help.
Click to expand...
Click to collapse
I dumped the bml7 partition, i see that inside there's a zimage... but i'm not able to extract this f u c .......initramfs!!!!!
rb210 said:
Have you managed to extract initramfs with redbend_ua?
If you don't mind, please take a look at this post. There is a step build/tools/device/mkvendor.sh device_manufacturer_name device_name /your/path/to/the/boot.img. Because Samsung doesn't use this boot.img building a recovery looks tricky. Any suggestions would help.
Click to expand...
Click to collapse
and if we can find the initramfs i think that is not difficult to modify the recovery to allow unsigned zip files installation
Perhaps, we could use parts of the following method:
h**p://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images
To extract the ramdisk from the boot.img, they do the following:
Then, look for a bunch of zeroes followed by the hex 1F 8B (which is the magic number of a gzip file). Copy everything from the first line of the file, through the zeroes, and stopping at the 1F 8B. That is the kernel. Everything from the 1F 8B through the end is the ramdisk. You could save each of these files separately. In order to see the contents of the ramdisk, you need to un-gzip it and then un-cpio it.
Click to expand...
Click to collapse
I know that we don't have a boot.img, but we do have an image including kernel and ramdisk - this should be very similar. And if you can locate the named headers in the file, the extraction should work. Further info and some useful commands can be found behind the link.
Sadly, I won't have time to try this before next weekend...
XDA_Bam said:
Perhaps, we could use parts of the following method:
h**p://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images
To extract the ramdisk from the boot.img, they do the following:
I know that we don't have a boot.img, but we do have an image including kernel and ramdisk - this should be very similar. And if you can locate the named headers in the file, the extraction should work. Further info and some useful commands can be found behind the link.
Sadly, I won't have time to try this before next weekend...
Click to expand...
Click to collapse
Which file are you referring to? I have some time, I can give it a shot.
EDIT: I found "initramfs.c" and its object file "initramfs.o" under GT-I9003_Kernel/kernel/Kernel/init from the Samsung opensource tarball. Don't think that helps us though.
@rb210: I mean the dumped bml7 partition. It's an image of a partition with a kernel and ramdisk in it, or did I misunderstand something?
PS: You could try "SGS kernel flasher" from the market. It's got a backup option - look if it does produce the same image of the bml7 partition (I tried it, it did a backup image of around 8MB on my SGSL, which is about the size of bml7, as far as I remember). It would be faster and easier to carry out than using a script.
XDA_Bam said:
@rb210: I mean the dumped bml7 partition. It's an image of a partition with a kernel and ramdisk in it, or did I misunderstand something?
PS: You could try "SGS kernel flasher" from the market. It's got a backup option - look if it does produce the same image of the bml7 partition (I tried it, it did a backup image of around 8MB on my SGSL, which is about the size of bml7, as far as I remember). It would be faster and easier to carry out than using a script.
Click to expand...
Click to collapse
But ramdisk=initramfs?
XDA_Bam said:
@rb210: I mean the dumped bml7 partition. It's an image of a partition with a kernel and ramdisk in it, or did I misunderstand something?
PS: You could try "SGS kernel flasher" from the market. It's got a backup option - look if it does produce the same image of the bml7 partition (I tried it, it did a backup image of around 8MB on my SGSL, which is about the size of bml7, as far as I remember). It would be faster and easier to carry out than using a script.
Click to expand...
Click to collapse
Ah I see what you mean. I was trying to figure out how to extract the initramfs from the opensource package from the Samsung website. I figure if they're providing the kernel and platform, there's got to be an initramfs somewhere. You'll are talking about trying to extract it from inside the phone itself.
I'm still not sure how this is going to fit in with porting Clockworkmod as per that method in the blog post because it's still an initramfs and not a boot.img. Getting custom recovery is vital to attracting development for this phone, we should not make the mistake of overlooking this.
Tools for extract initramfs from a zImage : https://github.com/project-voodoo/kernel_repack_utils

Custom Kernel SM_G935F

I have been playing around with kernels (for nexus 5), to add some features to the stock kernel. But I have problem with Samsung. I am trying to build a flashable custom kernel for Samsung S7 edge (G935F). .Steps I followed to create the boot.img are:
Get the stock source code (Samsung openSource)
Modify the kernel (just add/remove some TCP features)
Build the kernel (as per the kernel READ.ME, with aarch64-linux-android-4.9 toolchain)
-->created Image, with no loadable modules (*.ko)
Unpack the boot.img from the stock kernel (abootimg -x )
Create new boot.img replacing the original zImage with the custom kernel Image (abootimg --create . . . )
Make tar.md5 file of the custom boot.img for Odin3
Pushed the custom kernel using Odin3, but it fails to boot ("kernel not enforcing seadnroid"). I have tried using TWRP (install from zip), but it just does bootloop. Can anyone see what I am doing wrong? Am I missing something? I have read most of the "Build kernel from source" dev-threads but have not found a solution for this, nor am I allowed to post my questions there as I am just a junior member.
I would highly appreciate any help, as I have already invested some days with no avail
mdh-labs said:
I have been playing around with kernels (for nexus 5), to add some features to the stock kernel. But I have problem with Samsung. I am trying to build a flashable custom kernel for Samsung S7 edge (G935F). .Steps I followed to create the boot.img are:
Get the stock source code (Samsung openSource)
Modify the kernel (just add/remove some TCP features)
Build the kernel (as per the kernel READ.ME, with aarch64-linux-android-4.9 toolchain)
-->created Image, with no loadable modules (*.ko)
Unpack the boot.img from the stock kernel (abootimg -x )
Create new boot.img replacing the original zImage with the custom kernel Image (abootimg --create . . . )
Make tar.md5 file of the custom boot.img for Odin3
Pushed the custom kernel using Odin3, but it fails to boot ("kernel not enforcing seadnroid"). I have tried using TWRP (install from zip), but it just does bootloop. Can anyone see what I am doing wrong? Am I missing something? I have read most of the "Build kernel from source" dev-threads but have not found a solution for this, nor am I allowed to post my questions there as I am just a junior member.
I would highly appreciate any help, as I have already invested some days with no avail
Click to expand...
Click to collapse
I dont want to tell you something you have already read, if you have been through the Dev forums, But on the off chance:
Have you removed the Fingerprint reader?
The Kernel will fail to boot with it enabled, Unless you know the workaround (EchoTeam)
dave7802 said:
I dont want to tell you something you have already read, if you have been through the Dev forums, But on the off chance:
Have you removed the Fingerprint reader?
The Kernel will fail to boot with it enabled, Unless you know the workaround (EchoTeam)
Click to expand...
Click to collapse
Hmm ... Fingerprint reader? No, I have not removed anything. I was thinking that since I am not adding anything that was not already in the stock kernel source, I do not need to do any modifications. How can I remove this reader?
Here are the temporary solutions.
Way A:
Remove /system/lib/libbauth* , /system/lib64/libbauth*
Way B: (If you want to completely disable (or bypass) TEE)
Remove /system/lib/libbauth* , /system/lib64/libbauth*
Replace /system/lib64/hw/gatekeeper.exynos8890.so,/system/lib64/hw/keystore.exynos8890.so with these i uploaded.
Both of them will make your FP Sensor not working.
(Lock Screen will work)
But,at least,you get a stable custom kernel.
Click to expand...
Click to collapse
http://forum.xda-developers.com/s7-...m-g935f-fd-t3361460/post66762787#post66762787
Thank @Jesse Chan He also fixed the fingerprint too.
dave7802 said:
http://forum.xda-developers.com/s7-...m-g935f-fd-t3361460/post66762787#post66762787
Thank @Jesse Chan He also fixed the fingerprint too.
Click to expand...
Click to collapse
Thanks a lot, I will try that. I have already seen his custom kernel (would love to ask something on his thread but . . . )
mdh-labs said:
Thanks a lot, I will try that. I have already seen his custom kernel (would love to ask something on his thread but . . . )
Click to expand...
Click to collapse
I saw someone mention me.
Well, you must disable all TIMA-related configs as well as KNOX_KAP to get kernel boot.
And then, if you want to get a stable kernel with FP, you must apply my FP fix.(could be found in my Kernel's flashable zip)
Jesse Chan said:
I saw someone mention me.
Well, you must disable all TIMA-related configs as well as KNOX_KAP to get kernel boot.
And then, if you want to get a stable kernel with FP, you must apply my FP fix.(could be found in my Kernel's flashable zip)
Click to expand...
Click to collapse
I appreciate that you have had the time to look at my question. I've tried the tricks you suggested but my kernel still cannot boot. Modified the .config file (with menuconfig):
disabled
# CONFIG_KNOX_KAP is not set
# CONFIG_TIMA is not set
# CONFIG_TIMA_LKMAUTH is not set
not in config anymore
-CONFIG_TIMA_LOG=y
-CONFIG_TIMA_RKP=y
Then built a custom boot.img as mentioned in my question and added the META and mcRegistry folders from your flashable zip file to create a zip file out of the three.
I have also tried by removing the libbauth* files from system/lib/ and system/lib64 directories?
One more thing, does it matter whether I get just an Image file or zImage from kernel build (I get only Image and .gz of it)?

Building arm64 kernel for Galaxy S7 Edge (SM-G935F) question.

Hello,
First of all, im new to android modding and linux. I tried to build a kernel from stock G935FXXU1BPH6 source based on their readme file. My problem is, I don't have a zImage file after build that I could put into a flashable zip. I only have Image and Image.gz (I guess thats normal for arm64 kernels?) and I don't know how to make them flashable. I found a youtube video where the dude placed the Image file in a directory called "tools" in his flashable zip, I tried it and TWRP said I installed it successfully but when I start up my phone and check kernel version its still the previous one not mine.
Used this toolchain: aarch64-linux-android-4.9/bin/aarch64-linux-android-
I've set up CROSS_COMPILE path, then I set up configuration:
make ARCH=arm64 exynos8890-hero2lte_defconfig
make menuconfig (to tweak it a little bit more, like custom kernel version string so I can see if it worked)
Then I started build:
make ARCH=arm64
Output when build finished:
>>>>> Time used for generated all hashes is 6 sec
OBJCOPY arch/arm64/boot/Image
GZIP arch/arm64/boot/Image.gz
DTC arch/arm64/boot/dts/exynos8890-smdk8890.dtb
DTC arch/arm64/boot/dts/exynos8890-universal8890.dtb
Anyone knows how could I make it flashable? Thanks.
keezay said:
Hello,
First of all, im new to android modding and linux. I tried to build a kernel from stock G935FXXU1BPH6 source based on their readme file. My problem is, I don't have a zImage file after build that I could put into a flashable zip. I only have Image and Image.gz (I guess thats normal for arm64 kernels?) and I don't know how to make them flashable. I found a youtube video where the dude placed the Image file in a directory called "tools" in his flashable zip, I tried it and TWRP said I installed it successfully but when I start up my phone and check kernel version its still the previous one not mine.
Used this toolchain: aarch64-linux-android-4.9/bin/aarch64-linux-android-
I've set up CROSS_COMPILE path, then I set up configuration:
make ARCH=arm64 exynos8890-hero2lte_defconfig
make menuconfig (to tweak it a little bit more, like custom kernel version string so I can see if it worked)
Then I started build:
make ARCH=arm64
Output when build finished:
>>>>> Time used for generated all hashes is 6 sec
OBJCOPY arch/arm64/boot/Image
GZIP arch/arm64/boot/Image.gz
DTC arch/arm64/boot/dts/exynos8890-smdk8890.dtb
DTC arch/arm64/boot/dts/exynos8890-universal8890.dtb
Anyone knows how could I make it flashable? Thanks.
Click to expand...
Click to collapse
This particular chipset (64-bit Exynos) uses the uncompressed Image and a separate dtb.img file made from combining all the dtb revisions of your device codename and region into a DTBH format.
You can flash them using my LazyFlasher project.
See: https://github.com/jcadduono/lazyflasher
You will want to use the kernel-flasher branch. The kernel-flasher-samsung branch isn't fully ready and adds additional patch files to remove TIMA/Knox. I've yet to find out everything that needs to be changed from stock state to allow a bootable custom kernel without disabling encryption, unfortunately.
You can simply git clone it, then place your Image and optionally dtb.img in the root folder of the repository, then type "make" to build a TWRP flashable zip. They will be dynamically replaced in the current boot image on the device when the zip is flashed. You can check out the README.md for more info.
If you want to generate your own dtb.img to include in the installer, you can use a script I made from my universal8890 kernel sources on GitHub:
https://github.com/jcadduono/android_kernel_samsung_universal8890/blob/stock-6.0/dtbgen.sh
(correct the toolchain location for your build in the script)
It also requires the scripts/dtbTool folder (from the same git linked above) to be present in your repository. It's not the same as the Qualcomm dtbTool, and the sources are included (and fairly clean!) if you're interested in learning the Exynos dtb.img (DTBH) format.
./dtbgen.sh hero2lte xx
Now, there's still quite a bit that needs to be done to make the device actually boot successfully and be stable with a custom kernel. While the kernel is perfectly stable, the Samsung customized Android OS will absolutely freak out. That's a bit beyond me, and the reason I haven't really worked on any custom kernels for it myself.
Have fun!
jcadduono said:
This particular chipset (64-bit Exynos) uses the uncompressed Image and a separate dtb.img file made from combining all the dtb revisions of your device codename and region into a DTBH format.
You can flash them using my LazyFlasher project.
See: https://github.com/jcadduono/lazyflasher
You will want to use the kernel-flasher branch. The kernel-flasher-samsung branch isn't fully ready and adds additional patch files to remove TIMA/Knox. I've yet to find out everything that needs to be changed from stock state to allow a bootable custom kernel without disabling encryption, unfortunately.
You can simply git clone it, then place your Image and optionally dtb.img in the root folder of the repository, then type "make" to build a TWRP flashable zip. They will be dynamically replaced in the current boot image on the device when the zip is flashed. You can check out the README.md for more info.
If you want to generate your own dtb.img to include in the installer, you can use a script I made from my universal8890 kernel sources on GitHub:
https://github.com/jcadduono/android_kernel_samsung_universal8890/blob/stock-6.0/dtbgen.sh
(correct the toolchain location for your build in the script)
It also requires the scripts/dtbTool folder (from the same git linked above) to be present in your repository. It's not the same as the Qualcomm dtbTool, and the sources are included (and fairly clean!) if you're interested in learning the Exynos dtb.img (DTBH) format.
./dtbgen.sh hero2lte xx
Now, there's still quite a bit that needs to be done to make the device actually boot successfully and be stable with a custom kernel. While the kernel is perfectly stable, the Samsung customized Android OS will absolutely freak out. That's a bit beyond me, and the reason I haven't really worked on any custom kernels for it myself.
Have fun!
Click to expand...
Click to collapse
Thank you very much!
@jcadduono couldn't make the kernel boot after packing it with lazyflasher. I built a completely stock kernel from the mentioned source, pasted the "Image" (not the Image.gz) file in lazyflasher root and then used make command. Tried including "exynos8890-smdk8890.dtb" file as well. Same story. Not sure if I need anything else in the package or I made user mistake. Do you have any ideas how could I debug what makes it stuck on that screen?
Thanks!
EDIT: Solved Problem.
keezay said:
@jcadduono couldn't make the kernel boot after packing it with lazyflasher. I built a completely stock kernel from the mentioned source, pasted the "Image" (not the Image.gz) file in lazyflasher root and then used make command. Tried including "exynos8890-smdk8890.dtb" file as well. Same story. Not sure if I need anything else in the package or I made user mistake. Do you have any ideas how could I debug what makes it stuck on that screen?
Thanks!
EDIT: Solved Problem.
Click to expand...
Click to collapse
Can you help me set up an environment to build a kernel, arm64, for s7? I'm on Ubuntu having a heel of a time..
Galaxy S7 Edge Kernel Flashing Issues
I am currently trying to flash a different kernel into a galaxy s7 edge (SM-G935S).
I have gone as far as building a kernel and extracting a Image file from it, but every time I try flashing a boot.img with a replaced kernel image file, it seems to never work.
A mkbootimg tool that I am currently using requires a dtb file, but I cannot find where to get it from.
I have tried using @jcadduono's git code, but the dtb file created from it doesn't seem to work as well.
Can anyone tell me what I should do to flash a kernel successfully?
kernel panic after flashing
Hi @ll,
with this guide I was able to compile my own kernel and also flashing it to my phone. Unfortunatelly I'm getting kernel panic after rebooting the phone. is there any possibility to get the reason for this? Or do you have any hint, what I may have done wrong?
Thanks for your help.
Kind regards
v0ti

New file_contexts.bin format and make_ext4fs

Trying to alter a stock ROM and resign with my own custom key just for myself. This process will allow me to use a device with custom changes (NOT root), but still allow me to use Android Pay.
This process involves using the "make_ext4fs" tool. However, this tool (as far as I can tell) requires using the old plaintext version of "file_contexts". Android 7+ uses a new binary version of this file instead ("file_contexts.bin").
So if anyone can solve either of these questions, I would be very grateful:
1) Is there a tool to convert my device's binary "file_contexts.bin" to the old plaintext "file_contexts"? -OR-
2) Is there a build of "make_ext4fs" that accepts the new binary format "file_contexts.bin"? I tried to build the new nougat version myself from AOSP, but after a successful build of the tool, I can't get the thing to read files on either 64-bit or 32-bit systems. It yields an error "No such file or directory" when trying to point to file_contexts. I am not a great C developer, so I don't know if I built it wrong. For reference, no, I am not missing the lib32stdc++6 libraries. I have attached the binary if you want to see if you can get it to work. -OR-
3) If anyone has the file_contexts text file for the OnePlus 3, ROM version 7.X Nougat, that would work too!​
Any help anyone can offer in any way would be fantastic! Thank you so much for your time to look at this!
A good question
1) yes, see my signature
munjeni said:
1) yes, see my signature
Click to expand...
Click to collapse
I'm trying to do the same with a 7.1.1. rom. I convert the file_contexts.bin to file_contexts, unpack the rom, do the modifications to the rom, repack the rom then replace the original system.new.dat and system.transfer.list with the newly packed ones (original file_contexts.bin is still in the original zip) and when I go to flash it in TWRP it doesn't flash the system and I get a No OS installed Is there something I have to do to the file_contexts.bin after I repack the system.new.dat?
"file_contexts.bin" to the old plaintext "file_contexts" tool: http://blog.cofface.com/archives/2255.html
puargs said:
I tried to build the new nougat version myself from AOSP, but after a successful build of the tool, I can't get the thing to read files on either 64-bit or 32-bit systems. It yields an error "No such file or directory" when trying to point to file_contexts. I am not a great C developer, so I don't know if I built it wrong. For reference, no, I am not missing the lib32stdc++6 libraries.
Click to expand...
Click to collapse
Try building with the pie (Position Independent Executable) flag. Had this exact same problem when trying to compile a CVE for android.
Hopefully this should work for you and sorry for the Necro post

Categories

Resources