How to edit boot.img for SM-T585? - General Questions and Answers

I want to edit the boot.img for SM-T585, but I can't edit initrd.img. I'm using abootimg and I tested that it works by unpacking and repacking the boot.img without doing any thing to the initrd.img:
Code:
abootimg -x boot.img
abootimg --create newboot.img -k zImage -r initrd.img -f bootimg.cng
and this image can be flashed and the device boot normally, but when I try to modify the initrd.img:
Code:
mkdir initrd_folder && cd initrd_folder
# extract the [B]initrd.img[/B]
zcat ../initrd.img | cpio -idmv
# pack it again
find . | cpio --create --format='newc' | gzip -9 > ../newinitrd.img
From: How To Modify initrd.img
and then create the new boot.img with the new initrd.img
Code:
abootimg --create newboot.img -k zImage -r newinitrd.img -f bootimg.cfg
This new boot.img doesn't make the device boot and it only shows the Samsung logo and then reboots

Related

post your build scripts

Code:
FILENAME=`date +%Y.%m.%d-%H.%M.%S`
export CCOMPILER=~/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
export KERN_DIR=~/mydroid/kernel
export DROID_ARCH=arm
export JCOUNT=`cat /proc/cpuinfo | grep processor | wc -l`
echo "Cleaning"
cd $KERN_DIR
make clean
echo "**Building Kernel**"
#make ARCH=$DROID_ARCH CROSS_COMPILE=$CCOMPILER -j${JCOUNT}
make ARCH=$DROID_ARCH CROSS_COMPILE=$CCOMPILER
mv $KERN_DIR/arch/arm/boot/zImage ~/droidtmp/${FILENAME}_zImage
echo "**Building WLAN**"
#make clean
cd ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32
make ARCH=$DROID_ARCH CROSS_COMPILE=$CCOMPILER KERNEL_DIR=$KERN_DIR
#mv ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32/wlan.ko ~/droidtmp/build/system/lib/modules/wlan.ko
cp ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32/wlan.ko ~/droidtmp/${FILENAME}_wlan.ko
echo "**Building boot.img**"
~/mydroid/out/host/linux-x86/bin/mkbootimg --cmdline 'no_console_suspend=1 console=null' --kernel ~/droidtmp/${FILENAME}_zImage --ramdisk ~/droidtmp/ramdisk-new.gz -o ~/droidtmp/${FILENAME}_boot.img
#echo "**Adding boot.img to base**"
#TODO
#echo "**Signing zip**"
#TODO
Code:
#!/bin/sh
export KERNEL_DIR=/home/chris/cm-kernel
export TOOLCHAIN=/home/chris/mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi-
cd $KERNEL_DIR
make ARCH=arm CROSS_COMPILE=$TOOLCHAIN
echo ---Finished building kernel!
rm -r out/*
make ARCH=arm CROSS_COMPILE=$TOOLCHAIN INSTALL_MOD_PATH=./out/modules/ modules_install
echo ---Finished building modules tree!
cd out/modules
mksquashfs . ../modules.sqf -noappend
cd ../../
echo ---Finished building module squish!
cd ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32
make ARCH=arm CROSS_COMPILE=$TOOLCHAIN KERNEL_DIR=$KERNEL_DIR
echo ---Finished building wlan.ko!
cd ~/32A
cp $KERNEL_DIR/arch/arm/boot/zImage kernel
cp $KERNEL_DIR/out/modules.sqf update/system/modules/modules.sqf
cp ~/mydroid/system/wlan/ti/sta_dk_4_0_4_32/wlan.ko ~/32A/update/system/lib/modules/wlan.ko
/home/chris/bin/mkbootimg --cmdline "no_console_suspend=1 console=null" --kernel kernel --ramdisk ramdisk -o boot.img
echo ---Finished making boot image!
echo ---Preparing flashable update
cp boot.img update/
cd update
rm *.zip
zip -r update.zip boot.img system/ META-INF/
mv update.zip ../sign
echo ---Signing update
cd ../sign
java -jar signapk.jar testkey.x509.pem testkey.pk8 update.zip update_s.zip
mv update_s.zip update.zip
mv update.zip ~/32A/
echo ---Done - image is in ~/32A!

[9001] Kernel - Extracting initrd.img from zImage and package again

Disclaimer: Do only use this information if you know what you're doing!
PATH=$PATH:/home/markus/android/sdk/platform-tools
Get kernel from phone:
adb shell
su
dd if=/dev/block/mmcblk0p8 of=/sdcard/external_sd/stockboot.img
Exit adb shell
adb pull /sdcard/external_sd/stockboot.img
Separate the zImage from the ramdisk (see below for abootimg):
abootimg -x stockboot.img
unpacks the archive and copies contents to working directory:
gunzip -c initrd.img | cpio -i
Do your edits, e.g. default.prop, add:
debug.performance.tuning=1
video.accelerate.hw=1
windowsmgr.max_events_per_sec=150
--> move all files to new folder, cd into this folder:
repacks files from working directory into an archive (MAKE SURE NO OTHER FILES ARE IN THE WORKING DIRECTORY!!)
find . | cpio -o -H newc | gzip > ../myinitrd.img
New boot.img:
./mkbootimg --kernel zImage --ramdisk myinitrd.img --cmdline "console=null androidboot.hardware=qcom androidboot.emmc=true hw=6" -o myBuiltBoot.img --base 0x00400000 --pagesize 4096
You can also use abootimg to create your new .img file, it has an easier syntax as it exports the commandline to a .cfg file and you can use that while creating the package.
Push your new kernel.img to the phone:
adb push myBuiltBoot.img /sdcard/external_sd/myBuiltBoot.img
Write kernel to kernel-partition in phone:
adb shell
su
dd if=/sdcard/external_sd/myBuiltBoot.img of=/dev/block/mmcblk0p8
adb reboot
< pray >
Sources:
http://forums.androidcentral.com/lg...ense-back-up-your-phone-without-nandroid.html
http://forum.xda-developers.com/showthread.php?t=1227269
http://forum.xda-developers.com/showthread.php?t=1292557
Also quite handy: http://packages.debian.org/de/sid/abootimg
wouldnt just editing build.prop in /system without touching kernel do the same job? ^_^
Yep. I just wanted to describe the whole process of extracting and packing the needed files. The edit was just an example. And in fact, i made a typo, it's called default.prop.

[ARM][x86_64]ElfTool - Pack and unpack boot image for sony mobile devices

ElfTool​
This tool will help you to pack and unpack boot image for sony mobile devices.
Usage :
For unpacking
Code:
elftool unpack -i input-path -o output-path
For packing
If you have header file containing address of kernel, ramdisk etc..
Code:
elftool pack -o output-path header=path/to/header kernel-path ramdisk-path,ramdisk ipl-path,ipl rpm-path,rpm [email protected]
Else
Code:
elftool pack -o output-path [email protected] [email protected],ramdisk [email protected],ipl [email protected],rpm [email protected]
The tool was created for injecting twrp recovery ramdisk to fxp cm10 boot images to prevent overwriting of cwm ramdisk over twrp ramdisk. I hope this tool will be useful for other developers also.
Here is how I used it for injecting twrp to fxp cm10 boot images.
During start of twrp run backup.sh. This will extract twrp ramdisk from the boot partition and store it in /cache/backup
Code:
mount /cache
cd /cache
mkdir backup
cd backup
dump_image /dev/block/mmcblk0p3 /cache/backup/oldboot.img
mkdir oldboot
elftool unpack -i /cache/backup/oldboot.img -o /cache/backup/oldboot
cd oldboot
mkdir uramdisk
cd uramdisk
gzip -dc ../ramdisk | cpio -i
mv sbin/ramdisk-recovery.cpio /cache/backup/ramdisk-recovery.cpio
cd /cache/backup
rm -irf oldboot
rm oldboot.img
When a new zip file is installed inject.sh is run. This will extract the newly installed boot image and inject the twrp ramdisk into it and then flash the newly created bootimage.
Code:
#!/sbin/sh
mount /cache
dump_image /dev/block/mmcblk0p3 /cache/newboot.img
mkdir /cache/newboot
elftool unpack -i /cache/newboot.img -o /cache/newboot
rm cache/newboot.img
cd /cache/newboot
mkdir uramdisk
cd uramdisk
gzip -dc ../ramdisk | cpio -i
rm ../ramdisk
if [ -e "/cache/backup/ramdisk-recovery.cpio" ];then
cp /cache/backup/ramdisk-recovery.cpio sbin/ramdisk-recovery.cpio
cd ..
mkbootfs uramdisk > ramdisk.cpio
cat ramdisk.cpio | gzip > ramdisk
rm -irf uramdisk
rm ramdisk.cpio
elftool pack -o /cache/injectboot.img [email protected] [email protected],ramdisk [email protected]
cd /cache
rm -irf newboot
if [ -e "/cache/injectboot.img" ];then
erase_image /dev/block/mmcblk0p3
flash_image /dev/block/mmcblk0p3 /cache/injectboot.img
rm /cache/injectboot.img
fi
fi
Both arm and x86_64 versions are available.
Thanks to sony for providing boot image format in packelf.py
Source code can be found here
yeah
thanks bro
srl3gx said:
ElfTool​
This tool will help you to pack and unpack boot image for sony mobile devices.
Click to expand...
Click to collapse
Thanks for this tool. It helped me edit a kernel.
Btw, I've used the source to compile x86 version. I've attached it here.
I'm trying to use it on my ubuntu but it doesn't work. I get error: elftool: command not found
I want to unpack CM10 boot.img
Great. Will try it as soon as possible Thanks

[Q] Need help modifying boot blob

Could someone point me to some instructions on how to unpack, modify, and repack a boot.blob out of a kernel?
I'm trying to update bryce's kernel to use Data2SD mod, and I'm following the instructions from here:
http://forum.xda-developers.com/showpost.php?p=29532041&postcount=15
However, I tried unpacking and repacking without even modifying anything and I just get bootlooped.
Read this: http://forum.xda-developers.com/showpost.php?p=36925180&postcount=4
Do you want to use the Data2SD mod with CM or with CROMI? For CROMI I posted a kernel with auto-detection of Data2SD in bryce's thread - only for CM you'd have to do it yourself.
Thanks for the help. I actually just figured out a different way right before seeing your reply. I use blobpack and blobunpack from BlobTools git, and abootimg installed from Ubuntu repository. This script has the extracted bryce kernel zip in a directory called result, so I overwrite his boot.blob with my new one.
Code:
#!/bin/bash
#Clean:
rm out boot.img new_boot.img boot2.blob linux_processed.zip -r
mkdir -p out
echo;echo "**** Unpacking boot.blob to boot.img";echo
cp result/boot.blob .
../linux/blobunpack boot.blob
mv boot.blob.LNX boot.img
cd out
# now in out
echo;echo "**** Unpacking boot.img";echo
abootimg -x ../boot.img
#zcat initramfs|cpio -tiv
echo;echo "**** Extracting initrd.img";echo
mkdir -p initramfs
cp initrd.img initramfs/initramfs.gz
mv initrd.img old_initrd.img
cd initramfs
# now in old/initramfs
gzip -d initramfs.gz
cpio -i < initramfs
echo;echo "**** Modifying boot information";echo
perl -pi -e 's/mmcblk0p2/mmcblk1p3/g' *
perl -pi -e 's/mmcblk0p8/mmcblk1p2/g' *
echo;echo "**** Recompressing initrd.img";echo
find | cpio -H newc -o | lzma -9 > ../initrd.img
cd ..
# now in out
echo;echo "**** Creating new_boot.img";echo
abootimg --create ../new_boot.img -f bootimg.cfg -k zImage -r initrd.img
cd ..
#now out of out
echo;echo "**** Pack boot2.blob";echo
../linux/blobpack boot2.blob LNX new_boot.img
cp boot2.blob result/boot.blob
cd result
echo;echo "**** Zip it all up";echo
zip ../linux_processed.zip * -r
cd ..
I am trying to get bryce's CM10.1 kernel working with Data2SD. I thought all I needed to do was change the mount commands in fstab.cardhu so that data (and I'm trying to do cache too) moved to external partitions.
Those perl pie commands in the middle were supposed to change internal data partition and internal cache partition into the external SD card partition 2 and 3, respectively. As far as I can tell, the changes were made correctly and the blob and zip were re-created, but it didn't work when I booted with the new blob.
Any ideas why it doesn't seem to have worked? Are there other changes I'm missing?
Edit:
Looks like my boot.blob is not being applied. I've tried both flashing the zip and dd'ing it to mmcblk0p4, but in both cases, I do not get the bootloader update screen on reboot, it just boots straight into my old settings. What am I missing?
Edit again:
Oops, I had stopped adding the signature on the blobs for some reason, looks like I'm off a few steps, because now I get bootloops again.
AW: [Q] Need help modifying boot blob
oblib__ said:
Thanks for the help. I actually just figured out a different way right before seeing your reply. I use blobpack and blobunpack from BlobTools git, and abootimg installed from Ubuntu repository. This script has the extracted bryce kernel zip in a directory called result, so I overwrite his boot.blob with my new one.
Code:
#!/bin/bash
#Clean:
rm out boot.img new_boot.img boot2.blob linux_processed.zip -r
mkdir -p out
echo;echo "**** Unpacking boot.blob to boot.img";echo
cp result/boot.blob .
../linux/blobunpack boot.blob
mv boot.blob.LNX boot.img
cd out
# now in out
echo;echo "**** Unpacking boot.img";echo
abootimg -x ../boot.img
#zcat initramfs|cpio -tiv
echo;echo "**** Extracting initrd.img";echo
mkdir -p initramfs
cp initrd.img initramfs/initramfs.gz
mv initrd.img old_initrd.img
cd initramfs
# now in old/initramfs
gzip -d initramfs.gz
cpio -i < initramfs
echo;echo "**** Modifying boot information";echo
perl -pi -e 's/mmcblk0p2/mmcblk1p3/g' *
perl -pi -e 's/mmcblk0p8/mmcblk1p2/g' *
echo;echo "**** Recompressing initrd.img";echo
find | cpio -H newc -o | lzma -9 > ../initrd.img
cd ..
# now in out
echo;echo "**** Creating new_boot.img";echo
abootimg --create ../new_boot.img -f bootimg.cfg -k zImage -r initrd.img
cd ..
#now out of out
echo;echo "**** Pack boot2.blob";echo
../linux/blobpack boot2.blob LNX new_boot.img
cp boot2.blob result/boot.blob
cd result
echo;echo "**** Zip it all up";echo
zip ../linux_processed.zip * -r
cd ..
I am trying to get bryce's CM10.1 kernel working with Data2SD. I thought all I needed to do was change the mount commands in fstab.cardhu so that data (and I'm trying to do cache too) moved to external partitions.
Those perl pie commands in the middle were supposed to change internal data partition and internal cache partition into the external SD card partition 2 and 3, respectively. As far as I can tell, the changes were made correctly and the blob and zip were re-created, but it didn't work when I booted with the new blob.
Any ideas why it doesn't seem to have worked? Are there other changes I'm missing?
Edit:
Looks like my boot.blob is not being applied. I've tried both flashing the zip and dd'ing it to mmcblk0p4, but in both cases, I do not get the bootloader update screen on reboot, it just boots straight into my old settings. What am I missing?
Edit again:
Oops, I had stopped adding the signature on the blobs for some reason, looks like I'm off a few steps, because now I get bootloops again.
Click to expand...
Click to collapse
I had a hard time getting this done too. I couldn't find working blob tools at first. So I ended up using blob tools for windows. They also sign them directly. But I am also running Ubuntu in a vm
Sent from my Nexus 4 using xda premium

[Q] I'm trying to boot my Nexus 10 with your linux-kvm-arm kernel version 3.13...

Hello to everyone,
I'm trying to boot my Nexus 10 with another kind of kernel version,because I'm not interested to use the Android kernel,but the Ubuntu pure kernel. I've chosen to use the linux-kvm-arm kernel version 3.13 :
These are the commands that I have used :
git clone git://github.com/virtualopensystems/linux-kvm-arm.git
cd linux-kvm-arm
git checkout origin/chromebook-3.13 -b chromebook-3.13
curl http://www.virtualopensystems.com/downloads/guides/kvm_on_chromebook/config > .config
and then I've added these lines to the .config file :
CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_ASHMEM=y
CONFIG_ANDROID_LOGGER=y
CONFIG_ANDROID_PERSISTENT_RAM=y
CONFIG_ANDROID_RAM_CONSOLE=y
CONFIG_ANDROID_TIMED_OUTPUT=y
CONFIG_ANDROID_TIMED_GPIO is not set
CONFIG_ANDROID_LOW_MEMORY_KILLER=y
CONFIG_ANDROID_SWITCH is not set
CONFIG_ANDROID_INTF_ALARM is not set
CONFIG_FB_TILEBLITTING=y
CONFIG_PHONE is not set
CONFIG_USB_WPAN_HCD is not set
CONFIG_WIMAX_GDM72XX is not set
CONFIG_ARM_PLATFORM_DEVICES=y
CONFIG_ARM_CHROMEOS_FIRMWARE=y
CONFIG_CHROMEOS=y
CONFIG_CHROMEOS_VBC_BLK=y
CONFIG_CHROMEOS_VBC_EC=y
CONFIG_CHROMEOS_RAMOOPS_RAM_START=0x41f00000
CONFIG_CHROMEOS_RAMOOPS_RAM_SIZE=0x00100000
CONFIG_CHROMEOS_RAMOOPS_RECORD_SIZE=0x00020000
CONFIG_CHROMEOS_RAMOOPS_DUMP_OOPS=0x1
CONFIG_CLKDEV_LOOKUP=y
and then I did :
ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- make uImage dtbs
from here I've followed the tutorial that I've found here :
http://forum.xda-developers.com/showthread.php?t=1981788
and here :
http://forum.xda-developers.com/showthread.php?t=1981788&page=2
mkdir -p newkernel
cd newkernel
wget -c https://dl.google.com/dl/android/aosp/mantaray-kot49h-factory-174ba74f.tgz
tar xvzf mantaray-kot49h-factory-174ba74f.tgz
cd mantaray-kot49h
unzip image-mantaray-kot49h.zip
wget -c http://android-serialport-api.googlecode.com/files/getramdisk.py
chmod +x getramdisk.py
./getramdisk.py boot.img --> ramdisk.img
wget -c http://android-serialport-api.googlecode.com/files/android_bootimg_tools.tar.gz
tar xvf android_bootimg_tools.tar.gz
./mkbootimg --kernel ../../linux-kvm-arm/arch/arm/boot/zImage --ramdisk ramdisk.img --cmdline bootimg.cfg -o new-boot.img
fastboot flash boot new-boot.img
I think that something is wrong here,because it is not able to boot....I see a black screen and nothing else happens...any ideas ?

Categories

Resources