fastboot有快速启动的意思, 但这里指的是安卓系统的线刷模式。

安卓手机刷机一般使用两种模式,  fastboot 线刷,  recovery 卡刷,

通常: 一个使用usb线连接电脑,  另一个使用sd卡。


fastboot相对更底层点, 是启动过程中进入的一种模式。

uboot最新代码就集成了fastboot模块。故只要使用uboot作为引导程序且支持usb接口(从设备模式)的产品, 一般都能支持fastboot线刷。

查看fastboot相关代码日志,

git log README.android-fastbootcommit 3aab70afc531d1eea0e6fcfcf49001163ad13137
Author: Sebastian Siewior <bigeasy@linutronix.de>
Date:   Mon May 5 15:08:10 2014 -0500usb/gadget: add the fastboot gadgetThis patch contains an implementation of the fastboot protocol on thedevice side and documentation. This is based on USB download gadgetinfrastructure. The fastboot function implements the getvar, reboot,download and reboot commands. What is missing is the flash handling i.e.writting the image to media.

翻到最下面, 可以看到大约是2014年5月5日合入的代码。


recovery卡刷相对运行的更高层一点。其实就类似linux电脑的恢复模式, windows电脑的安全模式。

内核是引导起来的, 只不过加载的文件系统是一个recovery分区中的文件系统, 该文件系统通常不去更改, 里面存放一些必要的软件。如busybox, gpart, 网络工具等等。

安卓手机就是利用该recovery模式进行刷机操作, 将sd卡中的数据刷入手机emmc存储介质中。


ok, 这里记录下利用uboot fastboot功能更新相应分区镜像。

1. 这里使用的环境是xilinx zynq-ultrascale开发环境, 使用sd卡做为启动存储介质。即类似树莓派, 并不使用内部emmc作为存储介质。 而使用sdio接口读写外部sd/emmc卡。

2. sd卡分区模式使用传统的mbr模式, 即前512byte为mbr, main boot record主引导记录。(其中前446字节为引导程序, 后面跟着共四个分区表信息, 每个16字节,  共64字节。 最后以0xaa55的结束符2个字节。)

之后跟着2个分区, 一个为fat32分区,存放bootloader, kernel, uboot env, dtb等等文件。灵一个为ext4分区, 就是根文件系统。

具体分区信息如下:

river@river-VirtualBox:~/image$ fdisk sdimage.imgWelcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.Command (m for help): p
Disk sdimage.img: 576 MiB, 603979776 bytes, 1179648 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x09dcfcefDevice       Boot  Start     End Sectors  Size Id Type
sdimage.img1        2048  133120  131073   64M  b W95 FAT32
sdimage.img2      133121 1179647 1046527  511M 83 LinuxCommand (m for help):

3. 启动进入uboot shell

查看mmc 信息

ZynqMP> mmc info
Device: sdhci@ff170000
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Tran Speed: 50000000
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
ZynqMP> mmc list
sdhci@ff170000: 0 (SD)
ZynqMP> mmc partPartition Map for MMC device 0  --   Partition Type: DOSPart Start Sector    Num Sectors UUID        Type1   2048        131072      a69ff1bd-01 0b2 133120      1048576     a69ff1bd-02 83
ZynqMP> 

4. 开发板启动fastboot

ZynqMP> fastboot
fastboot - use USB Fastboot protocolUsage:
fastboot <USB_controller>- run as a fastboot usb device
ZynqMP> fastboot usb0

5. windows pc端就能发现USB download gadget设备, 是的fastboot对应的usb设备驱动就是download gadget。

windows pc安装fastboot客户端可参考安卓官网攻略, 相对步骤多点。

ubuntu电脑的话apt软件仓库中就有。 sudo apt-get install fastboot即可。

常用命令有

fastboot reboot

fastboot getvar xxx

fastboot erase <partition_name>

fastboot flash <partition_name> <partition_image>

fastboot flashall

下面演示主机端操作

river@river-VirtualBox:~/image$ fastboot devices
????????????    fastboot
river@river-VirtualBox:~/image$ fastboot erase mmcsda1
erasing 'mmcsda1'...
OKAY [  0.135s]
finished. total time: 0.135s
river@river-VirtualBox:~/image$
river@river-VirtualBox:~/image$
river@river-VirtualBox:~/image$ fastboot flash mmcsda1 boot.img
target reported max download size of 100663296 bytes
sending 'mmcsda1' (65536 KB)...
OKAY [  3.308s]
writing 'mmcsda1'...
OKAY [  4.781s]
finished. total time: 8.089s
river@river-VirtualBox:~/image$ 

开发板相应log

GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid Backup GPT ***
Erasing blocks 2048 to 133120 due to alignment
........ erased 67108864 bytes from 'mmcsda1'
request 000000007dee0400 was not queued to ep1in-bulk
WARNING: unknown variable: slot-count
request 000000007dee0400 was not queued to ep1in-bulk
WARNING: unknown variable: slot-suffixes
request 000000007dee0400 was not queued to ep1in-bulk
WARNING: unknown variable: slot-suffixes
request 000000007dee0400 was not queued to ep1in-bulk
WARNING: unknown variable: has-slot:mmcsda1
request 000000007dee0400 was not queued to ep1in-bulk
WARNING: unknown variable: partition-type:mmcsda1
request 000000007dee0400 was not queued to ep1in-bulk
request 000000007dee0400 was not queued to ep1in-bulk
Starting download of 67108864 bytes
request 000000007dee0400 was not queued to ep1in-bulk
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
..........................................................................
....................................................................request 000000007dee0400 was not queued to ep1in-bulkdownloading of 67108864 bytes finished
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid Backup GPT ***
Flashing Raw Image
........ wrote 67108864 bytes to 'mmcsda1'
request 000000007dee0400 was not queued to ep1in-bulk

是的, 开发板上挺多警告log, 关于gpt, mbr相关。


6. fastboot 支持gpt分区,  同时也支持mbr分区。

gpt分区: 安卓系统多采用gpt分区形式, 如以下就是其中一个分区例子。

Partition#   Name#   Size#   Strat LBA-End LBR   Description#
0   MBR & GPT       0x00000000-0x000000FF   Master Boot Record and GUID Partition Table
1   x-loader(MLO)   256KB   0x00000100-0x000001FF   First stage bootloader
2   bootloader(u-boot.bin)  384KB   0x00000200-0x000005FF   Second stage bootloader
3   misc    128KB   0x00000600-0x000006FF   Reserved.This partition can be used for internal purpose
4   recovery (zImage + recovery-ramdisk.img)   8MB 0x00000A00-0x000049FF   recovery partition
5   boot (boot.img = zImage + ramdisk.img)    8MB 0x00004A00-0x000089FF   Partition contains kernel + ramdisk images.
6   system (system.img) 256MB   0x00008A00-0x000889FF   android file system
7   cache (cache.img)   32MB    0x00088A00-0x000989FF   Partition will be used to store application cache
8   userdata (userdata.img) 32MB    0x00098A00-0x000A89FF   Partition contains userdata supplied by oem vendor like configuration files,utilities etc..
9   media   Remaining   0x000A8A00-0x00762761   Partition contains media files; supplied by oem vendor

可以看到第二行, 可采用partition_name进行分区的擦除烧写等操作。

例如

fastboot erase boot

fastboot flash boot boot.img

fastboot flash system.img

关于mbr分区表格式,  由于没有partition_name, 该如何进行分区操作呢?  继续参考uboot/doc/README.android.fastboot

Partition Names
===============
The Fastboot implementation in U-boot allows to write images into disk
partitions (currently on eMMC). Target partitions are referred on the host
computer by their names.                                                                                                                               For GPT/EFI the respective partition name is used.                                                                                                     For MBR the partitions are referred by generic names according to the
following schema:                                                                                                                                      <device type> <device index letter> <partition index>                                                                                                Example: hda3, sdb1, usbda1                                                                                                                            The device type is as follows:                                                                                                                         * IDE, ATAPI and SATA disks: hd                                                                                                                      * SCSI disks: sd                                                                                                                                     * USB media: usbd                                                                                                                                    * MMC and SD cards: mmcsd                                                                                                                            * Disk on chip: docd                                                                                                                                 * other: xx                                                                                                                                          The device index starts from 'a' and refers to the interface (e.g. USB
controller, SD/MMC controller) or disk index. The partition index starts
from 1 and describes the partition number on the particular device. 

所以以上操作中使用的命令为

fastboot erase mmcsda1

fastboot flash mmcsda1 boot.img

fastboot flash mmcsda2 rootfs.img


7. 关于boot.img, rootfs.img这些景象该如何制作

sdimage中是多分区的镜像集合。可以将其拆解开。

我这里依然采用制作sdimage的方法,

sudo dd if=/dev/zero of=boot.img bs=1M count=64M

sync

losetup -f boot.img                  // -f 是find第一个可用的loop回环设备

losetup -a                                // 查看所有loop设备, 假设是/dev/loop1

mkfs.vfat /dev/loop1

sudo mount /dev/loop1 /mnt/boot/

然后拷贝相应的boot文件, 如uboot, kernel, dtb等到该目录。

即可


多镜像分区利用fdisk命令即可。

后续利用gdisk, parted等工具制作一个gpt分区的sd卡。并尝试运行。(mbr + gpt)

fastboot烧写sd卡mbr类型分区相关推荐

  1. SD-Flasher在win7系统里面烧写SD卡的问题

    http://blog.csdn.net/cghver/article/details/8522021 参考上面网站

  2. android 编译fastboot,Android应用开发之Fastboot烧写Android镜像文件到eMMC

    本文将带你了解Android应用开发之Fastboot烧写Android镜像文件到eMMC,希望本文对大家学Android有所帮助. < Fastboot烧写Android镜像文件到eMMC 以 ...

  3. MSM8974 fastboot烧写软件

    fastboot烧写是在aboot阶段做的,所以空板没有完整烧写aboot及其boot sequence前的image是没法使用fastboot的.在手机开机状态下,执行:         adb r ...

  4. 手把手教你做树莓派魔镜-MagicMirror(二)-烧写系统卡

    本系列文章: 手把手教你做树莓派魔镜-MagicMirror(一)-准备工作 手把手教你做树莓派魔镜-MagicMirror(二)-烧写系统卡 手把手教你做树莓派魔镜-MagicMirror(三)-系 ...

  5. 树莓派魔镜MagicMirror —— 2 烧写系统卡

    本系列文章仅做作业做的记录! 树莓派魔镜MagicMirror: 树莓派魔镜MagicMirror -- 1 前期准备工作 树莓派魔镜MagicMirror -- 2 烧写系统卡 树莓派魔镜Magic ...

  6. 嵌入式Linux学习笔记—fastboot烧写Android

    本系列为本人在自学过程中的学习笔记,如有错误欢迎大家指正. 学习资料为讯为ITOP4412开发板. fastboot烧写Android 1.主要工具 OTG 接口烧写方式也叫 fastboot 烧写方 ...

  7. Linux下eMMC,SD卡格式化和分区管理

    Linux下eMMC,SD卡格式化和分区管理 一.Linux下查看eMMC设备是否正确识别 在命令行终端,输入ls /dev/mmc* -l,查看eMMC是否成功识别 dev目录下成功识别到了eMMC ...

  8. linux查看sd卡系统类型,从SD卡启动linux系统

    ---------------------------------------------------------------------------------------------------- ...

  9. android自动烧写工具,利用fastboot烧写Android平板镜像典型步骤举例

    1.准备fastboot烧写工具 在windows下下载fastboot软件,并将如下文件: bootloader.fex, env.fex,boot.img,recovery.img ,userda ...

最新文章

  1. sa执行命令方法总结
  2. FlashDevelop flex sdk 报错的奇怪问题
  3. 如何在 ASP.NET Core 中使用 LazyCache
  4. “5G+AI”到底有啥用?这篇漫画告诉你答案…
  5. Java阶段2-02JS:08ECMAScript BOM DOM:
  6. vscode同时打开多个文档方法,简直了
  7. 形象化理解 SpringBoot + SpringCloud
  8. android activity获取dialog对象,Android:从DialogFragment调用Activity的功能
  9. 数据中心服务器巡检方案,IDC机房巡检方案
  10. 贴片led极性_贴片发光二极管正负极判断方法详解
  11. 任正非的小女儿,出道了!以后会代言华为手机吗?
  12. 【R语言】GARCH模型的应用
  13. 女生学习前端究竟适不适合?
  14. 一款轻量的支付宝支付组件
  15. linux-centos7解决视频无法看问题(安装Adobe flash player)
  16. Gabor变换(2)
  17. Latex下代码的排版
  18. python研究背景和意义_课题设计研究的背景和意义
  19. 微信开放平台--》网站应用开发 微信登录网站接口(https://open.weixin.qq.com/)
  20. Android应用程序开发期末大作业(1)

热门文章

  1. win7命令启动计算机管理,Win7系统电脑如何删除Windows启动管理器选项?
  2. 可靠的手机问题修复工具分享 - 修复各种 Android 系统问题
  3. JavaScript中 bind函数的实现
  4. java+lamda+传参_lambda表达式传参
  5. Ubuntu系统目录
  6. Java Calendar set()方法与示例
  7. 虚拟机linux安装zookeeper
  8. 三季报业绩预增幅度较大的公司一览
  9. Vue上传文件操作(没有CV,认真看)
  10. 深度学习中的协方差矩阵