[SCRIPT] Make ODIN Flashable tars - Android General

Easy peasy. Download the script attached and run as follows to create an Odin flashable tar
Code:
$ odintar image_1 image_2 image_3 ... image_X package.tar
You can also run the script with no arguments to get the usage information.
The output will be a package.tar.md5 which will contain all the image_XXX files you specified, and will also be Odin flashable.
Flash at your own risk, but I have tested this and it works. Just helps to automate tar flashable making
Instructions for use:
Download and remove .txt extension
Move/Copy to somewhere in your path (~/bin, /usr/local/bin, [for cygwin move it to C:/path/to/cygwinDirectory/bin] anywhere in your PATH)
Run to make tars
Profit.
Contents of script file:
Code:
#!/bin/bash
if [ "[email protected]"="" ]
then
echo "Usage: $0 image_1 image_2 ... image_X package.tar"
exit 0
fi
O=${#@}
((NUM = ${#@} - 1))
tar -H ustar -c ${@:1:$NUM} > ${@:$O}
md5sum -t ${@:$O} >> ${@:$O}
mv ${@:$O} ${@:$O}.md5

Related

[UTIL] signapk.sh: onboard .apk signing. 100% java-free

Since I tend to modify roms before flashing them to my phone, and sometimes want to do so away from a computer, I ended up writing this. It's an ash script that uses the openssl binary found on most custom roms, and infozip. The sdk test/platform/media/etc keys are included. Usage:
Usage: signapk (options) [command] (files)
commands:
sign FILE sign a .zip or .apk
sign FILE1 FILE2 create a signed copy of FILE1 as FILE2
cert FILE(s) print cert info on FILE's signer
certinfo FILE print detailed cert info on FILE's signer
cmp FILE compare signer of FILE with default/selected cert
cmp FILE1 FILE2 compare signer of FILE1 to signer of FILE2
options:
-k, --key FILE key to sign with
-c, --cert FILE cert to sign with
if -c or -k are not files then they are considered
aliases to builtins (ie -k testkey or -c platform)
-f, --force sign even if cert differs from original
-t, --tmp DIR use DIR for tempdir instead of '/cache'
-d, --debug output debugging
-V, --version print 'signapk v0.3.1'
exit codes:
1: read error (file 1) 2: read error (file 2)
3: write error 4: ssl error
5: zip write error 9: key error
8: sign: cert mismatch 10: cmp: cert mismatch
128: script error 255: user error
Installation:
unpack somewhere. If needed, edit the variables at the top of the script. By default it uses /cache/ for 4 small temporary files.
Faq:
* Why did you include a busybox and openssl? * Some roms don't include the openssl utility. Busybox's unzip refuses to deal with zipaligned apks on alot of roms, because it wasn't compiled with ENABLE_DESKTOP. Busybox's ash is missing things that the script needs, on some roms. The script will use whatever the rom provides, if these binaries are not present. Good luck.
* How do I change the cert? * see signapk --help for cert/key selection flags
* Can I use this in my MarketAppThingy? * Sure, and please let me know. If it's a paid MarketAppThingy, consider sending me a free copy.
Changelog:
release 3: cmp function, key selection, documented exit codes that make sense, and paranoia. Includes trimmed down busybox and openssl binaries. If these are present, script will reload itself to run in it's busybox ash interpreter to avoid broken busybox compiles, and can run without using anything provided by the rom. In theory this means no compatibility issues, but is limited to ARM devices.
release 2: Apparently it's valid to have ANYNAME.SF/ANYNAME.RSA or ANYNAME.DSA. signapk cert and certinfo now handles this. The sign function will blindly write to CERT.SF and CERT.RSA as this is the behavior of the standard SignApk.java. This may be fixed later.
If you don't wanna signup to download attachment, snag this from http://code.google.com/p/signapk/downloads/list
very, very useful. I'm testing this now Signing stuff was always way too complicated.
Cool. Can't wait for someone to make a market app that creates a simple ui to edit update.zips before flashing. Hint hint
I put the files in /system/signapk (new folder)
When i run the script I get the error below. The test file is an unsigned apk exported from eclipse.
Code:
# ./signapk sign /sdcard/unsigned.apk
./signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
[COLOR="Red"]unable to write 'random state'
./signapk: line 132: ./signapk.zip: not found[/COLOR]
#
Any idea what needs changing to fix this?
update: When I used the full path it worked.
Code:
# /system/signapk/signapk sign /sdcard/unsigned.apk
/system/signapk/signapk sign /sdcard/unsigned.apk
Checksumming /mnt/sdcard/unsigned.apk:
res/layout/main.xml AndroidManifest.xml
resources.arsc res/drawable-hdpi/icon.png res/drawable-ldpi/icon.png res/drawable-mdpi/icon.png classes.dex
unable to write 'random state'
adding: META-INF/MANIFEST.MF (deflated 49%)
adding: META-INF/CERT.SF (deflated 48%)
adding: META-INF/CERT.RSA (deflated 33%)
# /system/signapk/signapk cert /sdcard/unsigned.apk
/system/signapk/signapk cert /sdcard/unsigned.apk
/sdcard/unsigned.apk 936EACBE07F201DF SDK Test Key
Was playing around with app inventor and came up with this:
edit: AppInventor does not generate java code and it cannot be worked on further in anything else (i.e eclipse)
I was really hoping I would atleast get the activity xml
Heya, the latest is at http://code.google.com/p/signapk/downloads/list and should fix the zip error. signapk-bb, signapk-zip, and signapk-openssl are static, trimmed down versions of utilities required by the script, and should be extracted to the same directory as the script. If they are not present it will try to use stuff in $PATH
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Hmmmm....
britoso said:
Just throwing it (the obvious) out there that this could enable a new generation of morphs for /data apps
Copy apk,uninstall,morph, install
Click to expand...
Click to collapse
How can i get this to work with a morph and to edit the updater-script?
Someone explain the commands with example...
Another noob question is .. it is for android or pc...
Edit:- Made my own mod here https://forum.xda-developers.com/t/...-apk-zip-within-android.3835975/post-81324327
below code works with latest(1.32.0) busybox
Bash:
#!/system/bin/sh
# depends unzip printf zip openssl
# put zip openssl busybox in PATH
# Usage:-
# Sign.sh key.pk8 key.x509.pem in.zip out.zip
ordie() {
if [ $? -ne 0 ]; then
IFS=" "
$BB printf "$1\n"
exit $2
fi
}
PKEY="$1"
CERT="$2"
ORIG="$3"
TARGET="$4"
BB=busybox
cat "$ORIG" > "$TARGET"; ordie "Cannot write to $TARGET" 3
$BB printf "Checksumming $ORIG:\n"
TMP=$HOME
TMPDIR="$TMP/sign-$$"
TMPPKEY="$TMPDIR/tmp.pkey"
mkdir -p "$TMPDIR/META-INF"; ordie "" 3
$BB printf "Manifest-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\n\r\n" > "$TMPDIR/META-INF/MANIFEST.MF"
ZIPls=$($BB unzip -qql "$ORIG"); ordie "$ORIG: unzip error" 1
OLDIFS=$IFS
IFS=${IFS:2:2}
for i in $ZIPls; do
IFS=$OLDIFS
set -- $i
if [ "$#" -ge 3 ] && [ "$1" != "0" ]; then
file="${i:30}"
case "$file" in META-INF/MANIFEST.MF|META-INF/CERT.SF|META-INF/CERT.RSA) continue;; esac
$BB printf "$file "
hash=$($BB unzip -p "$ORIG" "$file" | openssl sha1 -binary | openssl base64); ordie "$ORIG: unzip error" 1
ret="Name: $file\r\nSHA1-Digest: $hash\r\n\r\n"
$BB printf "$ret" >> "$TMPDIR/META-INF/MANIFEST.MF"
hash=$($BB printf "$ret" | openssl sha1 -binary | openssl base64)
$BB printf "Name: $file\r\nSHA1-Digest: $hash\r\n\r\n" >> "$TMPDIR/META-INF/CERT.SF.temp"
fi
done
$BB printf "\n"
mfhash=$(cat "$TMPDIR/META-INF/MANIFEST.MF" | openssl sha1 -binary | openssl base64)
$BB printf "Signature-Version: 1.0\r\nCreated-By: 1.0 (Android SignApk)\r\nSHA1-Digest-Manifest: $mfhash\r\n\r\n" > "$TMPDIR/META-INF/CERT.SF"
cat "$TMPDIR/META-INF/CERT.SF.temp" >> "$TMPDIR/META-INF/CERT.SF"
openssl pkcs8 -inform DER -nocrypt -in "$PKEY" > "$TMPPKEY"; ordie "" 4
cat "$TMPDIR/META-INF/CERT.SF" | openssl smime -sign -inkey "$TMPPKEY" -signer "$CERT" -binary -outform DER -noattr > "$TMPDIR/META-INF/CERT.RSA"; ordie "" 4
cd "$TMPDIR"
zip "$TARGET" META-INF/MANIFEST.MF META-INF/CERT.SF META-INF/CERT.RSA; ordie "" 5
cd - > /dev/null
rm -r "$TMPDIR"

[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.

Help extracting initramfs from Kernel [SOLVED]

Hi,
My Question is
How do i extract initramfs from a Kernel.bin file ?
the Galaxy S Advance uses Kernel.bin instead of a boot.img
I tried dsixda's kitchen, but it couldn't recognize the file format
I just want to replace a certain binary in the /sbin folder and repack the kernel.
Edit:this phone is kinda different,
it seems that the recovery and kernel partitions are the same
Figured it out
The zImage created after compilation process is actually the same, a kernel binary aka kernel.bin
I just had to rename the zImage to kernel.bin and add md5sum to the kernel.bin and pack it into a tarball to make it flashable via odin.
that can be done like this
Code:
md5sum -t kernel.bin >> kernel.bin
mv kernel.bin kernel.bin.md5
tar -cvf mykernel.tar kernel.bin.md5
As for packing the ramdisk into the kernel.bin
that can be done before compiling by editing the .config file or any config you gonna use
just have to add the path to the ramdisk at CONFIG_INITRAMFS_SOURCE="path to your ramdisk"
There's also a script to unpack the ramdisk from the kernel.bin, i'll attach it here
usage:
place the script at the same location of the kernel.bin
Code:
chmod +x unpack-initramfs.sh
bash unpack-initramfs.sh kernel.bin.md5
OR
/bin/sh unpack-initramfs.sh kernel.bin.md5
Hope this helped Others who were facing the same problem
how to repack it?

[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

[GUIDE] A Comprehensive Guide to Create Prerooted Odin Flashable Packages

GUIDE TO CREATE ODIN FLASHABLE
PREROOTED (and/or) PRETHEMED FIRMWARES
Guide by hnkotnis​
Featured On Portal! Thanks EAGLEEYETOM Sir.
http://www.xda-developers.com/android/make-your-own-pre-rooted-odin-flashable-firmware-with-ease/
Click to expand...
Click to collapse
Hello Everyone!
All of us, who own a Samsung device, need Odin Flash to go back to stock firmware.
This is done for various reasons like you want to flash a new ROM, so going to use stock ROM to serve as a base
or simply love stock ROM because of its stability.
However there is a catch. As soon as you flash the firmware, you lose root access.
Then starts the process (oftenly boring as you do it many times) and not to mention wear and tear of hardware buttons in recovery.
But this is easily solved by converting the firmwares into prerooted ones. You can put Superuser/SuperSU (and/or) busybox.
I assume you use 3 file flashing. PDA, PHONE (that is MODEM) and CSC.
hnkotnis said:
For my Samsung Galaxy y, I split firmware using SplitFUS2, because Galaxy y does not support single file flashing. It requires PDA, PHONE,CSC
But if your phone supports 1 file flashing, then rename xxxx_xxxx_HOME.tar.md5 to xxxx_xxxx_HOME.tar (I assume you know how to CHANGE FILE EXTENSION BY RENAMING)
Then extract it by WinRAR/7zip anything. You will get boot.img, system.img etc. Then at last step you make tar of these extracted files.
Click to expand...
Click to collapse
Now coming to the point, there are 3 cases.
1) Firmwares which are in rfs and converted with simg2img
2) Latest firmwares which are based on ext4 (These files when extracted they are named as system.img.ext4 etc.)
3) Firmwares which show "bad magic" with simg2img (like galaxy y firmwares)
INDEX:-
1) rfs firmwares compatible with simg2img (First Post)
2) New ext4 firmwares (These files when extracted they are named as system.img.ext4 etc.) (Second Post)
3) rfs firmwares not compatible with simg2img (Third Post)​
Click to expand...
Click to collapse
Prerequisites:-
1) Linux Environment (virtualbox can work) (I use Ubuntu 12.04 VBOX) (for case 3 cygwin will work)
2) Ability to transfer files from Virtualbox to Host (Refer here)
3) ext4_utils from here (They are required only for first 2 cases) (Put them in working folder)
4) Usable brain (must be dual core) Download Link:- Error 404: File encrypted to keep trolls away
Click to expand...
Click to collapse
CASE 1:- rfs format with simg2img support​Credits to dr.ketan
1) Download 3 file firmware from XDA Forum of your device. (skip steps 2 & 3 if you have done this)
2) Download firmware from Sammobile It will be named as xxxx_xxxx_HOME.tar.md5
3) Split it if required into PDA, PHONE & CSC. (We need only PDA file, take it to Linux PC/VBOX)
But if your phone firmware doesn't have PDA, CSC etc flashing, then rename xxxx_xxxx_HOME.tar.md5 to xxxx_xxxx_HOME.tar (I assume you know how to CHANGE FILE EXTENSION BY RENAMING)
Then extract it by WinRAR/7zip anything. You will get boot.img, system.img etc. Then at last step you make tar of these extracted files.
4) Extract it
Code:
tar xvf {your PDA file name here}.tar.md5
5) Convert it to ext4 to make it mountable.
Code:
./simg2img system.img newsys.img
Then delete old system.img
6) Create temp folder and mount it.
Code:
mkdir temp
mount -o loop newsys.img temp
7) Add root app (I am adding Superuser.apk), su binary and busybox.
Code:
cp su temp/xbin/su
chmod 06755 temp/xbin/su
cp Superuser.apk temp/app/Superuser.apk
chmod 0644 temp/app/Superuser.apk
cp busybox temp/xbin/busybox
chmod 04755 temp/xbin/busybox
8) Convert newsys.img to samsung system.img format.
Code:
./mkuserimg.sh -s temp system.img ext4 tempdir 2048M
[COLOR=green]# 2048M is the size of system.img[/COLOR]
9) Unmount and delete temp folder.
Code:
umount temp
rmdir temp
10) Create tar file and add md5 checksum
Code:
tar cvf prerooted.tar boot.img cache.img hidden.img modem.bin recovery.img sboot.bin system.img tz.img
#[COLOR="Green"][I]Please add files which you get in step 4[/I][/COLOR]
md5sum -t prerooted.tar >> prerooted.tar
mv prerooted.tar prerooted.tar.md5
11) Now flash this output file from Odin.
Click to expand...
Click to collapse
Press Thanks if helped.
New ext4 Firmwares
CASE 2:- New ext4 Firmwares​
1) Download 3 file firmware from XDA Forum of your device. (skip steps 2 & 3 if you have done this)
2) Download firmware from Sammobile It will be named as xxxx_xxxx_HOME.tar.md5
3) Split it if required into PDA, PHONE & CSC. (We need only PDA file, take it to Linux PC/VBOX) (I renamed PDA file to stock.tar.md5)
But if your phone firmware doesn't have PDA, CSC etc flashing, then rename xxxx_xxxx_HOME.tar.md5 to xxxx_xxxx_HOME.tar (I assume you know how to CHANGE FILE EXTENSION BY RENAMING)
Then extract it by WinRAR/7zip anything. You will get boot.img, system.img etc. Then at last step you make tar of these extracted files.
YOU NEED ROOT ACCESS IN LINUX TERMINAL.
4) Extract it to working folder.
Code:
tar xvf {your PDA file name here}.tar.md5
5) Create temp folder and mount it.
Code:
mkdir temp
sudo mount -o loop system.img.ext4 temp
6) Add root app (I am adding Superuser.apk), su binary and busybox.
Code:
cp su temp/xbin/su
chmod 06755 temp/xbin/su
cp Superuser.apk temp/app/Superuser.apk
chmod 0644 temp/app/Superuser.apk
cp busybox temp/xbin/busybox
chmod 04755 temp/xbin/busybox
8) Convert newsys.img to samsung system.img format.
Code:
./mkuserimg.sh -s temp system.img ext4 tempdir 2048M
9) Unmount and delete temp folder.
Code:
umount temp
rmdir temp
10) Create tar file and add md5 checksum
Code:
tar -H ustar -c aboot.mbn boot.img cache.img.ext4 hidden.img.ext4 modem.bin NON-HLOS.bin recovery.img rpm.mbn sbl2.mbn sbl3.mbn system.img.ext4 tz.mbn > prerooted.tar
#[COLOR="Green"][I]Please add files which you get in step 4[/I][/COLOR]
md5sum -t prerooted.tar >> prerooted.tar
mv prerooted.tar prerooted.tar.md5
11) Now flash this output file from Odin.
Click to expand...
Click to collapse
Press Thanks if helped.
rfs Firmwares incompatible with simg2img
CASE 3:- rfs Firmwares incompatible with simg2img
(Works with above type phones also)​
1) Download 3 file firmware from XDA Forum of your device. (skip steps 2 & 3 if you have done this).
2) Download firmware from Sammobile It will be named as xxxx_xxxx_HOME.tar.md5
3) Split it if required into PDA, PHONE & CSC. (We need only PDA file, take it to Linux PC/VBOX) (I renamed PDA file to stock.tar.md5)
But if your phone firmware doesn't have PDA, CSC etc flashing, then rename xxxx_xxxx_HOME.tar.md5 to xxxx_xxxx_HOME.tar (I assume you know how to CHANGE FILE EXTENSION BY RENAMING)
Then extract it by WinRAR/7zip anything. You will get boot.img, system.img etc. Then at last step you make tar of these extracted files.
YOU NEED ROOT ACCESS IN LINUX TERMINAL.
4) Extract it
Code:
tar xvf {your PDA file name here}.tar.md5
5) Flash your phone with stock firmware, root it, install busybox (You can also deodex and/or theme it).
Know mount point of /system partition of your phone.
In my Galaxy y it is stl9. So replace red coloured letters with your moint point.
6) Go to terminal emulator on phone and type
Code:
su
dd if=/dev/block/[COLOR="red"]stl9[/COLOR] of=/sdcard/system.img bs=4096
7) Pull this file to your computer (Use any method, adb or mount card)
8) Put this file in your working folder.
9) In Linux/Cygwin Terminal, type
Code:
tar cvf prerooted.tar [COLOR="Green"]LIST OF EXTRACTED FILES AND SYSTEM.IMG[/COLOR] system.img
#[COLOR="Green"][I]Please add files which you get in step 4[/I][/COLOR]
md5sum -t prerooted.tar >> prerooted.tar
mv prerooted.tar prerooted.tar.md5
11) Now flash this output file from Odin.
Click to expand...
Click to collapse
Press Thanks if helped.
I got my thinking cap on, and am ready to learn,
It sounds feasible for me.
I will install vbox and ubuntu in it... how exciting... I might be able to make my own prerooted stock-app.
Great work!
Would this work on the galaxy s4 with lock boot loader?
How can i split the xxxx_xxxx_HOME.tar.md5 to pda and modem and csc?
hi.. how about the firmware that doesnt contain PDA, PHONE & CSC parts..? some firmware that contains *.img files inside it.. hope you can make guide for this one..
thanks for your work.. great to see this on XDA Portal..
Johrans said:
How can i split the xxxx_xxxx_HOME.tar.md5 to pda and modem and csc?
Click to expand...
Click to collapse
It depends on your phone.
For my Samsung Galaxy y, I split firmware using SplitFUS2, because Galaxy y does not support single file flashing. It requires PDA, PHONE,CSC
But if your phone supports 1 file flashing, then rename xxxx_xxxx_HOME.tar.md5 to xxxx_xxxx_HOME.tar (I assume you know how to CHANGE FILE EXTENSION BY RENAMING)
Then extract it by WinRAR/7zip anything. You will get boot.img, system.img etc. Then at last step you make tar of these extracted files.
hotdroid said:
hi.. how about the firmware that doesnt contain PDA, PHONE & CSC parts..? some firmware that contains *.img files inside it.. hope you can make guide for this one..
thanks for your work.. great to see this on XDA Portal..
Click to expand...
Click to collapse
Please read my comment above this post. It is for the case you are saying.
Also I updated OP with this information. (I know searching OP is hard, OP is very long )
On Case 2, I am trying to mount the system.img. typing "sudo mount -o loop system.img.ext4 temp" only results in "you must specify the filesystem type".
Yeah, nevermind. The mkuserimg.sh has issues, needs work. Line 58 needs to be edited from "MAKE_EXT4FS" to "make_ext4fs" otherwise, it will return command not found. It also never actually builds the resulting image. No system.img.ext4 is ever found anywhere after running the script. Just still left with the original that you started with, with no changes. In addition, some image files with the ext4 extension ARE NOT IN EXT4 FORMAT. You still must rename to remove the ext4 extension, and sim2img in order to mount. Still, all pointless since the mkuserimg.sh is partially fragged. If you attempt to run "Case 2" one some system.img.ext4 images, you will fail. "Sudo mount -o loop system.img.ext4 temp" will result in no more than "you must specify the filesystem type"
Sent from my Nexus 7 using XDA Premium 4 mobile app
hello frnds..
i have a galaxy star pro device
and i am trying to pre root my stock firmware using 1st case
all steps goes well but at the step of repack the system.img file i get following error
[email protected]:/home/akshay/Documents/ext4_utils# ./mkuserimg.sh -s temp system.img ext4 temp 1027M
+ echo 'in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'
in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ ENABLE_SPARSE_IMAGE=
+ '[' -s = -s ']'
+ ENABLE_SPARSE_IMAGE=-s
+ shift
+ '[' 5 -ne 5 -a 5 -ne 6 ']'
+ SRC_DIR=temp
+ '[' '!' -d temp ']'
+ OUTPUT_FILE=system.img
+ EXT_VARIANT=ext4
+ MOUNT_POINT=temp
+ SIZE=1027M
+ FC=
+ case $EXT_VARIANT in
+ '[' -z temp ']'
+ '[' -z 1027M ']'
+ '[' -n '' ']'
+ MAKE_EXT4FS_CMD='make_ext4fs -s -l 1027M -a temp system.img temp'
+ echo make_ext4fs -s -l 1027M -a temp system.img temp
make_ext4fs -s -l 1027M -a temp system.img temp
+ make_ext4fs -s -l 1027M -a temp system.img temp
./mkuserimg.sh: line 58: make_ext4fs: command not found
+ '[' 127 -ne 0 ']'
+ exit 4
[email protected]:/home/akshay/Documents/ext4_utils#
and if i change the mkuserimg.sh file as per the rebel1699 from MAKE_EXT4FS TO make_ext4fs
then i get the following output-
[email protected]:/home/akshay/Documents/ext4_utils# ./mkuserimg.sh -s temp system.img ext4 temp 1027M
+ echo 'in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'
in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ ENABLE_SPARSE_IMAGE=
+ '[' -s = -s ']'
+ ENABLE_SPARSE_IMAGE=-s
+ shift
+ '[' 5 -ne 5 -a 5 -ne 6 ']'
+ SRC_DIR=temp
+ '[' '!' -d temp ']'
+ OUTPUT_FILE=system.img
+ EXT_VARIANT=ext4
+ MOUNT_POINT=temp
+ SIZE=1027M
+ FC=
+ case $EXT_VARIANT in
+ '[' -z temp ']'
+ '[' -z 1027M ']'
+ '[' -n '' ']'
+ MAKE_EXT4FS_CMD='make_ext4fs -s -l 1027M -a temp system.img temp'
+ echo make_ext4fs -s -l 1027M -a temp system.img temp
make_ext4fs -s -l 1027M -a temp system.img temp
+ '[' 0 -ne 0 ']'
[email protected]:/home/akshay/Documents/ext4_utils#
no system.img file is created
so how to resolve this problem???
akkishayk said:
hello frnds..
i have a galaxy star pro device
and i am trying to pre root my stock firmware using 1st case
all steps goes well but at the step of repack the system.img file i get following error
[email protected]:/home/akshay/Documents/ext4_utils# ./mkuserimg.sh -s temp system.img ext4 temp 1027M
+ echo 'in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'
in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ ENABLE_SPARSE_IMAGE=
+ '[' -s = -s ']'
+ ENABLE_SPARSE_IMAGE=-s
+ shift
+ '[' 5 -ne 5 -a 5 -ne 6 ']'
+ SRC_DIR=temp
+ '[' '!' -d temp ']'
+ OUTPUT_FILE=system.img
+ EXT_VARIANT=ext4
+ MOUNT_POINT=temp
+ SIZE=1027M
+ FC=
+ case $EXT_VARIANT in
+ '[' -z temp ']'
+ '[' -z 1027M ']'
+ '[' -n '' ']'
+ MAKE_EXT4FS_CMD='make_ext4fs -s -l 1027M -a temp system.img temp'
+ echo make_ext4fs -s -l 1027M -a temp system.img temp
make_ext4fs -s -l 1027M -a temp system.img temp
+ make_ext4fs -s -l 1027M -a temp system.img temp
./mkuserimg.sh: line 58: make_ext4fs: command not found
+ '[' 127 -ne 0 ']'
+ exit 4
[email protected]:/home/akshay/Documents/ext4_utils#
and if i change the mkuserimg.sh file as per the rebel1699 from MAKE_EXT4FS TO make_ext4fs
then i get the following output-
[email protected]:/home/akshay/Documents/ext4_utils# ./mkuserimg.sh -s temp system.img ext4 temp 1027M
+ echo 'in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games'
in mkuserimg.sh PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
+ ENABLE_SPARSE_IMAGE=
+ '[' -s = -s ']'
+ ENABLE_SPARSE_IMAGE=-s
+ shift
+ '[' 5 -ne 5 -a 5 -ne 6 ']'
+ SRC_DIR=temp
+ '[' '!' -d temp ']'
+ OUTPUT_FILE=system.img
+ EXT_VARIANT=ext4
+ MOUNT_POINT=temp
+ SIZE=1027M
+ FC=
+ case $EXT_VARIANT in
+ '[' -z temp ']'
+ '[' -z 1027M ']'
+ '[' -n '' ']'
+ MAKE_EXT4FS_CMD='make_ext4fs -s -l 1027M -a temp system.img temp'
+ echo make_ext4fs -s -l 1027M -a temp system.img temp
make_ext4fs -s -l 1027M -a temp system.img temp
+ '[' 0 -ne 0 ']'
[email protected]:/home/akshay/Documents/ext4_utils#
no system.img file is created
so how to resolve this problem???
Click to expand...
Click to collapse
Use method 3. It is compatible with all Samsung phones.
Helped much
@hnkotnis the numbering is wrong in the part where prerequesits are there Usable brain
androvista said:
@hnkotnis the numbering is wrong in the part where prerequesits are there Usable brain
Click to expand...
Click to collapse
:silly: Corrected it.
hnkotnis said:
​
Press Thanks if helped.
Click to expand...
Click to collapse
i suggesting you to make a video guide as possible as you can do !!!
watching videos clears idea more than text files !!
would you like to make receipe by wwatching youtube or buy book and do it as shown in book ??????????
---------- Post added at 12:37 PM ---------- Previous post was at 12:36 PM ----------
hnkotnis said:
GUIDE TO CREATE ODIN FLASHABLE
PREROOTED (and/or) PRETHEMED FIRMWARES
Guide by hnkotnis​
Hello Everyone!
All of us, who own a Samsung device, need Odin Flash to go back to stock firmware.
This is done for various reasons like you want to flash a new ROM, so going to use stock ROM to serve as a base
or simply love stock ROM because of its stability.
However there is a catch. As soon as you flash the firmware, you lose root access.
Then starts the process (oftenly boring as you do it many times) and not to mention wear and tear of hardware buttons in recovery.
But this is easily solved by converting the firmwares into prerooted ones. You can put Superuser/SuperSU (and/or) busybox.
I assume you use 3 file flashing. PDA, PHONE (that is MODEM) and CSC.
Now coming to the point, there are 3 cases.
1) Firmwares which are in rfs and converted with simg2img
2) Latest firmwares which are based on ext4 (These files when extracted they are named as system.img.ext4 etc.)
3) Firmwares which show "bad magic" with simg2img (like galaxy y firmwares)
​
Press Thanks if helped.
Click to expand...
Click to collapse
i suggesting you to make a video guide as possible as you can do !!!
watching videos clears idea more than text files !!
would you like to make receipe by wwatching youtube or buy book and do it as shown in book ??????????
manojkumar8552 said:
i suggesting you to make a video guide as possible as you can do !!!
watching videos clears idea more than text files !!
would you like to make receipe by wwatching youtube or buy book and do it as shown in book ??????????
---------- Post added at 12:37 PM ---------- Previous post was at 12:36 PM ----------
i suggesting you to make a video guide as possible as you can do !!!
watching videos clears idea more than text files !!
would you like to make receipe by wwatching youtube or buy book and do it as shown in book ??????????
Click to expand...
Click to collapse
Why you are posting same thing double?
And no, I cannot make and upload video. It will take lot of time to upload. I have really bad internet.
Sent from my GT-I9001 Gadget of Mass Destruction with CM11 using XDA Developers App.
tar cvf prerooted.tar boot.img cache.img hidden.img modem.bin recovery.img sboot.bin system.img tz.img
Click to expand...
Click to collapse
Hi OP,
Can you please provide the block partitions of the imgs? Would like to dump them from my phone :good:
Note 2 KitKat
I assume that this will not work an Note 2 Android 4.4.2, right?
Only changes in system.img won't pre-root any more afaik....

Categories

Resources