1. Flashing with fastboot
1. fastboot concept
fastboot is a command-line tool for USB communication between PC and BootLoader. It can re-burn the Android system partition by sending the flashing file (.img) to BootLoader. Fastboot requires BootLoader support and needs to be connected with a USB data cable, so it is often called the wire flash mode.
2.BootLoader
BootLoader is a piece of code used to boot the kernel in an embedded device. Kernel startup requires certain conditions. When the device is powered on, BootLoader will be run first, and BootLoader will initialize necessary hardware, such as DDR, Flash, serial ports, etc. Through this program, the system hardware environment can be set to a suitable state for Prepare the environment for system kernel debugging, and start the kernel after the relevant initialization is completed.
(In embedded systems, there is usually no solid-state program like BOIS, so the loading and starting tasks of the entire system are completed by BootLoader. The BootLoader program is usually arranged at the address 0x0000 0000 where the embedded system starts to run)
3.uboot & fastboot
uboot (universal bootloader) is a BootLoader program that can be used for various embedded CPUs.
Enter the fastboot command under uboot to make uboot enter the fastboot mode, and flashing is to flash in fastboot mode.
The development board itself is not a usb device, so when our development board is directly connected to the usb interface of the host through the usb cable, the host cannot recognize a usb device. When we enter the fastboot command under uboot, the host will recognize a usb device and prompt to install the driver.
4. Flash mode
4.1
Recovery mode (swipe card): the system ROM must be copied.
When customizing the system, the compiling system will compile a ZIP compressed package, which contains some system partition images, which are provided to customers for manual upgrade and system recovery. You need to build the compressed package into the SDcard in advance, and do it in Recovery mode. How to enter Recovery: After turning off the phone completely, press and hold the volume button down (up) + power button to enter the BootLoader interface. Use the volume up and down to control the cursor, and the power key to confirm (some machines can only use the volume down key to select, and the up key is the confirmation key).
4.2 Wire Brush
fastboot mode (wire brush): By flashing the .img image file, the partition can be reflashed without starting the kernel.
Fastboot is a lower-level flashing mode than Recovery in Android phones. Fastboot defines a set of protocols between the development board and the host, and is a flashing mode that uses a USB data cable to connect the mobile phone, which is the so-called wire flashing.
5. Frequently used partitions for flashing
Partition | effect |
---|---|
splash1 | Startup screen, the file after backing up the system with Nandroid backup is splash1.img |
recovery | This partition is in recovery mode (that is, press Home+poweri to enter the interface after booting, and use Nandroid backup to backup it as recovery.img |
boot | Kernel boot partition, backed up as boot.img using Nandroid backup |
system | For the Android system part, the directory is represented as /system, which is usually read-only, and it is backed up as system.img by using Nandroid backup |
cache | The cache folder, the directory is represented as /cache, in fact, except for the OTA update of T-mobile, it has little effect. Use Nandroid backup to back up as cache.img |
userdata | The software and various data installed by the user, the directory is /data, and the backup is data.img using Nandroid backup |
Two, fastboot command
restart related
fastboot reboot 重启⼿机
fastboot reboot-bootloader 重启到bootloader模式,其实就是再次进入fastboot
fastboot -w reboot 清除手机中所有数据然后重启
// fastboot -w reboot 等同于系统中的“恢复出厂设置”,或Recovery模式的“清空所有数据”操作
Erase related (erase)
fastboot erase {
partition} 擦除分区
fastboot erase boot 擦除boot分区
fastboot erase recovery 擦除recovery分区
fastboot erase system 擦除system分区
fastboot erase userdata 擦除userdata分区
fastboot erase cache 擦除cache分区
Write partition (flash)
fastboot flash {
partition} {
*.img} 烧录img文件至对应分区
fastboot flash boot boot.img 写⼊boot分区
fastboot flash recovery recovery.img 写⼊recovery分
fastboot flash system system.img 写⼊system分区
view related
fastboot getvar all 获取⼿机的全部信息
fastboot devices 查看fastboot模式下连接的手机
other
fastboot boot <内核镜像文件名或路径> 临时启动镜像,不会烧录和替换内核文件到存储中
fastboot oem device-info 输出当前BL锁状态(非MTK)
fastboot oem lks 输出当前BL锁状态(MTK)
fastboot oem poweroff 拔掉数据线后关机
fastboot oem lock 重新上BL锁并清空所有数据(需未开启root)
fastboot oem unlock 解除BL锁并清空所有数据
//小米手机必须绑定账号,主动申请解锁,等待7天,使用工具才行
fastboot flashing unlock 解锁设备
Android fastboot common commands
3. OEM unlocking (MTK)
Unlock Commands & Actions
Set the phone to developer mode, select OEM unlock in developer mode
Connect to adb, restart to bootloader mode
adb reboot bootloader
When fastboot mode appears on the phone screen, unlock the device
fastboot flashing unlock
According to the prompt, press the volume up key to unlock. After the prompt is successful, restart the device:
fastboot reboot
After restarting, the device will be reminded that it is unlocked, and the device data will be reset.
push file
Get root privileges
adb root
Turn off the partition detection function
After Android 7, the partition will be verified accordingly. For example, the system partition cannot use adb root or adb remount to mount the system partition like the previous version, and the partition detection function needs to be turned off first.
adb disable-verity
The device needs to be restarted after executing adb disable-verity
adb reboot
Get root permission again after the device restarts
adb root
mount (make the partition readable and writable)
adb remount
The device needs to be restarted after push