Please enable / Bitte aktiviere JavaScript!
Veuillez activer / Por favor activa el Javascript!

[Tutorial] Installing Flyme OS with custom recovery
Meizu MX4

I decided to write this tutorial to minimize the potential bricking possible when returning to flyme OS from a custom ROM without replacing the custom recovery.

!!!Never flash an update.zip directly if you have a modified phone!!!

That alone should be enough, but I’m going to go a step further and show you what you need to remove from a stock update.zip to ensure safe flashing.

I shall base my work on the newest stable version of flyme OS - 4.5.7A

Upon extracting the .zip, you can immediately delete the uboot.img file as well as the logo.img file as these are not needed (and will brick your phone if you flash them!)
Do not delete the boot.img as this is the kernel and is required.

Next up, we need to modify files in the META-INF folder:

(((An optional step is to remove the machine_match and imei.dat files and disable phone version checking (which is what I did) )))

Open the CERT.SF file and the MANIFEST.MF file in the text editor of your choice (preferable one that neatly shows all lines of code) and remove all entries of files that you previously deleted.

(((this includes the imei.dat and machine_match files if you decided to remove them)))

The files that have to be removed from the two lists are:
otacert
uboot.img
logo.img
(((imei.dat)))
(((machine_match)))

The actual otacert file can be found in META-INF/com/android - this file should be removed just in case (removing the file disables ota updates as you no longer have certification to get the ota updates)

Finally, under META-INF/com/google/android, open the updater-script and remove all the code concerning the flashing of the uboot.img and logo.img files - it should look something like this:

getprop("ro.product.device") == "mx4" || getprop("ro.product.device") == "mx4" || getprop("ro.product.device") == "M460A" || abort("This package is for \"mx4\" devices; this is a \"" + getprop("ro.product.device") + "\".");

package_extract_file(“META-INF/machine_match”, “/tmp/machine_match”);
set_perm(0, 0, 0755, “/tmp/machine_match”);
package_extract_file(“META-INF/imei.dat”, “/tmp/imei.dat”);
if (run_program("/tmp/machine_match", “/tmp/imei.dat”) != “0”) then
ui_print(“machine not match”);
delete(/tmp/imei.dat);
abort();
endif;
delete(/tmp/imei.dat);
show_progress(0.650000, 0);
block_image_update(“system”, package_extract_file(“system.transfer.list”), “system.new.dat”, “system.patch.dat”);
show_progress(0.100000, 0);
block_image_update(“custom”, package_extract_file(“custom.transfer.list”), “custom.new.dat”, “custom.patch.dat”);
show_progress(0.050000, 5);
assert(package_extract_file(“boot.img”, “/tmp/boot.img”),
write_raw_image("/tmp/boot.img", “bootimg”),
delete("/tmp/boot.img"));
delete("/data/nvram/APCFG/APRDCL/MD_Type");
show_progress(0.200000, 10);
delete_recursive("/data/data/com.mediatek.mtklogger/");

and like this if you removed the imei.dat and machine_match files:

show_progress(0.650000, 0);
block_image_update(“system”, package_extract_file(“system.transfer.list”), “system.new.dat”, “system.patch.dat”);
show_progress(0.100000, 0);
block_image_update(“custom”, package_extract_file(“custom.transfer.list”), “custom.new.dat”, “custom.patch.dat”);
show_progress(0.050000, 5);
assert(package_extract_file(“boot.img”, “/tmp/boot.img”),
write_raw_image("/tmp/boot.img", “bootimg”),
delete("/tmp/boot.img"));
delete("/data/nvram/APCFG/APRDCL/MD_Type");
show_progress(0.200000, 10);
delete_recursive("/data/data/com.mediatek.mtklogger/");

All you need to do is repack the update into a .zip format, and flash it via your custom recovery!

Optional:
Once booted back into flymeOS, your first steps are to gain root access (if you haven’t already), install some sort of file manager, remove the recovery-from-boot.p file in /system, and the install-recovery.sh file from /system/bin
Once you have removed these files, you need to enter fastboot mode once more and reflash your custom recovery (as it has been overwritten by the recovery-from-boot.p file).

Done! You have now returned to flyme OS from whichever other ROM you had (with custom recovery!)

Of course the usual warnings (that should already be known) still apply (mostly):
If you decided to do this with the international firmware, be sure to use an app like titanium backup to remove/disable the system update app

To finish up, I find it preferable to use a custom recovery instead of a patched stock recovery to update flyme OS as you have much more control over installation.

Here is an example of the modified update.zip (4.5.7A) (confirmed working):
https://drive.google.com/file/d/0B-PNmOKjIPzdOGhGa21oR3VRMWc/view?usp=sharing

last edited by meh301

There is a faster way (not as easy as this) :
Convert system.new.dat into system.img (there is a tool for that, it will just convert it in few seconds), copy it to the sdcard then boot into TWRP, format /system (/data) and /cache, mount /system, plug the phone to the computer, and via adb launch :
adb shell
dd if=/sdcard/system.img of=/dev/block/platform/mtk-msdc.0/by-name/system
Go to fastboot and type :
fastboot flash boot boot.img
fastboot reboot

Meizu MX4

@furious.builder I am aware of this but it requires a PC for installation while a simple flash from recovery does not require a computer so you can have several versions on your phone and just flash them when needed.

Best method would be to mix the two, convert the system.new.dat to system.img, unpack the system.img to remove the recovery-from-boot.p and install-recovery.sh files, repack the system.img, place into an update.zip and then flash so you don’t even have to reflash custom kernel.

It’s more complicated to repack system.img because windows don’t support EXT4 :/
fastboot flash system system.img is working too right ?

Meizu MX4

@furious.builder yeah fastboot flash system.img should work, its better to distribute all in one packages though for those who want to update while keeping custom recovery though :smile:

With fastboot flash system then boot, you can delete recovery-from-boot.p, recoveryres.dat, etc… From TWRP before booting for the first time, so you keep recovery :)

Meizu MX4

@furious.builder Maybe I should integrate a recursive deletion of the stock recovery files directly in the zip installer…

I don’t know why but on Flyme 5 I can’t delete them, even with root browser nor File Manager of TWRP, strange !

Meizu MX4

@furious.builder get root access on a terminal emulator, type in

mount -o remount,rw /system

And then browse to location of files via terminal and delete them with the rm command

Hi I have a question, in zip file I need remove preloader.img? Thanks

Meizu MX4

@autoradio78 There’s a preloader.img file!? Which zip file is this!?

DO NOT FLASH THIS, REMOVE THE FILE.

@meh301 said in [Tutorial] Installing Flyme OS with custom recovery:

@autoradio78 There’s a preloader.img file!? Which zip file is this!?

DO NOT FLASH THIS, REMOVE THE FILE.

Is a Meizu M2 mini flyme OS 4 I version. I want to keep twrp but I want also return to stock flyme OS. I have uboot.img , logo.img and preloader.img…

Meizu MX4

@autoradio78 Well I’m not sure for m2 mini, I wouldn’t include the preloader.img file though.

I installed version 5.1.5.0 Flyme prepared to TWRP. I used ClockwordMod Recovery. Now ClockwordMod recovery disappeared and is Flyme recovery. How to restore the custom recovery? Flashing by fastboot?

Looks like your connection to [Tutorial] Installing Flyme OS with custom recovery was lost, please wait while we try to reconnect.