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.
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!!!
Hello,
I'm trying to edit .IMG file to make some changes. I have "boot.img" and I've tried to extract it using `unpackbootimg` tool with following result:
5AB9CF0431DD269C/U# unpackbootimg -i boot.img -o boot
BOARD_KERNEL_CMDLINE androidboot.hardware=qcom user_debug=31 zcache
BOARD_KERNEL_BASE 80200000
BOARD_PAGE_SIZE 2048
Segmentation fault (core dumped)
Thanks.
@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]
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)