I'm attempting to repack a stock kernel after modifying the ro.secure flag, however, once repackaged and flashed (via MobileODIN) it just boot loops.
For reference, the device I'm building this for is the SGH-I747 (AT&T Samsung Galaxy S III)
I tracked down what I think is the correct base/offset --
First, I verified my board via my build.prop (just to be sure):
Code:
ro.product.board=MSM8960
Then I checked for the appropriate PHYS_OFFSET in the kernel source:
Code:
$ cat Kconfig |grep PHYS_OFFSET -A 13
config PHYS_OFFSET
hex
default "0x40800000" if ARCH_MSM9615
default "0x80200000" if ARCH_APQ8064
[color=red][b]default "0x80200000" if ARCH_MSM8960[/b][/color]
default "0x80200000" if ARCH_MSM8930
default "0x80200000" if ARCH_MSMCOPPER
default "0x10000000" if ARCH_FSM9XXX
default "0x00200000" if !MSM_STACKED_MEMORY
default "0x00000000" if ARCH_QSD8X50 && MSM_SOC_REV_A
default "0x20000000" if ARCH_QSD8X50
default "0x40200000" if ARCH_MSM8X60
default "0x10000000"
From this, I've determined that my offset is 0x80200000.
I then repacked via:
Code:
$ ./mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel boot.img-kernel --ramdisk ramdisk-new.gz --base 0x80200000 -o boot-new.img
I then push the boot-new.img to /sdcard/boot.img, flash via MobileODIN -- and that's all she wrote. Bootloop. I have to reflash the stock kernel via Odin to get the phone back up and running.
What am I missing here?
Related
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.
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...
@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)
I've read several tutorials both here and elsewhere. I've got a few different methods down using mkbootimg, unpackbootimg, abootimg, the perl scripts, and I have gzip/gunzip/cpio commands down. Splitting and repacking go without errors.
However, I cannot, to save my life, whether I modify something or not, get a boot image that I split and repacked to boot on my device.
I have a G4 H811 the T-Mobile variant. I have been playing with boot images and kernels included with ROMs and a custom kernel, even dd'd the working boot partition from my device. I simply cannot repack something that boots.
Here's an example approach, here I'm using binaries from a custom kernel zip mkbootimg, unpackbootimg, and the busybox included in the zip. I'm doing exactly what the kernel maintainer does to split the image, replace zImage and repack, only manually in a terminal and modifying the ramdisk leaving everything else alone.
mkdir boot
cd boot/
cat /dev/block/bootdevice/by-name/boot >boot.img
chmod 755 busybox
chmod 755 mkbootimg
chmod 755 unpackbootimg
./unpackbootimg -i boot.img
mkdir initrd
cd initrd
cat ../boot.img-ramdisk.gz | ../busybox gunzip | ../busybox cpio -vid
vi init.rc(made changes)
../busybox find . | ../busybox cpio -o -H newc | ../busybox gzip >../myinitrd.img
cd ..
./mkbootimg --kernel boot.img-zImage --ramdisk myinitrd.img --cmdline "$(cat boot.img-cmdline)" --base 0x$(cat boot.img-base) --pagesize 4096 --ramdisk_offset $(cat boot.img-ramdiskoffset) --tags_offset $(cat boot.img-tagsoffset) --output myboot.img
./busybox dd if=myboot.img of=/dev/block/bootdevice/by-name/boot
I end up with with a 26.8MB myboot.img and a bootloop
Here's a really good example, I changed absolutely nothing. After unpacking and repacking I end up with two different size boot images. What am I missing here?