在 macOS 上实现等效 MiFlash
2024-09-27
7 min read
arm macOS 的平行桌面无法安装 9008 驱动的解决方案:不用平行桌面,用 brew 安装安卓调试桥工具后,找到刷机包或 MiFlash 目录中的 flash*.bat,将其修改为 bash 语法,具体修改后的脚本如下。
假设 super.img
已解压,且已放入 ./image
shell
#!/bin/bash
# 检查产品是否匹配
fastboot getvar product 2>&1 | grep -E "^product: *gauguin" || { echo "Mismatch image and device"; exit 1; }
# 刷写镜像
fastboot flash super "$(dirname "$0")/images/super.img" || { echo "Flash super error"; exit 1; }
fastboot flash cust "$(dirname "$0")/images/cust.img" || { echo "Flash cust error"; exit 1; }
# 擦除和刷写其他镜像
fastboot erase boot || { echo "Erase boot error"; exit 1; }
fastboot flash xbl "$(dirname "$0")/images/xbl.elf" || { echo "Flash xbl error"; exit 1; }
fastboot flash xblbak "$(dirname "$0")/images/xbl.elf" || { echo "Flash xblbak error"; exit 1; }
fastboot flash xbl_config "$(dirname "$0")/images/xbl_config.elf" || { echo "Flash xbl_config error"; exit 1; }
fastboot flash xbl_configbak "$(dirname "$0")/images/xbl_config.elf" || { echo "Flash xbl_configbak error"; exit 1; }
fastboot flash abl "$(dirname "$0")/images/abl_ecc.elf" || { echo "Flash abl error"; exit 1; }
fastboot flash ablbak "$(dirname "$0")/images/abl_ecc.elf" || { echo "Flash ablbak error"; exit 1; }
fastboot flash tz "$(dirname "$0")/images/tz.mbn" || { echo "Flash tz error"; exit 1; }
fastboot flash tzbak "$(dirname "$0")/images/tz.mbn" || { echo "Flash tzbak error"; exit 1; }
fastboot flash hyp "$(dirname "$0")/images/hyp.mbn" || { echo "Flash hyp error"; exit 1; }
fastboot flash hypbak "$(dirname "$0")/images/hyp.mbn" || { echo "Flash hypbak error"; exit 1; }
fastboot flash devcfg "$(dirname "$0")/images/devcfg.mbn" || { echo "Flash devcfg error"; exit 1; }
fastboot flash devcfgbak "$(dirname "$0")/images/devcfg.mbn" || { echo "Flash devcfgbak error"; exit 1; }
fastboot flash storsec "$(dirname "$0")/images/storsec.mbn" || { echo "Flash storsec error"; exit 1; }
fastboot flash bluetooth "$(dirname "$0")/images/BTFM.bin" || { echo "Flash bluetooth error"; exit 1; }
fastboot flash cmnlib "$(dirname "$0")/images/cmnlib.mbn" || { echo "Flash cmnlib error"; exit 1; }
fastboot flash cmnlibbak "$(dirname "$0")/images/cmnlib.mbn" || { echo "Flash cmnlibbak error"; exit 1; }
fastboot flash cmnlib64 "$(dirname "$0")/images/cmnlib64.mbn" || { echo "Flash cmnlib64 error"; exit 1; }
fastboot flash cmnlib64bak "$(dirname "$0")/images/cmnlib64.mbn" || { echo "Flash cmnlib64bak error"; exit 1; }
fastboot flash modem "$(dirname "$0")/images/NON-HLOS.bin" || { echo "Flash modem error"; exit 1; }
fastboot flash dsp "$(dirname "$0")/images/dspso.bin" || { echo "Flash dsp error"; exit 1; }
fastboot flash metadata "$(dirname "$0")/images/metadata.img" || { echo "Flash metadata error"; exit 1; }
fastboot flash keymaster "$(dirname "$0")/images/km4.mbn" || { echo "Flash keymaster error"; exit 1; }
fastboot flash keymasterbak "$(dirname "$0")/images/km4.mbn" || { echo "Flash keymasterbak error"; exit 1; }
fastboot flash logo "$(dirname "$0")/images/logo.img" || { echo "Flash logo error"; exit 1; }
fastboot flash featenabler "$(dirname "$0")/images/featenabler.mbn" || { echo "Flash featenabler error"; exit 1; }
fastboot flash misc "$(dirname "$0")/images/misc.img" || { echo "Flash misc error"; exit 1; }
fastboot flash aop "$(dirname "$0")/images/aop.mbn" || { echo "Flash aop error"; exit 1; }
fastboot flash aopbak "$(dirname "$0")/images/aop.mbn" || { echo "Flash aopbak error"; exit 1; }
fastboot flash qupfw "$(dirname "$0")/images/qupv3fw.elf" || { echo "Flash qupfw error"; exit 1; }
fastboot flash qupfwbak "$(dirname "$0")/images/qupv3fw.elf" || { echo "Flash qupfwbak error"; exit 1; }
fastboot flash imagefv "$(dirname "$0")/images/imagefv.elf" || { echo "Flash imagefv error"; exit 1; }
fastboot flash imagefvbak "$(dirname "$0")/images/imagefv.elf" || { echo "Flash imagefvbak error"; exit 1; }
fastboot flash uefisecapp "$(dirname "$0")/images/uefi_sec.mbn" || { echo "Flash uefisecapp error"; exit 1; }
fastboot flash uefisecappbak "$(dirname "$0")/images/uefi_sec.mbn" || { echo "Flash uefisecappbak error"; exit 1; }
fastboot flash multiimgoem "$(dirname "$0")/images/multi_image.mbn" || { echo "Flash multiimgoem error"; exit 1; }
fastboot flash vbmeta_system "$(dirname "$0")/images/vbmeta_system.img" || { echo "Flash vbmeta_system error"; exit 1; }
fastboot flash vbmeta "$(dirname "$0")/images/vbmeta.img" || { echo "Flash vbmeta error"; exit 1; }
fastboot flash dtbo "$(dirname "$0")/images/dtbo.img" || { echo "Flash dtbo error"; exit 1; }
fastboot flash recovery "$(dirname "$0")/images/recovery.img" || { echo "Flash recovery error"; exit 1; }
fastboot flash boot "$(dirname "$0")/images/boot.img" || { echo "Flash boot error"; exit 1; }
fastboot flash cache "$(dirname "$0")/images/cache.img" || { echo "Flash cache error"; exit 1; }
# 擦除和刷写用户数据
fastboot erase metadata || { echo "Erase metadata error"; exit 1; }
fastboot flash userdata "$(dirname "$0")/images/userdata.img" || { echo "Flash userdata error"; exit 1; }
# 重启设备
fastboot reboot || { echo "Reboot error"; exit 1; }
chmod +x ./flash_all.sh
./flash_all.sh
enjoy~