[Xiaomi Mi A1 Guides, News, & Discussion] CosmicDan:
What?

A Windows (only) toolkit for making full backup/restore of all Mi A1 partitions to/from your PC.

Utilizes EMMCDL in Qualcomm EDL mode - only needs fastboot access (unlocked BL) or testpoint (for bricked devices, maybe locked ones too - not sure)

Backups create a rawprogram0.xml file which could also be restorable in MiFlash if you choose (untested - not part of toolkit goal).

See FAQ at bottom for details about how to use EDL mode.

--------------------------------

Why?

Mainly to...

...backup all your hidden/system partitions that TWRP cannot (e.g. persist) to keep them safe.

...recover your device in the event of a brick

--------------------------------

How?

Requirements

Windows PC ONLY

Qualcomm EDL drivers (can get them from here, among other places)

Fastboot access working with driver (generic binary and driver work fine, it's all over the place

If you're firm-bricked (stuck in Diagnostic mode) you need to disassemble and bridge the test-points to kick it out of diagnostic mode - but that's beyond the scope of this thread/tool.

Setup

Download the latest version from GitHub (link at bottom) and extract

Connect your device with a quality USB-C cable (original worked well). Some cheap cables, or USB2 > USB-C adapters can cause the process to fail.

Boot into fastboot and run the command...

fastboot oem edl

...you may see an error, that's normal. Device should now have blank screen and a white flashing light.

Install the QDLoader driver. You may see this in device manager if you've not installed it yet...

[Link because XDA forum keeps breaking my IMG tags whenever I edit]

...just right click > properties > update driver, the usual thing (if you downloaded the smaller driver pack ZIP from above). Then it should look like this...

[Link because XDA forum keeps breaking my IMG tags whenever I edit]

If your COM port in device manager (see above) is notCOM30, you need to-

Edit the config.ini in the toolkit folder

Replace com30 with whatever your port is

Now you're ready to use the tool.

Usage

The toolkit is pretty self-explanatory. But first you need to select which partitions you want to backup with option 1. Two partition lists are already included:

partition_list.all.txt - this list selects all partitions that exist on the Mi A1. Note that backing up system(_a/_b) and especially userdata will take a VERY LONG TIME. Also note that the backup images are NOT compressed; so expect to have 32GB space free for example (if you have a 32GB device).

partition_list.skip-systems-and-userdata.txt - this will backup all partitions except system(_a/_b) and userdata. More useful, since we backup system and userdata in TWRP anyway. All the other firmware partitions come to only about 500MB.

Once you select the list you want to use, you can run the backup with 2 - just enter a folder name and it'll go there.

Restore does not require a partition list to be loaded; since the partition table is stored inside the backup as rawpartition0.xml. You can manually edit this file if you want to selectively restore partitions - just delete the whole line of partitions you don't want to restore. Note that changing any of these values will NOT repartition the device - you'll only corrupt your partition table if you do this.

Well I guess that's it, I will update this guide after feedback (it's a bit rough, I am kind of rushing lol).

--------------------------------

Where?

Download the latest version on GitHub:

https://github.com/CosmicDan-Android/MiA1LowLevelBackupRestoreTool

... simply press the green 'Clone or download' button on the right, then 'Download ZIP'.

--------------------------------

Who?

Special thanks to @emuzychenko for his batch script wizardry which this is mostly based on. You can see his original tool and scripts here. I just re-wrote it all to be more user friendly and convenient for me and others.

--------------------------------

History

2022-03-04

Fix for systems with a GNU-like find executable in path

2018-05-23

Added config option to change transfer speed (reducing may help with freezes)

2018-05-15

Fixed crashing when path containing tool has spaces

Added a "debug mode" that won't instantly close the Window in event of a hard crash (why oh why did I ever use Batch again...)

Added a "persist-only" partition list

2018-05-14

Initial version

--------------------------------

FAQ

Q) EDL mode? Eh?

A) EDL mode, or "Emergency DownLoad" mode, is a low-level mode for flashing devices. It is entered by the command:

fastboot oem edl

EDL mode is used to read/write to the eMMC more directly. It is used by this tool, as well as flashing with MiFlash.

Other important notes:

You will need good QDLoader drivers. These drivers gave me the best results.

You can exit EDL mode by holding Power button for ~10 seconds. Hold with VolDn to reboot into fastboot again, as one might expect.

Make sure you use a good USB-C cable.

Sometimes the flashing process can freeze. It will always report success when done. If it freezes, you need to reboot EDL mode. Try a different USB port or cable if you keep experiencing freezes.

Q) I get a freeze or hang when trying backup/restore partitions

A) First, make sure it's actually frozen. Open log.txt in the tool folder, and then open it again to see if it's changed.

If not, make sure you're using the driver linked in this post, as it proved to be most reliable by myself and others. You can also try these things (recommended in this order):

Reboot to EDL mode again;

Use a different (better) cable;

Use a different USB port;

Reduce the transfer speed in config.ini (be sure to read the comments)

Use a different PC;

Of course all are welcome to post their questions/suggestions and so on. Happy flashing!