fastboot使用方法

本文代码基于Android9.0

fastboot环境进入

1.执行命令: adb reboot fastboot

2.同时按住 音量+ 和 电源 键开机

命令执行流程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fastboot flashing unlock                # 设备解锁,开始刷机

fastboot flash boot boot.img # 刷入 boot 分区。如果修改了 kernel 代码,则应该刷入此分区以生效

fastboot flash recovery recovery.img # 刷入 recovery 分区

fastboot flash country country.img # 刷入 country 分区。这个分区是开发组自己划分的,别的 Android 设备上不一定有

fastboot flash system system.img # 刷入 system 分区。如果修改的代码会影响 out/system/ 路径下生成的文件,则应该刷入此分区以生效

fastboot flash bootloader bootloader # 刷入 bootloader

fastboot erase frp # 擦除 frp 分区,frp 即 Factory Reset Protection,用于防止用户信息在手机丢失后外泄

fastboot format data # 格式化 data 分区

fastboot flashing lock # 设备上锁,刷机完毕

fastboot continue # 自动重启设备

fastboot命令的使用说明

将adb配置到全局环境变量,在命令行输入 fastboot -h 命令即可查看fastboot的使用帮助(注:[]可选,<>必选)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
user@user-OptiPlex-3020:~$ fastboot -h
usage: fastboot [ <option> ] <command>

commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
format <partition> format a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
continue continue with autoboot
reboot reboot device normally
reboot-bootloader reboot device into bootloader
help show this help message

options:
-w erase userdata and cache (and format
if supported by partition type)
-u do not first erase partition before
formatting
-s <specific device> specify device serial number
or path to device port
-l with "devices", lists device paths
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048
-S <size>[K|M|G] automatically sparse files greater than
size. 0 to disable