Help needed to unpack/repack Android boot.img & system.img - Android Q&A, Help & Troubleshooting

Hello
I am working with a Nanopi Fire3 board. I need to change the boot logo and boot animation.
With this Android Lollipop :
112.124.9.243/dvdfiles/S5P6818/images-for-eflasher/android-lollipop-images.tgz
Click to expand...
Click to collapse
If I unpack with the following method, the new image has a completely different size and does not boot.
Code:
apt install android-tools-fsutils
simg2img rootfs.img r.img
mount -t ext4 -o loop r.img /mnt
… To Change Something …
umount /mnt
img2simg r.img rootfs.img
I have tried to root the device, no tool found online works.
I have tried to unpack/repack, no tool found online works.
Tools like mkbootimg just copies the img file (it doesn't extract anything)
I am also trying to compile android completely, and it fails in the middle of the build process.
Would you have any advice please? I have run out of options
Thank you :good:

Related

[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] Mount Successful Changes Not

Hello
I have mounted system.img with linux the format i think it ext4 but the file is not sparse so i was successful using the following command.
sudo mount -t ext4 system.img ~/firmware2 -o loop
When the system image is mounted i have made some edits to the live image then i have unmounted the image and transferd the image back to my windows computer and ran the system.img through ext4 unpacker and extunpacker shows that my changes havent been made and and the file is the same as before however when i remount the system.img on my linux pc it shows the changes.
Im really stuck here and if anyone could help that would be great.
I am only new here but when i possible i will contribute and repay favours.
ps with the unmount i use visual unmount but have also tried unmounting with commands i used are umount /firmware2
re
I have sorted this issue now and managed to fix.

Manually patching system.img from Ubuntu linux

Hi, I open this thread because I mounted system.img (unpack it), maque some changes and repack it. Does not work, but the concept do (the rmxroot script I found in the web use this concept)
To do that I follow these steps:
1) Copy system.img to a folder in my ubuntu partition.
2) Make a backup.
3) Mount the system.img with:
sudo chmod 0644 system.img (giving permisions)
and
sudo mount -o loop,rw -t ext4 system.img tmp/
4) Make than changes (the rmxroot copi the su binaries and do other stuff)
The changes and adds can be made it graphically with nautilus.
5) Repack the system.img again with:
umount tmp
Please, if someone do something like that coment, so all can learn about.

What are different ways to make system level changes in android?

Requirements :
Need to change some system files
Install one application as system app
I know that above to requirements need rooted device, but device is not of well-known company so there is no support available from CWM, TWRP or any other.
Yet I've some how managed to get some tools and files to install android 5.1 from device manufacturer as below,
Intel's Platform Flash Tool
Also all necessary files such as recovery.img(stalk-read only permission), system.img etc.
Now what I've think of solution so far is to unpack and repack system.img and replace new system.img with existing one and install with Intel's Platform Flash Tool, XDA reference-1.
Unpack :
mkdir sys
./simg2img system.img sys.raw
sudo mount -t ext4 -o loop sys.raw sys/
Repack :
sudo ./make_ext4fs -s -l 512M -a system new.img sys/
sudo umount sys
rm -fr sys
also calculated size = "Block count" * "Block size", XDA reference-2
and after creating sucessully system.img and also installation is also complete with Intel's Platform Flash Tool, bur is not able to boot and stuck at loading screen.
Solutions that I can think of,
Is there something that I'm missing in above method of unpack/repack method of system.img?
I've Intel's Platform Flash Tool, so is there any way to put my changes during installation of android OS?
I've also recovery.img, is it possible to modify this and create custom recovery.img and give read and write permission to system files?
Are there any ohter solutions which meets my requirements?
Any help will be highly appreciated.

modifications in system.img ignored after flashing

Hi All,
I slightly modified system.img (details below), flash it, boot and none of my changes can be seen. It would be great if some expert could give me a hint on what I oversee here.
In detail: the device is a Sony XA2 and it was flashed successfully with AOSP Oreo 8.1 before. My approach worked on another mobile with 4.4 before, so I copied it.
What I've done: I unpacked the original system.img with simg2img, mounted it, modified a simple text file by adding a comment line (nothing crucial), pack it again with ext2simg and flash the new file. The commands were
> simg2img system.img system_unfold.img
> sudo mount -t ext4 -o loop system_unfold.img system
# modify...
> ext2simg -v system_unfold.img system_new.img
and then flashed it back via
> fastboot flash system system_new.img
Flashing worked in general, e.g. for AOSP Oreo 8.1. (also to slot A). Only the modified system_new.img does not lead to different files in /system
Any ideas?
Many Thanks!

Categories

Resources