Flashtools (MiFlash4Linux, Recovery from QDL/DLOAD, Partition resize)

Search This thread

m11kkaa

Recognized Dev / Inactive Recognized Contributor
Jan 20, 2011
1,259
2,147
Introduction
This is a collection of Tools and Resources for Flashing Mi2(s)(c).

MiFlash4Linux
https://github.com/M1cha/aries-image-builder

Core Recovery Package for MiFlash
This is a small package to Recovery MI2 from any bricked state. It has the following advantages over the official ones from Xiaomi:
  • They don't flash any ROM, just the core system(bootloaders, modem and recovery)
  • They are small which means both Download and Installation are faster
  • It directly installs custom Bootloader and TWRP. That means you easily get your device back to a modded status.
Please follow the official MiFlash guidelines for installation with the following differences:
  • the DLOAD config is called rawprogram_core.xml
  • the fastboot script is called flash_core.bat(or flash_core.sh for linux)
  • there's a script called flash_partition_table_and_core which is a alternative to flash_core.bat/sh.
    It can be used to change the partition table.
    USE THIS WITH THE CUSTOM BOOTLOADER INSTALLED BY ONE OF THE CORE PACKAGES ONLY. Xiaomi's bootloader will format your whole MMC device. THIS WOULD ERASE YOUR EFS AND YOU CAN'T MAKE CALLS ANYMORE

Changing the partition table
There are multiple packages available:
separated: Xiaomi's original layout with a virtual internal sdcard
separated_single: same as separated but without Dualsystem and bigger system partitions
unified: Xiaomi's new layout with /data/media support
unified_single: same as unified but without Dualsystem and bigger system partitions
unified_single_xiaomi: Xiaomi's version of unified_single

aries_core_unified_single.zip -> only MIUI > 5.4.x or M1cha's CM12.1 or latest AOSP5 works (only they can see Internal Storage, that now is a virtual sd-card in /data/media/0)

aries_separated_single.zip -> other roms

Installation:
  • Backup all your data(including internal sdcard, and EFS just to be safe)
  • if you don't use the custom Bootloader yet, flash this package using flash_core.bat/sh first. See the big red warning above for more information
  • flash the package using flash_partition_table_and_core.bat/sh
  • boot into recovery(which is TWRP now), recreate the filesystems for all partitions(system,data,cache,sdcard to ext4) in the wipe menu and reinstall your ROM.

Version Information
Bootloader: https://github.com/M1cha/mi2_lk/commits/LA.AF.1.1-02810-8064.0
TWRP: v2.8.7.0
core partitions: aries_images_5.7.16_20150626.0000.4_5.0_cn_a63cddccfa.tgz

Download links for Mobile users:
aries_core_unified_single_xiaomi.zip
aries_core_unified_single.zip
aries_core_unified.zip
aries_core_separated_single.zip
aries_core_separated.zip

XDA:DevDB Information
Flashtools, Tool/Utility for the Xiaomi Mi 2

Contributors
m11kkaa
Source Code: https://github.com/M1cha/aries-image-builder


Version Information
Status: Stable

Created 2015-02-21
Last Updated 2015-07-27
 

Attachments

  • screen.png
    screen.png
    9.3 KB · Views: 12,039
Last edited:

m11kkaa

Recognized Dev / Inactive Recognized Contributor
Jan 20, 2011
1,259
2,147
the singleboot packages causes the latest version of CM12 to fail booting because of SELinux enforcing. I'll upload a fixed package asap.
 
Last edited:

m11kkaa

Recognized Dev / Inactive Recognized Contributor
Jan 20, 2011
1,259
2,147
everything has been fixed and is up again.
Pls download everything again(especially MiFlash4Linux if u use that).
 

MyNameIsKappa

Senior Member
Jan 10, 2012
154
16
Siena
the purpose of this thread is not G4A :)
G4A doesn't allow u to change the partition table. I may publish a simple tool for it though.(so u don't need a computer).

Hey m11kkaa, I'm sorry for the noob question, but where can I download the files for windows? And how should I use them? I can't understand from the OP. Thanks in advantage for your help
 

ancics

Member
Mar 8, 2010
7
0
Florianópolis
Hey M1cha, thank you! Great job!
I have some issues about the procedure:
1. I am not sure if already had a custom bootloader, so first i'll flash the package flash_core.bat :
- turn on mi2s in fastboot mode
- plug usb, device should appear in miflash(the program should be configured as the photo?)
- and click flash
- reboot phone, enter in fastboot mode again and do the same procedure with flash_partition_table_and_core.bat

Is that right?
It's easy to recreate the ext4 filesystem in TWRP? always used CWM....
 

Attachments

  • miflash.png
    miflash.png
    16.2 KB · Views: 1,446
Last edited:

cogano

Senior Member
Mar 9, 2009
154
83
@m11kkaa: thnx for the linux tools/scripts, it made my migration from CWM to single-system partition + new bootloader + TWRP easier.

BTW, I just wanted to migrate and keep my current CM11 for the time being. I had to fight a bit with restore from backup because I was not aware of the incompatibility between CWM and TWRP, luckily enough it eventually was sufficient to:
  1. reformat system, data and cache in TWRP
  2. flash the old CWM temporarily and restore boot, system and data
  3. flash TWRP again and make new backups.
Proposal:
  • It would be good if you can change the heading style of "Installation" in the OP to be the same as e.g "Introduction", because now it looks like part of "Singleboot Partition Layout" section only. It is confusing IMHO.
  • In my case (i.e. flashing both flash_core.sh and then flash_partition_table_and_core.sh), I had to recreate ext4 FS not only on the system partition in TWRP, but also on the data partition (it could not be mounted and TWRP announced 0 MB size) and eventually also on the cache partition. This seems to contradict the info in OP, part "Singleboot Partition Layout", which mentions that data will be preserved.
 

m11kkaa

Recognized Dev / Inactive Recognized Contributor
Jan 20, 2011
1,259
2,147
@cogano thx for your feedback :)
it's weird that u had to recreate the filesystems because the positions of these partitions still are the same. I resized system1, modem1 and boot1 to 2KB and system, modem and boot to 2*oldsize-2KB. I checked the offsets and they still are the same.
 

cogano

Senior Member
Mar 9, 2009
154
83
I have another phone and plan to do the same some time in the next week.
I'll try to avoid the trial&error approach and keep notes between the steps.

P. S. I am quite proficient with Linux administration. However I have to admit that upgrading android devices is usually a risky thing: I would have to read lot of guides - often unclear and confusing - or just give it a go and resolve the problems as they appear. The latter one eventually seems to be faster :)
 

m11kkaa

Recognized Dev / Inactive Recognized Contributor
Jan 20, 2011
1,259
2,147
I have another phone and plan to do the same some time in the next week.
I'll try to avoid the trial&error approach and keep notes between the steps.

P. S. I am quite proficient with Linux administration. However I have to admit that upgrading android devices is usually a risky thing: I would have to read lot of guides - often unclear and confusing - or just give it a go and resolve the problems as they appear. The latter one eventually seems to be faster :)

thx :) "parted /dev/block/mmcblk0 p" will help to debug these things.
If you don't have a ROM/Recovery with parted you can reboot to dload from the bootloader which will provide ur whole MMC as a usb drive to your computer.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 18
    Introduction
    This is a collection of Tools and Resources for Flashing Mi2(s)(c).

    MiFlash4Linux
    https://github.com/M1cha/aries-image-builder

    Core Recovery Package for MiFlash
    This is a small package to Recovery MI2 from any bricked state. It has the following advantages over the official ones from Xiaomi:
    • They don't flash any ROM, just the core system(bootloaders, modem and recovery)
    • They are small which means both Download and Installation are faster
    • It directly installs custom Bootloader and TWRP. That means you easily get your device back to a modded status.
    Please follow the official MiFlash guidelines for installation with the following differences:
    • the DLOAD config is called rawprogram_core.xml
    • the fastboot script is called flash_core.bat(or flash_core.sh for linux)
    • there's a script called flash_partition_table_and_core which is a alternative to flash_core.bat/sh.
      It can be used to change the partition table.
      USE THIS WITH THE CUSTOM BOOTLOADER INSTALLED BY ONE OF THE CORE PACKAGES ONLY. Xiaomi's bootloader will format your whole MMC device. THIS WOULD ERASE YOUR EFS AND YOU CAN'T MAKE CALLS ANYMORE

    Changing the partition table
    There are multiple packages available:
    separated: Xiaomi's original layout with a virtual internal sdcard
    separated_single: same as separated but without Dualsystem and bigger system partitions
    unified: Xiaomi's new layout with /data/media support
    unified_single: same as unified but without Dualsystem and bigger system partitions
    unified_single_xiaomi: Xiaomi's version of unified_single

    aries_core_unified_single.zip -> only MIUI > 5.4.x or M1cha's CM12.1 or latest AOSP5 works (only they can see Internal Storage, that now is a virtual sd-card in /data/media/0)

    aries_separated_single.zip -> other roms

    Installation:
    • Backup all your data(including internal sdcard, and EFS just to be safe)
    • if you don't use the custom Bootloader yet, flash this package using flash_core.bat/sh first. See the big red warning above for more information
    • flash the package using flash_partition_table_and_core.bat/sh
    • boot into recovery(which is TWRP now), recreate the filesystems for all partitions(system,data,cache,sdcard to ext4) in the wipe menu and reinstall your ROM.

    Version Information
    Bootloader: https://github.com/M1cha/mi2_lk/commits/LA.AF.1.1-02810-8064.0
    TWRP: v2.8.7.0
    core partitions: aries_images_5.7.16_20150626.0000.4_5.0_cn_a63cddccfa.tgz

    Download links for Mobile users:
    aries_core_unified_single_xiaomi.zip
    aries_core_unified_single.zip
    aries_core_unified.zip
    aries_core_separated_single.zip
    aries_core_separated.zip

    XDA:DevDB Information
    Flashtools, Tool/Utility for the Xiaomi Mi 2

    Contributors
    m11kkaa
    Source Code: https://github.com/M1cha/aries-image-builder


    Version Information
    Status: Stable

    Created 2015-02-21
    Last Updated 2015-07-27
    7
    Yes, exactly thats were my questions, when approximately you publish GRUB, i understand that you have pretty work abuot CM12.1 but i mean many users would like to use your GRUB. BTW why CM12.1 has high priority? Isnt enough to have CM12, because in the moment will arrive new Android M and after your CM12.x or whatelse, isnt it?

    G4A got a little setback because I had an idea that would change the whole concept(in a very good way both technical and for usability).
    I still have to proof that it can work and it really makes things easier for development.

    About CM12.1: the current version of CM is very unstable - especially when it comes to audio, camera and call bugs.
    I started to work from scratch based on Ivans new sources and am improving it step by step until we reach our old Nexus quality.
    This will definitely be helpful (and the base) for all future releases.
    5
    Ok the next and i hope final question is: do you suggest to merge the data with system as xiaomi did in the last few weeks. Do you suggest both? I mean yours and xiaomi's or there is sth that we have to avoid. Thanks in advance

    Sent from my MI 2S using Tapatalk

    I totally recommand merging data+sdcard(not system) partitions like Xiaomi did.
    There's absolutely no downside(except for ROM compatibility, but CM will support it soon) and Xiaomi should've shipped the phone at the release date with that config.

    I'll create new flash packages as soon as I have some time to reverse engineer the new layouts.
    5
    Is TWRP 2.8.5.0 also available as a zip somewhere? I only seem to find older versions in the other threads.

    EDIT: never mind, found the recovery.img in images folder.

    Are these bootloader and recovery compatible with MIUI V6 with merged partitions?

    from now on yes :) I just updated both the thread and the downloads, so make sure to read everything again :)
    I removed the G4A bootloader and replaced it with a modified Xiaomi bootloader.
    TWRP is now at 2.8.7.0 compiled from the new cm-12.1 sources with support for both merged and separated partition layouts.

    Also, TWRP supports backing up EFS now, PLS DO THAT!
    5
    @m11kkaa would you mind adding yet another layout to the flashtools? The one supported by Miui 5.11.19 and newer.
    Done :) (aries_core_unified_single_xiaomi.zip)

    Help, I flash aries_core_unified_single.zip or aries_core_separated_single.zip, both of them change my bootloader back to Mi fastboot, how to change to the custom fastboot?
    I stopped support for the custom bootloader previously included in miflash for two reasons:
    1) it was from Grub4Android, and these packages should just get u back to a flashing base(correct partitiontable, recovery etc) asap.
    2) Grub4Android got discontinued in advance of EFIDroid, so this UI doesn't exist anymore anyway. (it looks like this now: http://puu.sh/mfVHh/34233edaf5.jpg)