[Q] Problems building a boot.img : Is this safe to use? - Droid Eris Q&A, Help & Troubleshooting

I am trying to replace the kernel in a boot.img, and then repackage it to a zip that can be flashed. I am trying to follow a guide. Since I am not allowed to post a link, I'll post an excerpt:
E. The Boot.img
We already know that this is the kernel and ramdisk needed to boot up the device. You can pull this apart and swap out the kernel if you would like. For this, you're going to have to run Linux. If you're not able to run Linux natively, download Sun's Virtual Box and an easy to use Linux distro like Ubuntu or Fedora. We will leave custom kernel compilation for another day. To extract and rebuild the Boot.img we need some tools. These are in the attached Boot-tools.zip file found in the first post. Extract the entire zip file into a tools directory in the top level of your working directory. Open your terminal and navigate to your working directory, then enter the following commands:
Code:
/tools/extract-kernel.pl boot.img
/tools/extract-ramdisk.pl boot.img
This will place a copy of the kernel and ramdisk in your working directory. Overwrite the kernel image with the kernel you would like to use. Then re-package everything as so:
Code:
mkbootfs boot.img-ramdisk | gzip > ramdisk-boot
mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o newBoot.img --base 0x19200000
Click to expand...
Click to collapse
I have no problem with the first 3 commands:
extract-kernel.pl boot.img
extract-ramdisk.pl boot.img
mkbootfs boot.img-ramdisk | gzip > ramdisk-boot
But this last command just returns the mkbootimg syntax help blurb:
mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o newBoot.img --base 0x19200000
it returns this:
usage: mkbootimg
--kernel <filename>
--ramdisk <filename>
[ --second <2ndbootloader-filename> ]
[ --cmdline <kernel-commandline> ]
[ --board <boardname> ]
-o|--output <filename>
I noticed that the --base option isn't included in the help, so I left out the "--base 0x19200000". This worked fine and created the newBoot.img file. Will this be safe to use?
Thanks in advance.

Related

[Q] Kernel compiling

First off I'd like to say I'm no noob when it comes to the linux kernel, though this is my first time on android. I have attempted to compile my own kernel (defaults for now) for my thunderbolt.
Mostly followed
http://htcevohacks.com/htc-evo-hacks/how-to-build-your-own-htc-evo-4g-android-kernel/
Tools from here
http://forum.xda-developers.com/showthread.php?t=551711
Pulled the Thunderbolt sources and extracted
Ran
CROSS_COMPILE=~/android-sdk-linux_x86/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- make clean
CROSS_COMPILE=~/android-sdk-linux_x86/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- make mecha-lte_defconfig
CROSS_COMPILE=~/android-sdk-linux_x86/android-ndk-r5b/toolchains/arm-eabi-4.4.0/prebuilt/linux-x86/bin/arm-eabi- make -j3 ARCH=arm
no errors
make working folder next te kernel sources with tools and stock boot.img in it.
rm ./zImage
rm -rf ./boot.img-ramdisk
rm ./boot.img-ramdisk.cpio.gz
rm ./myBoot.img
rm -rf ./ramdisk-boot
cp ../kernel_htc-mecha/arch/arm/boot/zImage ./
./extract-kernel.pl boot.img
./extract-ramdisk.pl boot.img
rm boot.img-kernel
mv zImage boot.img-kernel
./mkbootfs boot.img-ramdisk | gzip > ramdisk-boot
./mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o myBoot.img --base 0x19200000
and the resulting image built is myBoot.img, renamed to boot.img and installed through fastboot, hboot, or clockwork. My only issue with this is that my system refuses to boot with the kernel and stays at the splash screen. Not the boot animation even. Please tell me if I missed a step (I manually ran all of that checking for errors, all appeared to go fine, though it still won't boot.
Thanks in advance!
EDIT: Returning to any known working kernel (anyone else's or stock) works fine. I con still boot clockwork and hboot with my kernel)
kdb424 said:
./mkbootimg --kernel boot.img-kernel --ramdisk ramdisk-boot --cmdline "no_console_suspend=1 console=null" -o myBoot.img --base 0x19200000
Click to expand...
Click to collapse
change "--base 0x1920000" to "--base 0x05200000"
The offset is different for each device. I believe you are using the offset for the hero. The one that I gave you should be the one for the TB. That's the only obvious thing that I see, but I don't have a TB to test...

[Q]Unpack and repack files .img

I want to unpack and repack .img files. I tried with winrar, no success. I tried to mount as a disk image, but no success. I've tried to see other posts about it, but no one tell me how to do with windows. Can you help me?
My recommendation would be to run a virtual unbuntu linux machine and start learning linux. If you're playing around with kernels you're going to want to compile your own pretty soon.
That being said:
the unpack-bootimg.pl is a perl script, you can probably install perl on your windows machine to unpack the bootimg.
I use mkbootimg to repack the kernel image, whic is a binary executable. I'm not sure if there a precompiled windows version you can download or if it comes with the windows NDK but that would be the way to go to repack the boot img.
Here's a copy and paste about repacking the kernel on linux that i just made in the xoom forum
(1) make a backup with CWM, and copy the boot.img to my computer.
(2) extract boot.img with unpack-bootimg.pl
(3) this gives me the boot-img-ramdisk.cpio.gz file and boot.img-kernel.gz
If you want to recpio because you changed the ramdisk/added ko's run:
cd boot.img-ramdisk/
find . | cpio -o -H newc | gzip > ../bootimg-ramdisk.cpio.gz
cd ..
(4) use command:
mkbootimg --cmdline 'androidboot.carrier=wifi-only product_type=w' --kernel zImage --ramdisk boot.img-ramdisk.cpio.gz -o boot-new.img --base 0x30000000 --pagesize 4096
adb reboot bootloader
fastboot flash boot boot-new.img
use a hex editor from a working boot.img to determine what the cmdline option should be set to for your device. The easiest way is to take one from a cwm backup.

[Q] Modding Recovery.img fail

Well, my problem is when i unpack and repack a funtional recovery.img this dont run.
I use this parameters with cygwin:
./split_bootimg.pl recovery.img
./unpack-bootimg.pl recovery.img
Mkdir ramdisk
Cd ramdisk
gzip -dc ../recovery.img-ramdisk.gz | cpio –i
SOURCE CHANGES
Cd ..
Find ./ramdisk | cpio –o –H newc | gzip > newramdisk.cpio.gz
mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel recovery.img-kernel --ramdisk newramdisk.cpio.gz -o recoveryNew.img
If i do changes or not, the result after flash the new recoveryNew.img is a frezzee into logo.
What i doing wrong?
HELP!!!

[Q&A]Compile TWRP 2.8.3.0 touch recovery

@HoaPham98 , @Zaaap72 , @invaderjohn , @siracuervo and other devs
In the last few days I tried to compile TWRP 2.8.3.0 for D620 without success. What I managed to compile, is not working; when I try to enter in recovery the phone enter in fastboot.
My environment was installed like here.
Then I deleted /bootable/recovery (CWM recovery) and I used this command to download TWRP recovery:
git clone git:/github.com/omnirom/android_bootable_recovery.git -b android-4.4 /bootable/recovery
The next thing I did was to download Zaaap72 sources:
Code:
git clone git://github.com/Zaaap/android_device_lge_d620.git -b master device/lge/d620
git clone git://github.com/Zaaap/android_vendor_lge_d620.git -b master vendor/lge/d620
git clone git://github.com/Zaaap/android_kernel_lge_d620.git -b master kernel/lge/d620
Next I used the next command:
.build/tools/device/makerecoveries.sh cm_D620r-eng
source build/envsetup.sh
lunch cm_d620-eng
And to compile the recovery I used:
make clobber - I used this every time I modified BoardConfig.mk
sudo make clean && make -j5 recoveryimage
In the first tests, I had a lot off errors, and I had do delete Zaaap72 Kernel source and I used TARGET_PREBUILT_KERNEL := device/lge/d620/kernel in BoardConfig.mk.
Next, if the settings bellow were set in BoardConfig.mk the compile stop every time and it given me the next error:
make: *** No rule to make target '/home/amd/android/system/out/host/linux-x86/bin/dtbToolCM', needed by '/home/amd/android/system/out/target/product/d620/dt.img'. Stop.
Code:
BOARD_CUSTOM_BOOTIMG_MK := device/lge/d620/mkbootimg.mk
BOARD_KERNEL_CMDLINE := console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=g2m
BOARD_KERNEL_BASE := 0x00000000
BOARD_KERNEL_PAGESIZE := 2048
BOARD_KERNEL_OFFSET := 0x00008000
BOARD_MKBOOTIMG_ARGS := --ramdisk_offset 0x01000000 --tags_offset 0x01e00000
If I disabled the settings, the compile was OK, but recovery.img is not booting.
I decompile the recovery.img and the first thing I saw was the missing off twrp.fstab from etc folder.
Next I tried to repack the recovery.img with the next commands:
Code:
./unmkbootimg recovery.img > output.txt - unpack recovery.img
gunzip -c ../initramfs.cpio.gz | cpio -i - unpack ramdisk
mkbootfs ramdisk | gzip > ramdisk-new.gz -repack ramdisk with mkbootfs
or
find . | cpio -o -H newc | gzip > ../newramdisk.cpio.gz - repack ramdisk
and the command to repack recovery.img
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x1dfff00 --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=g2m' -o new_boot1.img
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x0 --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=g2m' -o new_boot2.img
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x0 --pagesize 2048 --ramdisk_offset 0x01000000 --tags_offset 0x01e00000 --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=g2m' -o new_boot3.img
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x0 --pagesize 2048 --kernel_offset 0x00008000 --ramdisk_offset 0x01000000 --tags_offset 0x01e00000 --cmdline 'console=ttyHSL0,115200,n8 androidboot.console=ttyHSL0 user_debug=31 msm_rtb.filter=0x37 androidboot.hardware=g2m' -o new_boot5.img
All the recovery repack give me the same result, fastboot instead of recovery.
I tested another thing, because I believe the pack of recovery is the problem. I tried to unpack and repack TWRP recovery made by Zaaap72 , and none of my test recovery files are working.
So I think the problem with compilation is with the pack of recovery and I don't know how to fix it, and my method to unpack and repack is not working. I attached my test BoardConfig.mk file.
Can anyone help me with the compile of TWRP 2.8.3.0.
Use stock dtb or https://github.com/Garcia98/android_device_lge_d620/commit/7de7345cf5dbb94f0b7344d0580af66a60cd5cd0
Sent from my D620r [Stock 4.4.2]
I used mkbootimg.mk from Garcia98 and now I am getting a new error:
make: *** No rule to make target '/home/amd/android/system/out/target/product/d620/obj/KERNEL_OBJ/usr', needed by '/home/amd/android/system/out/target/product/d620/dt.img'. Stop.
I think I'm wrong somewhere, because I tried with Zaaap72 source (original and with mkbootimg.mk from Garcia98) and with Garcia98 source, and every time I have a lot of errors.
Should I used to compile recovery with a built kernel extracted from an working recovery, or should I compile recovery with kernel built from source?
And why I can not rebuilt an working recovery with the command displayed in my first post? - The recovery can be repack correctly with Android Image Kitchen.
And what is dt.img? The recovery is composed from dt.img + RAM DISK(TWRP, CWR, PhilZ or stock) + kernel
Sorry for the noob questions, but this things are new to me and I don't know how to move on from this point.
Don't use his file. Just the commit I posted.
Garcia's file is for normal android kernel, not recovery.
Or, you can extract dtb.img from stock recovery using Android Image Kitchen and put it in your recovery (again, using AIK)
Sent from my D620r [Stock 4.4.2]
@Vagelis1608 Thank you very much for your help.
I managed to compile TWRP 2.8.1.0, and after unpackimg and repackimg (I added dtb.img from stock recovery) with Android Image Kitchen my recovery is working (the backup function is working, wipe function is working, and on restore function I only tested data restore).
The only problem remaining is entering in recovery with volume down + power, the recovery factory reset the phone.
On CWM and PhilZ this problem can be fix by editing recovery.c and set wipe_data = wipe_cache = 0.
On TWRP I don't know which file and what I have to edit.
http://forum.xda-developers.com/showthread.php?p=54955945
Sent from my D620r [Stock 4.4.2]

How do I get the zImage ( the original kernel) from my Samsung Galaxy Tab S?

I am trying to install Linux on my Samsung Galaxy Tab S using the directions described in How to run Debian or Ubuntu GNU/Linux on your Android (I am not yet allowed to specify the URL but you might google it). However I cannot find the zImage (which is the original kernel in the tablet) to be used in the command
Code:
# mkbootimg --base 0x00200000 --kernel zImage --ramdisk initramfs.cpio.gz -o my-boot.img
What dælen can I do to find and extract it?
Thanks in advance.
CMJager said:
I am trying to install Linux on my Samsung Galaxy Tab S using the directions described in How to run Debian or Ubuntu GNU/Linux on your Android (I am not yet allowed to specify the URL but you might google it). However I cannot find the zImage (which is the original kernel in the tablet) to be used in the command
Code:
# mkbootimg --base 0x00200000 --kernel zImage --ramdisk initramfs.cpio.gz -o my-boot.img
What dælen can I do to find and extract it?
Thanks in advance.
Click to expand...
Click to collapse
You need to unpack the boot image to separate the kernel(zImage) and ramdisk. There are various tools about to do this.
ashyx said:
You need to unpack the boot image to separate the kernel(zImage) and ramdisk. There are various tools about to do this.
Click to expand...
Click to collapse
So where (or how) do i find the boot image?
CMJager said:
So where (or how) do i find the boot image?
Click to expand...
Click to collapse
The boot.img can either be found in the stock firmware or pulled frm the device or use a custom kernel posted in development.
Found it:
Code:
# ls -l /dev/block/platform/dw_mmc.0/by-name/BOOT
lrwxrwxrwx root root 2015-12-27 19:43 BOOT -> /dev/block/mmcblk0p9
Put the contents in a file:
Code:
# cat /dev/block/mmcblk0p9 /sdcard/boot.img
And at my linux box extracted the contents:
Code:
$ adb pull /storage/sdcard0/boot.img
$ unpackbootimg -i boot.img
BOARD_KERNEL_CMDLINE
BOARD_KERNEL_BASE 10000000
BOARD_PAGE_SIZE 2048
$
Then I also found a more robust mkbootimg-command:
Code:
$ mkbootimg --kernel boot.img-zImage --ramdisk boot.img-ramdisk.gz -o my-boot.img --base $(cat boot.img-base)

Categories

Resources