[U-Boot 7] Fastboot principle analysis and uboot fastboot function practice

  This article first introduces the basic principles of fastboot, then analyzes the implementation of fastboot in uboot, and finally tests the fastboot protocol and the use of various fastboot commands from a practical perspective. This article only briefly describes my own actual testing process. If there is anything inappropriate, you are welcome to enlighten me, thank you.

1. Overview

  First of all, make it clear that fastboot is a communication protocol.
  The fastboot protocol is a mechanism for communicating with the bootloader over USB or Ethernet (UDP). It's designed to be simple and can be used on a variety of devices and hosts running Linux, macOS, or Windows. The basic principle of implementation is that the PC communicates with the bootloader through the fastboot protocol.

In summary, the following points are as follows :
(1) Fastboot is a flashing method used by android. The Android system has designed two flashing methods: fastboot and recovery;
(2) Fastboot uses USB as physical transmission. Flashing is actually image transmission + burning. When fastboot flashes, the image is transferred through the USB cable; (
3) fastboot is also a command in uboot. When uboot starts, you manually enter the command line mode. If you need to flash the machine, you can Executing the fastboot command in the command line will allow uboot to enter fastboot mode, and flashing is performed in fastboot mode; (4
) If you want to flash the machine through uboot's fastboot command, you need the cooperation of the fastboot software on the host side (fastboot.exe)

2. Source code analysis

待添加。。。

3. Engineering practice

3.1 Preparation

3.1.1 Download fastboot.exe

  Download the fastboot host-side exe file at the following URL: https://developer.android.com/studio/releases/platform-tools?hl=zh-cnAfter
Insert image description here
  the download is complete, unzip it and enter the folder as follows: 在当前目录下,同时按下Shift+Ctrl,然后鼠标右键,选择“在此处打开 Powershell 窗口”,进入Powershell命令行.
Insert image description here
Insert image description here

.\fastboot.exe connect udp:192.168.100.152:5554
After the command is executed successfully, there is no response. 192.168.100.152 is the IP address of the development board, the port number is 5554 (fixed value), and communication is carried out through UDP.

3.1.2 uboot configuration and compilation

待添加。。。

3.1.3 uboot disk partition (making partition table)

  Before starting fastboot for file transfer, you need to ensure that the disk has been partitioned and the partition table has been created. The storage mechanism of the development board I use is 1G eMMC. The steps are as follows:

  1. Start the development board and enter the uboot command line mode;
  2. Set environment variables
=> setenv mbr_parts 'name=boot,start=4M,size=128M,bootable,id=0x0e; name=rootfs,size=10G,id=0x83'
  1. Write partition table to eMMC
=> mbr write mmc 0
MBR: write success!
  1. Verify whether the partition information is correct
=> mbr verify mmc 0
MBR: verify success!

Note: In my development board, the eMMC device is 0, so the above operations are all mmc 0. This needs to be modified according to the actual situation.

3.1.4 uboot format partition

Due to business needs, partition 1 needs to be formatted. The formatting command is:fatformat mmc 0:1

fatformat mmc 0:1	/* 将mmc0的分区1格式化为FAT32 */

3.1.5 Making file system (rootfs)

You can directly create your own file system for testing (rootfs.ext4.img) through the following script:
Insert image description here

dd if=/dev/zero of=rootfs.ext4.img seek=524288 count=0 bs=1024
mkfs.ext4 -F -i 4096 rootfs.ext4.img -d rootfs
fsck.ext4 -pdvfD rootfs.ext4.img

It should be noted that there must be a rootfs folder in the directory where the mkfs.sh script is run (some files or folders can be placed in the folder)

3.2 Testing

After entering the Uboot command line, execute the following command to view fastboot help information:
Insert image description here

The following information can be summarized through the help information:

  1. fastboot can use either udp or usb mode
  2. The optional parameter addr specifies the first address of the fastboot buffer in memory.
  3. The optional parameter size specifies the size of the fastboot buffer, in bytes

3.3.1 UDP mode

Development board
command:fastboot udp
Insert image description here

Windows host side
command:.\fastboot.exe -s udp:192.168.100.152:5554 flash mmcsda2 .\256.ext4.img
Insert image description here

3.3.2 usb mode

Development board side
command: fastboot usb 0
windows host side
command:.\fastboot.exe flash mmcsda2 .\256.ext4.img

references:

Supongo que te gusta

Origin blog.csdn.net/KXue0703/article/details/130797146
Recomendado
Clasificación