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

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

Related

[GUIDE][U, SOLA, GO, P][ICS/JB][Unlocked BL] Enable Multi Boot Feature

Hello Guys,
This is my first thread in XDA and probably the most important one too. As the title says, I would like to introduce the awesome multiboot capabilities of Xperia U, Sola, Go, P developed by our favourite dev munjeni . Here is the original thread http://forum.xda-developers.com/showthread.php?t=2418241. Go there & give thanks to him for this awesome feature.
UPDATE: September 20, 2013
Made it to the Portal Homepage!!!!
Thanks all for your constant support for updating this thread and thanks to munjeni without whom this feature would've been just a dream
Portal Link: http://www.xda-developers.com/android/enable-multi-boot-on-the-xperia-u-sola-go/​
Click to expand...
Click to collapse
So, What is Multiboot ?
Ever got tired of flashing ROM again & again because of bootloop or to choose a good ROM?? Well news flash, now u don't have to. U can install multiple operating system in your ROM just like you do in your computer. Don't like the new ROM? Just switch your ROM to previous one with just a click. No flashing, wiping needed. The secondary ROM will be loaded from the sdcard partition.​
WARNING: Your warranty is already void. You will do this at your own risk. Me or XDA will take no responsibility if you brick your device while attempting to do these.
Requirements
ADB connection. Please check if you can connect adb in normal mode, recovery mode, fastboot mode. It's mandatory.
Rooted phone with unlocked bootloader
Any text editor except notepad, microsoft word or wordpad.
It is recommended to edit all files in PC with text editors and with unix/utf-8 format.
Brain & Brave heart
This is a step by step guide to enable multiboot intended for all users including noobs like me . The whole process is divided into several parts. First I'll guide you to boot your current rom (primary rom) through boot menu. Then I'll cover how to boot the second rom.
So, Let's Get Started !!!!
Booting Into Primary/Current ROM​
Part 1: Configure BootMenu Settings
So, the basic is this: when you power on your device, a menu will appear containing the list of ROMs' you have installed in your device. You browse it and select which ROM you want to boot. Then it'll be loaded. Pretty simple, eh ? But how will this menu figure out which ROM you have in your device? That's right, we have to define them.
Create a folder named "bootmenu" in your sdcard
Inside the folder, create a file named "settings.ini"
Now say you have stock JB 4.1.2 installed. So create a folder inside "bootmenu" named "StockJB". Also we have to create another folder "recovery" so that we have cwm recovery in Boot.
Don't use space while naming the folder. Otherwise bootmenu will show error at startup.
Now we have to edit the settings.ini file. Copy it to desktop and open it with text editor. Write these code....
Code:
[rom-1]
menutitle=Stock JB
kernel=/sdcard/bootmenu/StockJB/zImage
ramdisk=/sdcard/bootmenu/StockJB/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
[rom-2]
menutitle=CWM Touch Recovery
kernel=/sdcard/bootmenu/recovery/zImage
ramdisk=/sdcard/bootmenu/recovery/initrd.gz
cmdline=[COLOR="Red"]your_cmdline[/COLOR]
Let's explain these. "menutitle" is the name that'll appear in the menu when you power on the device. kernel, ramdisk, cmdline will be extracted from the boot.img that is provided with the ROM. More info about extracting them will be discussed later. You can see that in the kernel,ramdisk we have to set the path to the StockJB and recovery folder we created earlier. There are 2 rom settings for stock jb & recovery. If you want to have more ROM, you have to add another rom settings here. "cmdline" is kernel command line. You can find it when you extract boot.img or kernel.elf (see part 2). Open it with editor and copy-paste the whole text in your_cmdline. Now, ROM1 here will be the default rom i.e if you don't select any rom to load in 10 seconds, bootmenu will automatically load the ROM1 defined here :good:. After you're done editing simply overwrite the settings.ini with your new settings.ini in bootmenu folder. That's the end of first part. We'll come back to these folder again later.
Part 2: Extracting boot.img
Now we'll dive into more complex steps. We'll extract the kernel(zImage) and ramdisk(initrd.gz) from the boot.img that is provided with the rom.zip package. We'll need some tools to do that. Download the image_tools.rar from download section. Extract the files and copy them to your /system/bin folder. Make sure to give them permission 755 or rwx r-x r-x. Reboot your phone to apply the changes.
Now extract your current ROMs' boot.img and copy it to /data/local/tmp folder. Now connect your phone with pc, establish adb connection and follow the given code:
Code:
adb shell
su
cd /data/local/tmp
mkdir boot
kernel_dump ./boot boot.img
{
"lightbox_close": "Close",
"lightbox_next": "Next",
"lightbox_previous": "Previous",
"lightbox_error": "The requested content cannot be loaded. Please try again later.",
"lightbox_start_slideshow": "Start slideshow",
"lightbox_stop_slideshow": "Stop slideshow",
"lightbox_full_screen": "Full screen",
"lightbox_thumbnails": "Thumbnails",
"lightbox_download": "Download",
"lightbox_share": "Share",
"lightbox_zoom": "Zoom",
"lightbox_new_window": "New window",
"lightbox_toggle_sidebar": "Toggle sidebar"
}
this will dump kernel(zImage), ramdisk(initrd.gz) and cmdline to your /data/local/tmp/boot folder. For elf based kernel, just change the boot.img with kernel.elf.
Part 3: Ready the ROM For Booting
We will be using ramdisk(initrd.gz) only from the dumped folder since the kernel(zImage) inside it is not kexec patched!!! (If zImage is kexec patched, then use that one rather than from download section). Download the zImage, bootmenu, recovery ramdisk from download section. Extract it, you will find zImage inside it along with another initrd.gz and a modules folder. Copy both zImage & initrd.gz from the downloaded folder and paste it in /sdcard/bootmenu/recovery folder that you created earlier. Now copy the recently dumped initrd.gz from /data/local/tmp/boot to /sdcard/bootmenu/StockJB that you created. For zImage copy the appropriate one for ICS/JB from downloads and paste in here. The folder structure will look like these:
/sdcard/bootmenu
Stock_JB
initrd.gz (from /data/local/tmp/boot folder)
zImage (from downloads)
recovery
initrd.gz (from downloads)
zImage (from downloads)
settings.ini
Note: When custom kernel with kexec patch will be released, you will use zImage, initrd.gz from that kernel.
We're nearly there. Only two thing remains. Since we'll use munjenis' JB kernel(zImage) or DevSwift1s' ICS kernel we need to flash the proper module for that kernel. Otherwise wifi & other module will not work. So copy the modules from modules folder and paste it in /system/lib/modules folder. Give them permission 644 or rw- r-- r--. Now you have to flash the boot_menu.img to get the menu at startup. That's simple, download the boot_menu.img from download section and flash it by fastboot.
That's it!!! Your current ROM (primary rom) is ready for booting. Reboot your device and you'll enter bootmenu. You'll find options for your Stock JB and CWM Touch Recovery. Simply select your rom and you'll boot into your Primary ROM :laugh::laugh:. Your bootmenu will look like these except you'll have Stock JB option (I'm using SlimBean & CM 10.1 ).
Downloads
Xperia U (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage. modules, recovery ramdisk -> View attachment cwm.rar
3) bootmenu -> View attachment boot_menu.img
Click to expand...
Click to collapse
Xperia Sola (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) zImage, modules, recovery ramdisk, bootmenu
Click to expand...
Click to collapse
Xperia Go (JB)​1) packing, unpacking ->View attachment image_tools.rar
2) bootmenu
3) zImage, modules, recovery ramdisk
Click to expand...
Click to collapse
Xperia P ​Download from this thread http://forum.xda-developers.com/xperia-u/p-development/-t2647623
Click to expand...
Click to collapse
Xperia U, Sola, Go (ICS)​1) packing, unpacking -> same as JB
2) zImage. modules, -> here
3) recovery ramdisk, bootmenu -> same as JB
Click to expand...
Click to collapse
Customized Bootmenu, Recovery​http://forum.xda-developers.com/showpost.php?p=45733631&postcount=349
Click to expand...
Click to collapse
​::Credits::​
@munjeni bro for this awesome feature in our awesome device. ALL HAIL MUNJENI
@DevSwift1 for providing ICS kexec patched kernel
@percy_g2 for his work on Xperia P
Me, for writing this guide
Welcome to the second part of this guide . Here I'll cover how to create partitions in sdcard and from them how to boot the second ROM. Things that you need to know before doing this:
First if you do these, I'm assuming you've succeeded in booting into primary ROM. If not, please don't do this.
You need to have some space in your sdcard (depends on your rom size).
You can't use CWM Touch Recovery (created earlier) in your second ROM. You have to use its' own recovery. But its' recovery also won't work without modification. It'll be discussed in part2.
You can't flash ROM.zip normally on second ROM. For that you have to modify your updater-script a little bit. It'll be discussed in part 3.
Getting worried? Well, don't be. It's easy if you follow the steps thoroughly :fingers-crossed:
Let's get started!!!
Booting Into Second ROM
From Internal Storage​
Part 1: Creating Partition in SDCARD
We have to create three separate partition. One for system, one for data & last one for cache since your current roms' data, system, cache won't match with your second rom. Now say you want CM 10.1 as your second rom. It's size is around ~175MB. After unzipped it is ~290MB and with gapps it becomes ~450MB. So we'll create around 600~650MB sized system partition. Always create system with more space otherwise android will fail to boot.
Enough talk. Let's jump into action. Connect your phone, establish ADB connection do as the following:
Code:
adb shell
su
df
this'll show all your mounted partitions and their status. See that system is mounted at /dev/block/mmcblk0p10, data is mounted in /dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12 (see screenshot). We need to remember this for future use.
Now to create all partitions do as following after reading the explanation below:
Code:
[B][CENTER]##### for system partition only ([COLOR="red"]Updated[/COLOR]) #####[/CENTER][/B]
[COLOR="Red"]dd if=/dev/zero of=/sdcard/your_desired_folder/system.ext4 bs=4096 count=(your desired size)[/COLOR]
###### wait till the partitions is created ######
[COLOR="Red"]losetup /dev/block/loop1 /sdcard/your_desired_folder/system.ext4
blkid /dev/block/mmcblk0p10 ([COLOR="blue"]this'll give you a UUID[/COLOR])
mke2fs -T ext4 -O has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize -U ([COLOR="Blue"]paste here your UUID[/COLOR]) -I 256 /dev/block/loop1
losetup -d /dev/block/loop1[/COLOR]
[B][CENTER]##### for data,cache partition #####[/CENTER][/B]
dd if=/dev/zero of=/sdcard/your_desired_folder/data.ext4 bs=4096 count=[COLOR="Blue"][B]76800[/B][/COLOR]
###### wait till the partitions is created ######
dd if=/dev/zero of=/sdcard/your_desired_folder/cache.ext4 bs=4096 count=(your desired size)
###### wait till the partitions is created ######
Ok, let's explain these. "dd" comand will create partition based on the parameter given by you. So in these case partition will be created from /dev/zero to /sdcard/your_folder. Be careful, don't switch "if" with "of" and "of" with "if", it may brick your device. Notice that there are some other parameters. "bs" is the blocksize of your new partition and it's default value is 4096KB(4MB). Don't change it. Let's say you want to create data partition with size of 300MB (cause you don't use many apps). So 300/4(block size) = 75 and 75*1024 = 76800. That's the "count" parameter. So modify system, data, cache size according to your needs but make sure that you have enough space to create your desired partition. "losetup" basically sets up the loop so that you can mount your partition into that loop.
Update: You can now create system partition with exact amount of size instead of cloning them ( big thanks to munjeni again ). Before, creating specific sized system partition caused bootloop cause it was missing an unique identifier (UUID). Now it has been fixed (marked with red code).
Now comes more complex steps. You need to make sure to avoid any partition corruption and check for errors. Reboot your phone to bootmenu and press any key to avoid auto restart. Keep the device in boot menu. Now again check your adb connection and do these:
Code:
adb shell
losetup /dev/block/loop1 /sdcard/your_folder/system.ext4
losetup /dev/block/loop2 /sdcard/your_folder/data.ext4
losetup /dev/block/loop3 /sdcard/your_folder/cache.ext4
##### To pack/unpack ext4 #####
make_ext4fs /dev/block/loop1
make_ext4fs /dev/block/loop2
make_ext4fs /dev/block/loop3
##### To check for error #####
e2fsck -f -y /dev/block/loop1
e2fsck -f -y /dev/block/loop2
e2fsck -f -y /dev/block/loop3
##### for tuning and cleaning up ([COLOR="red"]just loop2 & loop3[/COLOR]) #####
tune2fs -o journal_data_writeback /dev/block/loop2
tune2fs -o journal_data_writeback /dev/block/loop3
##### unmount loop and sdcard #####
losetup -d /dev/block/loop1
losetup -d /dev/block/loop2
losetup -d /dev/block/loop3
umount /sdcard
##### reboot #####
exit
adb reboot
That's it!!!! Your new partitions are now ready for booting. :laugh::laugh:
Part 2: Modifying Second ROMs' Ramdisk
So while booting into primary rom, we simply put the ramdisk in /sdcard/bootmenu/StockJB without modifying it. Why do we need to modify it for second rom? Well unless modified, all your recoveries will recognize only your primary rom. So If you flash a rom thinking that it'll be installed in second rom, you'll see it got installed in your primary rom!!! So we'll modify the second roms' recovery so that it can use second rom while cwm touch recovery will use primary rom. Two recoveries for two roms
First, extract boot.img from your second roms' zip file and place it in /data/local/tmp folder (if any boot.img or boot folder is present there just delete it). Then extract the boot.img the same way as discussed in 1st post (part2). Then you'll have boot folder in /data/local/tmp. After that do as following:
Code:
cd /data/local/tmp/boot
mkdir ramdisk
cd ramdisk
gunzip < ../initrd.gz | cpio -i -d
this'll extract ramdisk(initrd.gz) in the ramdisk folder inside boot folder. copy this ramdisk folder in your desktop. Inside there are many files. We only need to modify some of them. Ok, change these files in the following area:
For JB Ramdisk​
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
fstab.st-ericsson
# Android fstab file.
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
/dev/block/mmcblk0p6 /modemfs ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop1 /system ext4 ro wait
/dev/block/loop2 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
/dev/block/loop3 /cache ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check
Click to expand...
Click to collapse
recovery.fstab
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat /dev/block/mmcblk0p14
/external_sd vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1
Click to expand...
Click to collapse
init.st-ericsson.rc
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
setprop ro.crypto.state unsupported
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw wait
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
exec /sbin/e2fsck -y /dev/block/loop2
mount_all fstab.st-ericsson
# SEMC: Start the TrimArea Daemon and early TA-users
Click to expand...
Click to collapse
For ICS Ramdisk​
fstab (if doesn't exist, ignore it)
# These declarations must match the mount statements in
# <buildroot>/device/semc/riogrande/files/init.riogrande.rc
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/modemfs ext4 /dev/block/mmcblk0p6
Click to expand...
Click to collapse
init.rc
find line "mkdir /system" and add line: "mkdir /sde" before line mkdir /system"
Click to expand...
Click to collapse
recovery.fstab
# mount point fstype device [device2] fstype2
/boot emmc /dev/null
/system ext4 /dev/block/loop1
/data ext4 /dev/block/loop2
/cache ext4 /dev/block/loop3
/sdcard vfat /dev/block/mmcblk0p14
#/sd-ext ext4 /dev/block/mmcblk0p2
/emmc vfat /dev/block/mmcblk1p1 /dev/block/mmcblk1
Click to expand...
Click to collapse
init.st-ericsson.rc (red lines are modified & blue lines are new)
on fs
# If you change anything here, make sure to update
# <root>/vendor/semc/system/bootstrap/masterreset/fstab.riogrande
# accordingly.
# Wait for eMMC device to become available
wait /dev/block/mmcblk0p14
mkdir /sde
mount vfat /dev/block/mmcblk0p14 /sde rw
exec /sbin/losetup /dev/block/loop1 /sde/your_folder/system.ext4
exec /sbin/losetup /dev/block/loop2 /sde/your_folder/data.ext4
exec /sbin/losetup /dev/block/loop3 /sde/your_folder/cache.ext4
# Mount system partition
mount ext4 /dev/block/loop1 /system ro
# Mount user data partition
exec /system/bin/logwrapper /system/bin/e2fsck -y /dev/block/loop2
setprop ro.crypto.state unsupported
mount ext4 /dev/block/loop2 /data nosuid nodev noatime noauto_da_alloc
# Mount cache partition
mount ext4 /dev/block/loop3 /cache nosuid nodev noatime
mount ext4 /dev/block/mmcblk0p6 /modemfs nosuid nodev noatime
# FOTA must be started after partitions are mounted
# and property service is initialized
exec /sbin/fota-ua c
Click to expand...
Click to collapse
That's it. You're done editing. Now save & copy these modified files to your /data/local/tmp/boot/ramdisk folder. Then in cmd do as the following:
Code:
cd /data/local/tmp/boot
mkbootfs ./ramdisk | gzip > initrd.gz
this'll repack the ramdisk folder into initrd.gz and save it in /data/local/tmp/boot folder. Make a new folder in your /sdcard/bootmenu for the new rom and copy this initrd.gz to that folder. Also copy the appropriate zImage for ICS/JB and paste it here. Add a new rom settings in settings.ini for this rom. Now you've your ramdisk ready and modified for flashing zips in second rom .
Part 3: Finishing Touch
We're at the end of this long road. You just have to modify your "rom.zip"s updater-script so that it flashes the rom in your newly created partition. Extract your updater-script, open it with editor. Remember that we saw system is in /dev/block/mmcblk0p10, data in /dev/block/mmcblk0p11, cache in /dev/block/mmcblk0p12. Find all the lines that start with "format" or "mount" (example format("ext4", "EMMC", "/dev/block/mmcblk0p10", "0")) and replace the /dev/block/mmcblk0p10 with /dev/block/loop1, /dev/block/mmcblk0p11 with /dev/block/loop2 and /dev/block/mmcblk0p12 with /dev/block/loop3. Also remove the function that flashes the kernel. It's usually at the end of the script. Just search for kernel.elf or boot.img and delete that function. Save the updater-script and push it into the zip with winrar. Choose compression "store".
NOTE: If you forget to remove the kernel function then don't worry. It just removes your bootmenu when you flash the second rom. Just power off the device after flashing and flash boot_menu.img again by fastboot.
Now reboot to bootmenu, your second roms' title that you defined in settings.ini will appear here. Select it, then phone will restart and load your second rom. Press vol. down repeatedly to enter its' recovery. From there flash your second rom. Reboot again to bootmenu and select second rom again. Now you'll see second ROM BOOTING !!!!!!! :good::good:
Hope it is clear to all of you. I tried my best to explain everything. If you need help, feel free to post. Also if you like my guide, give it a 5 star and press thanks to appreciate my work
================== THE END ==================​
F.A.Q​
1. Will this work on GB,ICS ?
Ans: Now Working For ICS based ROM too. See this post for kexec patched kernels ICS kernel with kexec support
For GB, you have to wait for kernel.
2. How can I remove the second ROM ?
Ans: Make sure you are in primary ROM, then just delete the 3 partitions from sdcard.
3. Can't unmount sdcard: device or resource busy
Ans: Type fuser -km /sdcard. It'll kill all the process that's keeping your sdcard busy. Then unmount sdcard.
4. Getting status 7 error ?
Ans: Delete assert function from updater-script.
5. Wifi's not working even after flashing modules from attachment ?
Ans: Unpack initrd.gz and see if there's a lib/modules folder inside it. If it exists and deep inside there are 2 modules, then you need to replace them with the ones from attachment.
6.Getting status 6 error no matter what ?
Ans: Always edit files in unix/utf-8 format and use compression method store to push files in zip. NEVER USE DOS FORMAT.
7.Getting "somthing went wrong. please see log!" in bootmenu ?
Ans: You have done something wrong in settings.ini or folder naming. Check again.
Very good tut. Men !
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
JohnLouise said:
Very good tut. Men !
Click to expand...
Click to collapse
thnx
mohammadagha said:
Nice Bro,
So we don't need system.ext4, data.ext4 and cache.ext4 in sdcard?
I think this thread belong to Xperia U develompent section.
Click to expand...
Click to collapse
Yes we'll need them for second ROM. I'll upload guides for them soon
If it belongs to dev section, pls can someone tell the moderator to move it ?
Nice
You are the best :good::laugh:
Good start!
very nice tutorial
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
NoobCoder said:
I'll upload soon guides for booting into second ROM. Pls be patient
Click to expand...
Click to collapse
Thanks for this bro.... waiting for other part..... :cheers:
Anthrax said:
Thanks for this bro.... waiting for other part..... :cheers:
Click to expand...
Click to collapse
cmdline in setting.ini belongs to Xperia U, You can find it for sola, Just open kernel.elf for sola with notepad, You can find it at the end of notes.
mohammadagha said:
@NoobCoder How the hell did u take screenshot in bootmenu recovery bro? :laugh:
Delete this thread fast and make new one in Development section because if u wait for Moderators and they say u can not move thread, Many pepole will lost this good thread.:good:
Click to expand...
Click to collapse
By DDMS . Also I reported this thread to move into the dev section, but moderator said this is the right section. Anyway to all users, please report this thread to make it sticky/pinned so that no one have any problems finding it
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
can u post same for Xperia P
dd98 said:
in step 2 i got this error in cmd:
Using existing folder ./boot
dd: can't open 'boot.img': No such file or directory
FAILURE to dump boot.img to ./boot! Pllease try another folder!
I know what kernel i'm using so can i just extract it with winrar
Click to expand...
Click to collapse
No, boot.img can't be extracted with winrar. you copied the boot.img to /data/local/tmp, right ? Please provide a screenshot if this doesn't help you.
Aamirx12 said:
can u post same for Xperia P
Click to expand...
Click to collapse
Sorry bro, munjeni stopped P's development. So I can't do it
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
cpkunki said:
Thanks mate! I was waiting for this for a long time. It ws actually ment for go and sola, but ultimately, munjeni ended up with developing it for U
Thanks to him too!
One more question.
What exactly i have to do to make this for sola?
Sorry to bother you..
Sent from my MT27i using xda app-developers app
Click to expand...
Click to collapse
Guess we're the lucky ones . Also there were many user who tried to test. That encouraged munjeni bro to keep the thread updated.
I'll check files uploaded by munjeni to get an idea how to do it in sola. But I think he mentioned it in post 4 in sola section. Check that and follow this guide. I'm sure you'll be able to do it
Can't umount
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
cesanaboia said:
When I write umount /sdcard (final step) the CMD say me: can't umount /storage/sdcard0: Device or resource busy.
But I have 1.2 gb free space in the SD. Why?
Click to expand...
Click to collapse
That's strange. It didn't occur to me. You have 1.2GB free after creating all partition or before? If before, then you have to free more space. If it doesn't help, pls post a screenshot. Also don't create partitions yet. I'll update the post with new code.
Sent from my Xperia U using Tapatalk 2

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.

Advice : Porting Indian ROM to Chinese ROM on Samsung Galaxy A8 8000 Model (China)

hi
I purchased a Samsung Galaxy A8 A8000 from China. I did not like its ROM since it lacked Google Apps and other stuff. So i decided to port system apps (apps+priv-app) from an indian rom. I am totall new to ROM stuff and to linux as well but i decided to go with virtual box and learn few things along the way.
For this,
first i extracted indian rom, it contained following
boot.img, cache.img, hidden.img, modem.bin, recovery.img, sboot.bin and system.img
then i extracted chinese rom, it contained different files as below
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
Since i donot want to mess with partitions and modem and other stuff so i decided to port only apps from indian rom and built an odin flashable tar file
For this i navigated various forum, i even dont exactly remember all but i am thankful to all who wrote useful stuff that helped me decide what to do, well most important of these were
http://forum.xda-developers.com/showthread.php?t=1974014
http://forum.xda-developers.com/showthread.php?t=1941239
http://rwilco12.com/forum/showthread.php?tid=92
first of all i converted indian rom system.img to system.raw using following command in linux virtualbox ubuntu 15.04
simg2img indsystem.img indsystem.raw
then i mounted this raw image using this command
mkdir indsystem
mount -o loop indsystem.raw indsystem/
then i converted chinese rom system.img to system.raw using same command as above
simg2img chcsystem.img chcsystem.raw
then i mounted this chinese raw image using this command
mkdir chcsystem
mount -o loop chcsystem.raw chcsystem/
then i created a system_new.img.ext4 file of 3.1GB size with this command
dd if=/dev/zero of=system_new.img.ext4 bs=4k count=775000
then i formated new image with ext4
mkfs.ext4 system_new.img.ext4
then probably i override the file system check and then mounted new ext4 image
tune2fs -c0 -i0 system_new.img.ext4
mkdir system_new
mount -o loop system_new.img.ext4 system_new
here i had a problem, i could not copy files from both indian and raw mounted images to my new ext4 image since i did not have permission to copy to the destination folder. then i made use of superuser access
gksu nautilus /path/to/image/folder
then i had full access and copied chinese rom to my new ext4 image.
cp -v -r -p chcsystem/* system_new/
then i deleted app, priv-app, font, framework, media, etc/permissions/allfiles-starting-with-android.-and-com.-and-allshare_library.xml from ext4 image.
then i manually copied these folders and permission files from indian system raw image file to my new ext4 image file
next i copy /system/lib/libandroid_runtime.so from chinese rom to the system/lib/ directory of indian rom and then deleted lib folder from chinese rom and replaced it with indian rom
then i sync files with "sync" command
then unmounted all partitions.
I then replaced system.img.ext4 file in my original rom with one that i have just made.
Now i need to compile these files back into flashable tar files with md5sum check with
tar -H ustar -c image_1 image_2 > your_odin_package.tar
md5sum -t your_odin_package.tar >> your_odin_package.tar
mv your_odin_package.tar your_odin_package.tar.md5
1. but before i do so I need some advance developer to please help me out and give some confidence as to the approach that i have used. is that correct.
2. Secondly, if someone can tell me tar ball flashing order for my rom since i heard it is important while compiling odin flashable tar file.
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
3. Also Is it possible that i convert system.img.ext4 into flashable odin tar file with above commands and flash only system image with Odin without messing with anyother settings.
Thank you
No one would like to help me out here.
Hi. I plan to do the same for my SM-A7000. did you get your to work?
waqasjeral said:
hi
I purchased a Samsung Galaxy A8 A8000 from China. I did not like its ROM since it lacked Google Apps and other stuff. So i decided to port system apps (apps+priv-app) from an indian rom. I am totall new to ROM stuff and to linux as well but i decided to go with virtual box and learn few things along the way.
For this,
first i extracted indian rom, it contained following
boot.img, cache.img, hidden.img, modem.bin, recovery.img, sboot.bin and system.img
then i extracted chinese rom, it contained different files as below
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
Since i donot want to mess with partitions and modem and other stuff so i decided to port only apps from indian rom and built an odin flashable tar file
For this i navigated various forum, i even dont exactly remember all but i am thankful to all who wrote useful stuff that helped me decide what to do, well most important of these were
http://forum.xda-developers.com/showthread.php?t=1974014
http://forum.xda-developers.com/showthread.php?t=1941239
http://rwilco12.com/forum/showthread.php?tid=92
first of all i converted indian rom system.img to system.raw using following command in linux virtualbox ubuntu 15.04
simg2img indsystem.img indsystem.raw
then i mounted this raw image using this command
mkdir indsystem
mount -o loop indsystem.raw indsystem/
then i converted chinese rom system.img to system.raw using same command as above
simg2img chcsystem.img chcsystem.raw
then i mounted this chinese raw image using this command
mkdir chcsystem
mount -o loop chcsystem.raw chcsystem/
then i created a system_new.img.ext4 file of 3.1GB size with this command
dd if=/dev/zero of=system_new.img.ext4 bs=4k count=775000
then i formated new image with ext4
mkfs.ext4 system_new.img.ext4
then probably i override the file system check and then mounted new ext4 image
tune2fs -c0 -i0 system_new.img.ext4
mkdir system_new
mount -o loop system_new.img.ext4 system_new
here i had a problem, i could not copy files from both indian and raw mounted images to my new ext4 image since i did not have permission to copy to the destination folder. then i made use of superuser access
gksu nautilus /path/to/image/folder
then i had full access and copied chinese rom to my new ext4 image.
cp -v -r -p chcsystem/* system_new/
then i deleted app, priv-app, font, framework, media, etc/permissions/allfiles-starting-with-android.-and-com.-and-allshare_library.xml from ext4 image.
then i manually copied these folders and permission files from indian system raw image file to my new ext4 image file
next i copy /system/lib/libandroid_runtime.so from chinese rom to the system/lib/ directory of indian rom and then deleted lib folder from chinese rom and replaced it with indian rom
then i sync files with "sync" command
then unmounted all partitions.
I then replaced system.img.ext4 file in my original rom with one that i have just made.
Now i need to compile these files back into flashable tar files with md5sum check with
tar -H ustar -c image_1 image_2 > your_odin_package.tar
md5sum -t your_odin_package.tar >> your_odin_package.tar
mv your_odin_package.tar your_odin_package.tar.md5
1. but before i do so I need some advance developer to please help me out and give some confidence as to the approach that i have used. is that correct.
2. Secondly, if someone can tell me tar ball flashing order for my rom since i heard it is important while compiling odin flashable tar file.
aboot.mbn, boot.img, cache.img.ext4, hyp.mbn, modem.bin, NON-HLOS.bin, recovery.img, rpm.mbn, sbl1.mbn, sec.dat, system.img.ext4 and tz.mbn
3. Also Is it possible that i convert system.img.ext4 into flashable odin tar file with above commands and flash only system image with Odin without messing with anyother settings.
Thank you
Click to expand...
Click to collapse
Hi waqasjeral. Have you already ported the Indian rom to the a8000?

Help needed to unpack/repack Android boot.img & system.img

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:

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