Unpacking boot.img of gt-i8160? - Galaxy Ace S5830i Q&A, Help & Troubleshooting

Hi,
has anyone unpacked the boot.img of our ace 2? I created the boot.img with a CWM backup and also with this command:
Code:
su
dd if=dev/block/mmcblk0p15 of=/mnt/sdcard/boot.img
but i can't unpack the file, get the message "Android 'magic' header not found at start of boot.img" or similar. Tried with Android Kitchen and this command:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Can anyone help me?

rs90xda said:
Hi,
has anyone unpacked the boot.img of our ace 2? I created the boot.img with a CWM backup and also with this command:
Code:
su
dd if=dev/block/mmcblk0p15 of=/mnt/sdcard/boot.img
but i can't unpack the file, get the message "Android 'magic' header not found at start of boot.img" or similar. Tried with Android Kitchen and this command:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Can anyone help me?
Click to expand...
Click to collapse
I took boot.img from CWM Recovery during making recovery
boot.img

If you guys can, take my kernel from MX general thread, take out the kernel.bin.md5, remove the md5 extension by removing the hash sum and then rename kernel.bin to zImage. Then inject it into the boot.ing you have
Sent from my GT-I8160 using Tapatalk 2

michal_ag said:
I took boot.img from CWM Recovery during making recovery
boot.img
Click to expand...
Click to collapse
I think OP did the same... So this boot.img is not proper one? because i want to try do do some "digging" (i'm a newbie in android development/linux) and boot.img is crucial

judas1977 said:
I think OP did the same... So this boot.img is not proper one? because i want to try do do some "digging" (i'm a newbie in android development/linux) and boot.img is crucial
Click to expand...
Click to collapse
I'm struggling with the same problem... Did you already found a solution for this?

These tools that you are using doesn't work because for our device there isn't a regular boot.img
kernel.bin.md5 is just gzipped zImage with ramdisk. Note that ramdisk is not compressed (it's raw cpio file). Tomorrow I'll post script to unpack kernel.bin.md5.
But to pack it again the best way is compile kernel with CONFIG_INITRAMFS_SOURCE specified.

Thanks but how could I know that? I have been looking a lot but couldn't find much info about it... Perhaps I was looking at the wrong places...
[Edit] After your explanation I've found the script myself and extracted the kernel.img.md5

Actually, it's quite simple.
For unpacking:
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
And to be honest, kernel.bin.md5 is nothing but a zImage with MD5 checksum at the end of the file.

bagnz0r said:
Actually, it's quite simple.
For unpacking:
http://forum.xda-developers.com/wiki/index.php?title=Extract_initramfs_from_zImage
And to be honest, kernel.bin.md5 is nothing but a zImage with MD5 checksum at the end of the file.
Click to expand...
Click to collapse
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.

ccnky said:
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.
Click to expand...
Click to collapse
You might need to get these:
Code:
cpio gzip
And don't remove that gz part.

bagnz0r said:
You might need to get these:
Code:
cpio gzip
And don't remove that gz part.
Click to expand...
Click to collapse
I'm not so much noob
This script created empty files for me. I manually typed commands (without gzip) and worked perfect.

ccnky said:
Don't know why but for me this script didn't work on Arch Linux. I had to remove the part where it's checking if cpio is gzipped.
Click to expand...
Click to collapse
Try the last version in github (see at bottom of page on the link bagnz0r has sent) That one worked for me on cygwin.
Sent from my GT-I8160 using xda app-developers app

h3llrais3r said:
Try the last version in github (see at bottom of page on the link bagnz0r has sent) That one worked for me on cygwin.
Sent from my GT-I8160 using xda app-developers app
Click to expand...
Click to collapse
Thanks for your advice but I unpacked ramdisk once and don't have to do that anymore.

Related

[Q] Unpack backup.ab created by "adb backup" command?

Is there any way to unpack the backup files created by the
Code:
adb backup -all
command? (Working since Android 4.0)
It seems this is a file-based backup and unpacking (and repacking) would allow tweaking some internal databases and files without needing to root.
I would like to know this also
I believe the ".ab" format is in some kind of "tar" compressed archive.
bakakaka said:
I believe the ".ab" format is in some kind of "tar" compressed archive.
Click to expand...
Click to collapse
Doesn't look like it. At least it's neither plain tar nor one of tarred gzip, bzip2 or compress. Also, it's not zip or rar.
So what's left?
- The android backup supports encryption. This does not necessarily mean that the archiver has to support that, too, since you could always first archive and then encrypt or vice versa.
- You can include .apk-files in backups. This suggests, that the archiver does not need to be über-effective, like bzip2, since that would cost time and cycles and .apk-files are already compressed, IIRC.
I don't know how to make any sense of this but maybe someone else does?
If anyone is still interested, here's a small utility that does this:
Apparently I can't post links, so add 'http' in front to get the URLs:
github.com/nelenkov/android-backup-extractor
More details about the format and the tool here:
nelenkov.blogspot.jp/2012/06/unpacking-android-backups.html
How to extract android adb ab backup
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
scandiun said:
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
Click to expand...
Click to collapse
Note that this only works for unencrypted backups though.
kapitan_petko said:
Note that this only works for unencrypted backups though.
Click to expand...
Click to collapse
I see
And the other way around:
1. create adb backup header
2. convert tar archive and append to header
Code:
echo -e "ANDROID BACKUP\n1\n1\nnone" > backup.ab
openssl zlib -in backup.tar >> backup.ab
Doesn't work
scandiun said:
You can do it that way, you need dd and openssl. You can do it from linux, mac or windows with cygwin:
Code:
dd if=mybackup.ab bs=24 skip=1 | openssl zlib -d > mybackup.tar
Click to expand...
Click to collapse
Doesn't work for me. I get this error: openssl:Error: 'zlib' is an invalid command.
What did I do wrong? Do I need to update my openssl?
CyanogenLover said:
Doesn't work for me. I get this error: openssl:Error: 'zlib' is an invalid command.
What did I do wrong? Do I need to update my openssl?
Click to expand...
Click to collapse
Run
Code:
openssl list-cipher-commands
And see if zlib is at the bottom
Which operating system are you using?
Nope, zlib is missing. I'm using Ubuntu 14.04. What do I do now?
Are there any other methods to unpack an .ab file?
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - filename | gzip -d
Click to expand...
Click to collapse
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - /sdcard/backup.ab > /sdcard/backup2.ab
dd if=/sdcard/backup2.ab bs=24 skip=1 | busybox gzip -d > wa.tar
Click to expand...
Click to collapse
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
bu backup PACKAGE_NAME > /sdcard/backup.ab
dd if=/sdcard/backup.ab bs=24 skip=1 > /sdcard/backup2.ab
printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - /sdcard/backup2.ab | busybox gzip -d > /sdcard/backup.tar
Click to expand...
Click to collapse
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
gps3dx said:
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
Click to expand...
Click to collapse
Is root required?
---------- Post added at 03:38 PM ---------- Previous post was at 03:24 PM ----------
gps3dx said:
any chance we can deflate .ab file on the phone itself ?
I know that one can deflate zlib by adding zlib header to the data then pass it through gzip:
source: printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" | cat - body.zlib | gzip -dc
I even tried ( and failed, cause i'm getting 'corrupt data' error
is the .ab ( without encryption ) is compress in some special way such that this technique isn't working ?
EDIT - SUCCESS !!!!
although gzip throws an error of 'gzip: corrupted data' - the ".ab" file is deflated into .tar, so that running
Code:
tar xvf <TARFILE> <FULL_INTERNAL_FILE_PATH> -C <WHERE_TO_EXTRACT_FILE>
extract the file I want !!!
EUREKA !!!!
DON'T YOU GET IT !?!?!
NOW IT IS POSSIBLE TO MAKE BACKUP SCRIPTS FOR APPS ON THE DEVICE ITSELF FOR FREE!
Click to expand...
Click to collapse
Ok thanks but it probably requires root. Testing it in my Samsung S7 official stock ROM it generates a 0 bytes file. Note that not all apps allow adb backup, you have to perform backup only in those that allow it.
If I do "bu" on android terminal I get:
sh: resetreason: can't execute: Permission denied. Killed.
scandiun said:
Is root required?
Click to expand...
Click to collapse
bah... I think I gave my terminal emulator root perm, although I did not initiate any "su" command.
this gave some extra perm to the emulator...
so my answer is that root is required to run this command on the phone itself... but NO root is required is you run it through ADB from a PC.
so, yeah, no real special news here, but the fact that there is NO need to copy the backup to PC, because deflating zlib, tar extracting can be done on the phone itself.
which means in return, that NO special openSSL is needed to extract the WA key file.
gps3dx said:
bah... I think I gave my terminal emulator root perm, although I did not initiate any "su" command.
this gave some extra perm to the emulator...
so my answer is that root is required to run this command on the phone itself... but NO root is required is you run it through ADB from a PC.
so, yeah, no real special news here, but the fact that there is NO need to copy the backup to PC, because deflating zlib, tar extracting can be done on the phone itself.
which means in return, that NO special openSSL is needed to extract the WA key file.
Click to expand...
Click to collapse
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
scandiun said:
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
Click to expand...
Click to collapse
if you got root you don't need to use external backup, you have access directly to /data/data and can view/edit WA databases.
also, to backup WA's key, you MUST install old version of the app, then perform the "bu" backup.
( as OP's script does ).
scandiun said:
Having root I would prefer to use Titanium backup or similar. The problem with adb backup is that not all apps are allowed to be backed up. There's a flag in AndroidManifest.xml
Click to expand...
Click to collapse
Have a question, adb doesn't backup all kind of data, or doesn't backup all kind of apk?
I need some clarification please
Youms said:
Have a question, adb doesn't backup all kind of data, or doesn't backup all kind of apk?
I need some clarification please
Click to expand...
Click to collapse
It backups all apks provided that you use the -apk flag. For the data, it only backs up data for those applications that are allowed inside the manifest. with the app System Info for Android you can check the AndroidManifest of each app. Android does not tell you explicitly which apps will be backed up or not. iOS works much better, iTunes will backup all the data of your apps (the apps itself not, it have to be re-downloaded from the Apple Store, and if some app is removed from there you can't install it anymore).
Please, don't use dd bs=24, instead use dd ibs=24, which is a bit faster, but really fast is only
Code:
tail -c +25 backup.ab | zlib-flate -uncompress | tar -tf -

[Q]How to Unpack/Split Samsung boot.img ?

Maybe a noob question, but how do you guys split and repack SGS3 boot.img ?
The usual perl scripts don't seem to work with any S3 boot.img I came across (neither for the Galaxy Tab 7.7 boot.img's btw).
I keep getting this error :
Android Magic not found in boot.img. Giving Up.
Click to expand...
Click to collapse
Thanks for answering.
To unpack, you can do this:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Of course, that assumes you have abootimg installed. The above will split the zImage and the ramdisk from the boot.img and then proceed to extract the files from the ramdisk. Some ramdisks are not Gzip compressed so in that case use cat instead of zcat. Also: run that as root to make sure you don't mangle the files' permissions. I haven't tried repacking, though. ("find . -print | cpio -o -H newc | gzip > ../initrd.img" followed by "cd .. ; abootimg -u boot.img -r initrd.img" worked for my U8800pro, but I've had no need to try it with GS3 images.) I'd start by looking at the tools that come with the official Samsung source distribution and guides that tell you how to build a Samsung kernel.
Thanks a lot for this thorough answer
Trying this right now.
Couldn't find a specific Samsung kernel-related tutorial, though good idea to go take a look at Samsung's official kernel documentation.
qwerty12 said:
To unpack, you can do this:
Code:
abootimg -x boot.img && mkdir newramdisk && cd newramdisk && zcat ../initrd.img | cpio -i --no-absolute-filenames
Of course, that assumes you have abootimg installed. The above will split the zImage and the ramdisk from the boot.img and then proceed to extract the files from the ramdisk. Some ramdisks are not Gzip compressed so in that case use cat instead of zcat. Also: run that as root to make sure you don't mangle the files' permissions. I haven't tried repacking, though. ("find . -print | cpio -o -H newc | gzip > ../initrd.img" followed by "cd .. ; abootimg -u boot.img -r initrd.img" worked for my U8800pro, but I've had no need to try it with GS3 images.) I'd start by looking at the tools that come with the official Samsung source distribution and guides that tell you how to build a Samsung kernel.
Click to expand...
Click to collapse
Great!! Thanks for your information.
Here is what I use. Inside there are three binaries and two perl scripts,, copy the binaries into /usr/bin/ or you can add them in their own place and add that to the path. Then use this to help you use the files
Thanks for that too, ima try those scripts
Getting this error :
~$ perl unpack-bootimg.pl boot.img
could not find any embeded ramdisk images. Are you sure this is a full boot image?
Click to expand...
Click to collapse
Apparently, from what I have been reading, Samsung uses a different type of kernels than other manufacturers.
Although there's a huge number of custom samsung kernels out there. There might be a way^^
Here is the kernel i'm trying to edit if anyone wanna give a try at unpacking it for me.
That is true up until the S3 boot.img/kernel They have always used a zImage. Now Google has forced them to move over to EXT4 system and change the kernel format.
That file is only 2.88 mb's that is way too small to be a full kernel. Even for stock with no tweaks. That's why you are having an error.
This is the original boot.img from the CM9 for Galaxy Tab 7.7 update.zip
However i get the same error when trying to unpack S3 stock boot.img or even CM10 boot.img, although when i try the same scripts on my Xperia Play's kernels they unpack properly.
Good thing if Google made Samsung do kernels like others
Hi,
Did you manage to unpack/repack the SGS3 boot image? I'm trying to modify init.rc in an international SGS3 (i9300).
I've managed to unpack the boot image (from /dev/block/mmcblk0p5) as per qwerty12's command but how do I repack it?
Thanks!

[Dev][Tool][Script to]Make ODIN flashable Roms ext4 devices

Hey fellas!!!
This is my first real contribution to my xda friends .I happy to share with you guys the script to make ODIN flashable rom for ext4 devices.
First of all I would like to say that this script currently supports only International variants of sgs2,sgs3 and SG Note.This is because I own only Note (similar to s2) and my friend has s3 which I used to make s3 compatible.I can support any devices if you guys can give me the required data
So now into the topic
In order to work with the script,you need the following:
A PC/Laptop with linux installed either as dualboot or in vm
A rooted Phone which supported by the script.
A usb cable
And of course you need your brain
Apart from the hardware,you will also need:
A stock rom from which you need to take the following:
cache.img
modem.bin
hidden.img
and a custom kernel(zImage) of you choice.(recovery.img and boot.img in case of s3)
Now download the script and do the following:
Extract ODIN-script.tar anywhere.
Run first_time.sh (Needed Only for the first time)
Put the above collected .img's,.bin and/or zImage inside ODIN-script directory
Connect your phone to PC/Laptop with usb debugging enabled.
Run the script and follow the instructions
Your Rom will be in the same directory in few mins
Note1:The Rom obtained by the above is not a full wipe rom.If you need to make it full wipe(factory reset),you need aditional empty data.img(for note/s2) or userdata.img(s3).I will upload data.img for Note.It "may" work on s2 too.But I havent tested.so its on your own risk
S3 users,I'm sorry I can help you .Because I dont know the size of /data partition to make an empty image.
Note2:You can always flash the rom with .pit and repartition.I have always used .pit to flash my rom.But still you are at your own risk.
Disclaimer:Do this at your own risk!!!I'm not responsible if you brick your phone.(Though you cannot if you do everything correctly )
Download link and changelog on next post.
And finally if you like my project and if you think you need to support me for future updates on this,Please do donate .And do not copy/edit/alter this work without my permission!!!
Download Links and changelogs
Changelog for v1:
Code:
[LIST]
[*]Initial release
[/LIST];)
Changelog for v2:
Code:
[LIST]
[*]Cleaned the code and redone entirely
[*]Added support for preload for some devices
[*]bug fixes
[/LIST]
Thanks to:
1.As-I9000 for zlibs and first_time.sh
vijai2011 said:
Reserved
Click to expand...
Click to collapse
Reserved!!!
really awesome...going to try now and let you know the feedback...
Ok...Thats good...Just an update...Dont add cache.img for now...It takes forever in recovery to flash....Found the issue and working on a fix
vijai2011 said:
Ok...Thats good...Just an update...Dont add cache.img for now...It takes forever in recovery to flash....Found the issue and working on a fix
Click to expand...
Click to collapse
thank you and i was about to test and i will refrain from doing that till you release the fix!
grgsiocl said:
thank you and i was about to test and i will refrain from doing that till you release the fix!
Click to expand...
Click to collapse
Hey...You can try it without cache.img as long as you have csc within you /system
But still if you have added cache.img,it will boot but only with couple of reboots and a looooong time in recovery
vijai2011 said:
Hey fellas!!!
Note1:The Rom obtained by the above is not a full wipe rom.If you need to make it full wipe(factory reset),you need aditional empty data.img(for note/s2) or userdata.img(s3).I will upload data.img for Note.It "may" work on s2 too.But I havent tested.so its on your own risk
[/COLOR]
Click to expand...
Click to collapse
If you needed FULL WIPE DATA - FACTORY RESET, you need to put the image cache file with the command wipe data...
as i9000 said:
If you needed FULL WIPE DATA - FACTORY RESET, you need to put the image cache file with the command wipe data...
Click to expand...
Click to collapse
Nope...instead I have added a empty data.img It will wipe off data...But didn't make it for s3 because I have heard s3 has /data and /sdcard combined.So if I make one for s3,it will wipe sdcard too.But need a confirmation on this
And I have fixed recovery issue too in v2 and it should be fine now.
Finally had a look on your script too.It also looks good.good job.nice work .May be we two can work together to make a kitchen???
Sent from my GT-N7000 using xda app-developers app
I used your script as guiding for customizing my own odin rom.
- I untarred my firmware.tar.md5
- $ simg2img system.img.ext4 system.raw
- $ sudo mount -t ext4 -o loop system.raw /tmp
I didn't change a thing and then repacked it
- make_ext4fs -s -l 512M -a system newsystem.img.ext4 /tmp
- chown 1000:1000 newsystem.img.ext4
- packed everything with $tar -H ustar -cvf out.tar *.img.* fat.bin
- signed the package md5sum -t out.tar >> out.tar
- mv out.tar out.tar.md5
I flashed it, had no problems, but after the flashing i see "failed to mount /system (invalid argument)
And as my system partition doesn't get mounted, i cant startup my phone.
Does anyone have a clue on what i could be doing wrong?
1bymany said:
I used your script as guiding for customizing my own odin rom.
- I untarred my firmware.tar.md5
- $ simg2img system.img.ext4 system.raw
- $ sudo mount -t ext4 -o loop system.raw /tmp
I didn't change a thing and then repacked it
- make_ext4fs -s -l 512M -a system newsystem.img.ext4 /tmp
- chown 1000:1000 newsystem.img.ext4
- packed everything with $tar -H ustar -cvf out.tar *.img.* fat.bin
- signed the package md5sum -t out.tar >> out.tar
- mv out.tar out.tar.md5
I flashed it, had no problems, but after the flashing i see "failed to mount /system (invalid argument)
And as my system partition doesn't get mounted, i cant startup my phone.
Does anyone have a clue on what i could be doing wrong?
Click to expand...
Click to collapse
If you did exactly what you posted,then,
1. You should not have got system.img.ext4 but system.img and so simg2img is simg2img system.img system.img.ext
2./temp in mount command would be your temp filesystem where system files are stored.Use a relative path like TempDir in your PWD
3. Are you sure the make_ext4fs line is correct?You said you used my script as reference and I have never used that command at all.Its like:
Code:
sudo ./mkuserimg.sh -s TempDir factoryfs.img ext4 ./temp 893386752B
(in mb is also fine)
where the numbers indicate the size of system partition in Bytes.Be sure to cd to ext4_utils before executing this command and should always be run as sudo as the mount is done as sudo.And donot include .ext4 at the end.Use just img.Works better.
4.again...chown should be sudo.As the img is owned by root and so you cannot chown it with basic user permissions.Simple user hierarchy
5.You did a blunder here in tar command if you put the original system.img and the newly packed img in the same directory.As the command will include all .img's which we donot want.
vijai2011 said:
If you did exactly what you posted,then,
1. You should not have got system.img.ext4 but system.img and so simg2img is simg2img system.img system.img.ext
2./temp in mount command would be your temp filesystem where system files are stored.Use a relative path like TempDir in your PWD
3. Are you sure the make_ext4fs line is correct?You said you used my script as reference and I have never used that command at all.Its like:
Code:
sudo ./mkuserimg.sh -s TempDir factoryfs.img ext4 ./temp 893386752B
(in mb is also fine)
where the numbers indicate the size of system partition in Bytes.Be sure to cd to ext4_utils before executing this command and should always be run as sudo as the mount is done as sudo.And donot include .ext4 at the end.Use just img.Works better.
4.again...chown should be sudo.As the img is owned by root and so you cannot chown it with basic user permissions.Simple user hierarchy
5.You did a blunder here in tar command if you put the original system.img and the newly packed img in the same directory.As the command will include all .img's which we donot want.
Click to expand...
Click to collapse
First of all, thanks for the reply.
second:
1. My phone is not rooted yet, it's a GT-S6500D aka Samsung galaxy tab. So I used a firmware.tar.md5 (that i have flashed to test and works)
and in this firmware.tar.md5 i have following files: boot.img, cache.img.ext4, fat.bin, hidden.img.ext4, recovery.img and system.img.ext4
So the system.img.ext4 wasn't a typo and the system.raw is just an arbitrary name i have chosen.
2. I don't get the mountpoint. Is this the mountpoint on the phone? of on my computer?
3. I have analysed the mkuserimg.sh script, and it is just a wrapper that flips the argument order. I have no clue why they made it..
So i doubt my problem would be in this line, but I will try, as i don't know what else can go wrong
4. chown should indeed be sudo, no doubt about that I just didn't type it here
5. I skipped this step a bit in the explanation, but i made the sure the directory only concluded the necessary files, naming the original files from step 1 or modified files.
6. I don't know if this could help, but if i unpack for example system.img.ext4 and repack it again, the new file will be bigger then the original one.. I was thinking maybe Samsung adjusted some things, but maybe i need some more arguments in my make_ext4fs command..
grtz
Fixed it!
The problem was that i was using a size of 512M without knowing where it came from.
I flashed the original firmware back to the phone, did a
Code:
adb shell "df /system "
to know what size my img needed to be. In my case it was a total size of 492M. So i used following command to make my system.img.ext4
Code:
make_ext4fs -s -l 492M -a system system.img.ext4 /system
Now trying to pack my own kernel in the boot.img
thanks for the support!
1bymany said:
Fixed it!
The problem was that i was using a size of 512M without knowing where it came from.
I flashed the original firmware back to the phone, did a
Code:
adb shell "df /system "
to know what size my img needed to be. In my case it was a total size of 492M. So i used following command to make my system.img.ext4
Code:
make_ext4fs -s -l 492M -a system system.img.ext4 /system
Now trying to pack my own kernel in the boot.img
thanks for the support!
Click to expand...
Click to collapse
Sorry for the late response .got a little busy.Happy that you solved it .Just an hint,you can use -h to see the size better readable by humans(In M and G) in df command incase you find its in kb or B
Sent from my GT-N7000 using xda app-developers app
Updated to v2
vijai2011 said:
Updated to v2
Click to expand...
Click to collapse
thanks man

[Q] Custom ROM - extract boot.img

I have update.img from venor of my tablet. I would like to make a custom rom and later CyanogenMod. At this moment I need to extract boot.img form update.img
mkimage -l update.img displays:
mkimage: Bad Magic Number: "update.img" is no valid image
Image Type : Davinci UBL Boot Image
UBL magic : 57464b52
Entry Point: 00010066
nr of pages: 00000401
start block: 07dd0105
start page : 290e1201
Any idea?
You can download update.img from:
https://mega.co.nz/#!XFExEDBL!OkPfQwWDp0JDzRHIg4TZQk6lt3EwEJiDfR2IyOE6p_4
mafamafa said:
I have update.img from venor of my tablet. I would like to make a custom rom and later CyanogenMod. At this moment I need to extract boot.img form update.img
mkimage -l update.img displays:
mkimage: Bad Magic Number: "update.img" is no valid image
Image Type : Davinci UBL Boot Image
UBL magic : 57464b52
Entry Point: 00010066
nr of pages: 00000401
start block: 07dd0105
start page : 290e1201
Any idea?
You can download update.img from:
https://mega.co.nz/#!XFExEDBL!OkPfQwWDp0JDzRHIg4TZQk6lt3EwEJiDfR2IyOE6p_4
Click to expand...
Click to collapse
try using ext2explore...
ext2explore didn’t show anything
mr.harsh said:
try using ext2explore...
Click to expand...
Click to collapse
Unfortunately ext2explore didn’t show anything. Any idea? Maybe somebody download the file I posted I mega.co.nz and check it?
unmkbootimg doing the job for you
mafamafa said:
Unfortunately ext2explore didn’t show anything. Any idea? Maybe somebody download the file I posted I mega.co.nz and check it?
Click to expand...
Click to collapse
There is programm called unmkbootimg. type:
unmkbootimg boot.img
will create zImage and initramfs.cpio.gz files in current directory. scripts/extract-ikconfig will give you config from kernel.
kaptorali said:
There is programm called unmkbootimg. type:
unmkbootimg boot.img
will create zImage and initramfs.cpio.gz files in current directory. scripts/extract-ikconfig will give you config from kernel.
Click to expand...
Click to collapse
Shoud I run it on my Tablet? Shoud I install something on my tablet?
mafamafa said:
Shoud I run it on my Tablet? Shoud I install something on my tablet?
Click to expand...
Click to collapse
If you have unpacked ROM and got yourromfolder/RFSFAT16_BOOT_00000000000 then all you need
>unmkbootimg yourromfolder/RFSFAT16_BOOT_00000000000
To get boot.img from tablet: install Term(terminal) (to tablet), run terminal, type:
>su
>busybox dd if=/dev/block/nandc of=/mnt/sdcard/boot.img
Copy boot.img from /mnt/sdcard/ (or other directory) to "extsd", insert to PC and run unmkbootimg
From adb shell (linux style):
>./adb start-server
In tablet turn on "usb adb debugging". Plug tablet to PC with usb. Run:
>./adb shell busybox dd if=/dev/block/nandc of=/mnt/sdcard/boot.img
>./adb pull /mnt/sdcard/boot.img boot.img
Run unmkbootimg.
mkimage -l update.img gives you header (first 64bites) of your boot.img - all right.
Also unmkbootimg type output for building (packing) new_boot.img!
mafamafa said:
Any idea?
Click to expand...
Click to collapse
$ dd if=update.img skip=1 bs=13155412 of=boot.img
I've updated unmkbootimg so it handles embedded boot images now. Download it and run it directly on your update.img
$ unmkbootimg update.img
unmkbootimg version 1.2 - Mikael Q Kuisma <[email protected]>
File update.img not a plain boot image, seeking for embedded image ... found!
Kernel size 8073252
Kernel address 0x60408000
Ramdisk size 6380372
Ramdisk address 0x62000000
Secondary size 0
Secondary address 0x60f00000
Kernel tags address 0x60088000
Flash page size 16384
Board name is ""
Command line ""
*** WARNING ****
This image is built using NON-standard mkbootimg!
OFF_KERNEL_ADDR is 0x00380100
OFF_RAMDISK_ADDR is 0x01F78100
OFF_SECOND_ADDR is 0x00E78100
Please modify mkbootimg.c using the above values to build your image.
****************
Extracting kernel to file zImage ...
Extracting root filesystem to file initramfs.cpio.gz ...
All done.
---------------
To recompile this image, use:
mkbootimg --kernel zImage --ramdisk initramfs.cpio.gz --base 0x60087f00 --pagesize 16384 -o new_boot.img
---------------
$ ls
initramfs.cpio.gz update.img zImage
$
Click to expand...
Click to collapse

[Q] 1000 failures while trying to compile CM!

I'm tired of asking the same question again and again but for the thousandth and the last time I'll try my best to explain y'all the jeopardy I'm in.
I'm trying to build cm-10.2 from source for Sony Xperia E (nanhu) and everything started off just fine until I had to generate the skeleton files. I decided to use the mkvendor.sh to generate em. I have no clue why, but Sony seems to be in love with .elf files. And the best part, mkvendor only works with a standard boot.img file. Since I found mkvendor.sh the only convincing option, I decided to not use the other 2 options given here.
I extracted the kernel.sin from the ftf package of the kernel I downloaded, used flashtool to in turn extract kernel.sin which produced kernel.elf. I tried two things:
1) Unpack kernel.elf (flashtool elf extractor) and then pack em into a boot.img file (Failed as I couldn't pack em because I didn;t know how to use mkbootimg)
2) Rename kernel.elf to boot.img. as suggested by a developer of CM11 for Xperia E (Worked and was also accepted by mkvendor.sh)
I used mkvendor and it said that i don't have unpackbootimg binaries. I tried to make them by using:
make -j4 out/host/linux-x86/bin/unpackbootimg
Sadly I didn't know how to proceed so I got the binary from here and copied it to /usr/bin/ and made executable using:
sudo chmod a+x /usr/bin/unpackbootimg
Rebooted and it worked but you will see below that it isn't fixed 100% but it just works. I moved on and decided to use the script again on the renamed kernel.elf file(i.e. boot.img)
This is the following error I encounter while using mkvendor:
[email protected]:~/tools/FlashTool$ cd ~/source/cm/branch/cm-10.2
[email protected]:~/source/cm/branch/cm-10.2$ ./build/tools/device/mkvendor.sh sony nanhu ~/Desktop/boot.img
Arguments: sony nanhu /home/carbogen-chemist/Desktop/boot.img
Output will be in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu
*** Error in `unpackbootimg': free(): invalid next size (fast): 0x09793170 ***
./build/tools/device/mkvendor.sh: line 84: 3943 Aborted (core dumped) unpackbootimg -i $BOOTIMAGEFILE > /dev/null
gzip: ../boot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
cp: cannot stat ‘/tmp/carbogen-chemist/bootimg/boot.img-zImage’: No such file or directory
Creating initial git repository.
~/source/cm/branch/cm-10.2/device/sony/nanhu ~/source/cm/branch/cm-10.2
Initialized empty Git repository in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu/.git/
[master (root-commit) d49b660] mkvendor.sh: Initial commit of nanhu
7 files changed, 95 insertions(+)
create mode 100644 AndroidBoard.mk
create mode 100644 AndroidProducts.mk
create mode 100644 BoardConfig.mk
create mode 100644 cm.mk
create mode 100644 device_nanhu.mk
create mode 100644 recovery.fstab
create mode 100644 system.prop
~/source/cm/branch/cm-10.2
Done!
Use the following command to set up your build environment:
lunch cm_nanhu-eng
And use the follwowing command to build a recovery:
. build/tools/device/makerecoveries.sh cm_nanhu-eng
Since the script seems to look up for boot.img-ramdisk.gz and boot.img-zImage, I decided to investigate a bit further. I renamed boot.img to kernel.elf and used flashtool elf extractor to unzip kernel.elf. I obtained four files as a result of the extraction:
1) kernel.elf.bootcmd
2) kernel.elf.cert
3) kernel.elf.Image
4) kernel.elf.ramdisk.gz
Since mkvendor needed boot.img-ramdisk.gz and boot.img-zImage, I renamed all the files:
1) kernel.elf.bootcmd >> kernel.img-bootcmd
2) kernel.elf.cert >> kernel.img-cert
3) kernel.elf.Image >> kernel.img-zImage
4) kernel.elf.ramdisk.gz >> kernel.img-ramdisk.gz
Now I repackaged them using mkelf.py script. Since I couldn't find any command specific to nanhu, I edited it to fit for the device:
python mkelf.py -o edited.elf [email protected] [email protected],ramdisk [email protected],cmdline
This command throws no error and produces edited.elf. All of the files are packed in except kernel.img-cert as I didn't know the arguments for it ([email protected]?x????????,cert). I rename the edited.elf to boot2.img.
But I get the same error as the one I get when I use the unedited kernel (boot.img)
What should I do to get out of this format abyss? Would I have better luck with mkbootimg? If so, could you point me out to a thread or tell me here itself how to use it?
Thank you all!
TheUltimateNoobist said:
I used mkvendor and it said that i don't have unpackbootimg binaries. I tried to make them by using:
make -j4 out/host/linux-x86/bin/unpackbootimg
Sadly I didn't know how to proceed so I got the binary from here and copied it to /usr/bin/ and made executable using:
sudo chmod a+x /usr/bin/unpackbootimg
Rebooted and it worked but you will see below that it isn't fixed 100% but it just works. I moved on and decided to use the script again on the renamed kernel.elf file(i.e. boot.img)
Click to expand...
Click to collapse
Fixed it myself. How did I miss that note at cyanogenmod porting?
Cd'ed to my working directory. Ran :
sudo make -j4 otatools
and grabbed unpackbootimg from WORKING_DIR/out/host/linux-x86/bin/unpackbootimg and pasted to /usr/bin
Made it executable by running:
sudo chmod a+x /usr/bin/unpackbootimg
Reboot!
It would also be very helpful if anyone could point out what the correct config for Xperia E is. (For EG >> blue_mint_defconfig is for Xperia T, semc_zeus_defconfig is for Xperia Play)
There is a file called README_Xperia, which contains the configuration names for the different phones in the kernel source can be used for. But my source doesn't contain it. So I would be very grateful if someone pointed it out!
Thank you!
TheUltimateNoobist said:
I'm tired of asking the same question again and again but for the thousandth and the last time I'll try my best to explain y'all the jeopardy I'm in.
I'm trying to build cm-10.2 from source for Sony Xperia E (nanhu) and everything started off just fine until I had to generate the skeleton files. I decided to use the mkvendor.sh to generate em. I have no clue why, but Sony seems to be in love with .elf files. And the best part, mkvendor only works with a standard boot.img file. Since I found mkvendor.sh the only convincing option, I decided to not use the other 2 options given here.
I extracted the kernel.sin from the ftf package of the kernel I downloaded, used flashtool to in turn extract kernel.sin which produced kernel.elf. I tried two things:
1) Unpack kernel.elf (flashtool elf extractor) and then pack em into a boot.img file (Failed as I couldn't pack em because I didn;t know how to use mkbootimg)
2) Rename kernel.elf to boot.img. as suggested by a developer of CM11 for Xperia E (Worked and was also accepted by mkvendor.sh)
I used mkvendor and it said that i don't have unpackbootimg binaries. I tried to make them by using:
make -j4 out/host/linux-x86/bin/unpackbootimg
Sadly I didn't know how to proceed so I got the binary from here and copied it to /usr/bin/ and made executable using:
sudo chmod a+x /usr/bin/unpackbootimg
Rebooted and it worked but you will see below that it isn't fixed 100% but it just works. I moved on and decided to use the script again on the renamed kernel.elf file(i.e. boot.img)
This is the following error I encounter while using mkvendor:
[email protected]:~/tools/FlashTool$ cd ~/source/cm/branch/cm-10.2
[email protected]:~/source/cm/branch/cm-10.2$ ./build/tools/device/mkvendor.sh sony nanhu ~/Desktop/boot.img
Arguments: sony nanhu /home/carbogen-chemist/Desktop/boot.img
Output will be in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu
*** Error in `unpackbootimg': free(): invalid next size (fast): 0x09793170 ***
./build/tools/device/mkvendor.sh: line 84: 3943 Aborted (core dumped) unpackbootimg -i $BOOTIMAGEFILE > /dev/null
gzip: ../boot.img-ramdisk.gz: No such file or directory
cpio: premature end of archive
cp: cannot stat ‘/tmp/carbogen-chemist/bootimg/boot.img-zImage’: No such file or directory
Creating initial git repository.
~/source/cm/branch/cm-10.2/device/sony/nanhu ~/source/cm/branch/cm-10.2
Initialized empty Git repository in /home/carbogen-chemist/source/cm/branch/cm-10.2/device/sony/nanhu/.git/
[master (root-commit) d49b660] mkvendor.sh: Initial commit of nanhu
7 files changed, 95 insertions(+)
create mode 100644 AndroidBoard.mk
create mode 100644 AndroidProducts.mk
create mode 100644 BoardConfig.mk
create mode 100644 cm.mk
create mode 100644 device_nanhu.mk
create mode 100644 recovery.fstab
create mode 100644 system.prop
~/source/cm/branch/cm-10.2
Done!
Use the following command to set up your build environment:
lunch cm_nanhu-eng
And use the follwowing command to build a recovery:
. build/tools/device/makerecoveries.sh cm_nanhu-eng
Since the script seems to look up for boot.img-ramdisk.gz and boot.img-zImage, I decided to investigate a bit further. I renamed boot.img to kernel.elf and used flashtool elf extractor to unzip kernel.elf. I obtained four files as a result of the extraction:
1) kernel.elf.bootcmd
2) kernel.elf.cert
3) kernel.elf.Image
4) kernel.elf.ramdisk.gz
Since mkvendor needed boot.img-ramdisk.gz and boot.img-zImage, I renamed all the files:
1) kernel.elf.bootcmd >> kernel.img-bootcmd
2) kernel.elf.cert >> kernel.img-cert
3) kernel.elf.Image >> kernel.img-zImage
4) kernel.elf.ramdisk.gz >> kernel.img-ramdisk.gz
Now I repackaged them using mkelf.py script. Since I couldn't find any command specific to nanhu, I edited it to fit for the device:
python mkelf.py -o edited.elf [email protected] [email protected],ramdisk [email protected],cmdline
This command throws no error and produces edited.elf. All of the files are packed in except kernel.img-cert as I didn't know the arguments for it ([email protected]?x????????,cert). I rename the edited.elf to boot2.img.
But I get the same error as the one I get when I use the unedited kernel (boot.img)
What should I do to get out of this format abyss? Would I have better luck with mkbootimg? If so, could you point me out to a thread or tell me here itself how to use it?
Thank you all!
Click to expand...
Click to collapse
Nevermind :/ Fixed it myself.
Repacked the edited files using mkbootimg.
mkbootimg --kernel kernel.img-zImage --ramdisk kernel.img-ramdisk.gz --cmdline kernel.img-bootcmd -o boot.img

Categories

Resources