fastboot

2021-02-07, updated 2021-09-12

adb reboot bootloader 命令进入bootloader/fastboot模式,才可以使用fastboot进行烧写 adb reboot recovery 命令行进recovery模式

usage: fastboot [ <option> ] <command>  

commands:  
update <filename>   reflash device from update.zip  
flashall    "flash boot" + "flash system"  
flash <partition> [ <filename> ] write a file to a flash partition  
erase <partition>   erase 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  
reboot     reboot device normally  
reboot-bootloader   reboot device into bootloader  
options:  
-w     erase userdata and cache  
-s <serial number>   specify device serial number  
-p <product>    specify product name  
-c <cmdline>    override kernel commandline  
-i <vendor id>    specify a custom USB vendor id 

1 升级系统

fastboot flash bootloader u-boot.bin
fastboot flash kernel uImage
fastboot flash system system.img
fastboot flash userdata userdata.img
fastboot flash ramdisk ramdisk-uboot.img
fastboot erase cache

fastboot flash {partition} {*.img}   例:fastboot flash boot boot.img或fastboot flash system system.img等。

fastboot flashall   注意:此命令会在当前目录中查找所有img文件,将这些img文件烧写到所有对应的分区中,并重新启动手机。

一次烧写boot,system,recovery分区:

(1)创建包含boot.img,system.img,recovery.img文件的zip包。

(2)执行:fastboot update {*.zip}

烧写开机画面:

fastboot flash splash1 开机画面

2 重启系统

fastboot reboot

3 不烧写flash情况下调试

fastboot boot uImage 或者u-boot.bin

4 查看版本号

fastboot getver:version

5 复位到bootloader

fastboot reboot-bootloader

6 命令格式

主机端发送字符串的命令,字符串小于等于64个字节,客户端首先返回四个字节的内容,是OKAY、FAIL、DATA、INFO之一,随后跟着是信息或数数据。

7 清空分区

fastboot erase {partition}   例:fastboot erase boot或fastboot erase system等。

fastboot erase boot

fastboot erase system

fastboot erase data

fastboot erase cache

上面的命令也可以简化成一条命令

fastboot erase system -w

8 获取客户端(手机端)变量信息

fastboot getvar version:version-bootloader:version-baseband:product:serialno:secure 
/ # df
df
Filesystem           1K-blocks      Used Available Use% Mounted on
ubi0:rootfs              57800     34888     22912  60% /
tmpfs                       64         8        56  13% /dev
tmpfs                    79260        24     79236   0% /run
tmpfs                    79260        80     79180   0% /tmp
tmpfs                    79260         0     79260   0% /media/ram
ubi0:cachefs             50344        24     47712   0% /cache
ubi0:usrfs               44036        24     44012   0% /data
/dev/ubi1_0              39564     31036      8528  78% /firmware
/dev/ubi2_0               3668       116      3552   3% /etc/backup
/dev/ubi3_0               3668      1892      1776  52% /mnt/cdrom
/dev/ubi4_0              55048     10484     44564  19% /bmdefsys
/ # cat /pr     mt
/ # cat /proc/mt
cat: can't open '/proc/mt': No such file or directory
/ # cat /pr     mtd
/ # cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00140000 00020000 "sbl"
mtd1: 00140000 00020000 "mibib"
mtd2: 00c00000 00020000 "efs2"
mtd3: 000c0000 00020000 "tz"
mtd4: 00060000 00020000 "rpm"
mtd5: 00100000 00020000 "aboot"
mtd6: 00940000 00020000 "boot"
mtd7: 01040000 00020000 "scrub"
mtd8: 037c0000 00020000 "modem"
mtd9: 01420000 00020000 "misc"
mtd10: 00940000 00020000 "recovery"
mtd11: 05040000 00020000 "fota"
mtd12: 01980000 00020000 "recoveryfs"
mtd13: 01420000 00020000 "cdrom"
mtd14: 04c00000 00020000 "bmdefsys"
mtd15: 00040000 00020000 "sec"
mtd16: 0b6a0000 00020000 "system"
/ #
words: 880 tags: fastboot