Commit Graph

8 Commits

Author SHA1 Message Date
Jocelyn Bohr df6f4a1cdf fastboot: Handle getvar for partition-size
Bug: 36889156
Test: Ran 'getvar partition-size:<partition>' for all partitions on rpi3
Change-Id: Id85a1164ab382f43201a08d3f9d86eb42ad1e3cd
2017-11-14 10:55:47 +08:00
Jocelyn Bohr 9ec8daff33 Handle all commands and variables for "fastboot flashall"
Implement the rest of the variables and fastboot commands for flashall.
For A/B related commands, slot A is always selected.

Bug: 31887729
Test: "fastboot flashall" does not result in any unknown commands or
      variables

Change-Id: Iec794a0a0805aeb744157ab25b417443a3fc7f5a
2017-11-14 10:55:45 +08:00
Jocelyn Bohr aba554cc34 Handle slow MMC writes
Flashing a 400Mb sparse system image takes ~10 minutes. The fastboot UDP
protocol expects a response within 1 minute, so during long flash
operations, the device must send fastboot "INFO" packets.

This patch does the following:
  - Separate large writes into writes of size FASTBOOT_MAX_BLK_WRITE.
    This parameter was tuned by hand to result in a ~10 second write.
  - Keep a timer and send an INFO packet every 30 seconds.
  - Adjust the sequence number in the header of the fastboot OKAY packet
    to account for any INFO packets sent during flashing.
  - Reduce busywaiting in the bcm2835 MMC driver. This change is based on
    what the kernel does, and doesn't seem to corrupt the MMC. Without
    this change, "flashall" takes 25 minutes.

Bug: 31887729
Test: "fastboot -s udp:$RPI_IP flashall" works, rpi3 boots
      - Compute CRC checksum over every write to verify written data
        was not corrupted.

Change-Id: Ib17ef6a85715705a8b5f722a8b7d3e5fd1a6625d
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 0eda6822d0 Implement fastboot continue, reboot, reboot-bootloader, boot.
Add functions to respond to fastboot continue, reboot, and
reboot-bootloader. Continue continues the normal android boot process.
Reboot-bootloader writes a message to the start of the fastboot
buffer, to be parsed at the start of the android boot process. Boot
boots the previously downloaded image from memory.

Bug: 31887729
Test: - Sending "continue" boots into android.
      - Sending "reboot" reboots the device.
      - Sending "reboot-bootloader" reboots the device, and the
        message persists in memory.
      - Sending "boot boot.img" boots into kernel.

Change-Id: I8b14724de4612450ccc382bb7532edb993e6e8a4
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 8b464fa913 Implement fastboot flash and erase.
Add function to respond to fastboot flash and erase. Flash writes the
previously downloaded image to indicated partition. Erase clears the
indicated partition. fb_flash and fb_erase are essentially wrappers
for fb_mmc_flash_write and fb_mmc_erase, which are implemented in
common/fb_mmc.c.

Added common/fb_common.c, where fastboot_okay/fail are implemented.
common/fb_mmc.c assumes fasboot_okay() and fastboot_fail() are
implemented, but they were tied to the fastboot USB implementation.
This refactor adds the response string as a parameter to
fastboot_okay/fail, instead of modifying a global.

Bug: 31887729
Test: FLASH:
      - Create file "foo" containing 2048 chars = "-"
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP flash misc foo" from host
      - From U-boot console, read into memory the first 4 blocks from
        misc partition, observe each byte is "-".

      ERASE
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP erase misc" from host
	  - From U-boot console, read into memory many blocks from misc
        partition, observe each byte is 0x00

	  Configs that use fastboot USB implementation still build.

Change-Id: I5bd54868990bd9d5736d0969b3db240c2926eeec
2017-11-14 10:55:45 +08:00
Jocelyn Bohr 45930fc17b Implement fastboot download.
Adds function to respond to fastboot download, and copy downloaded
image to buffer in RAM.

Bug: 31887729
Test: - Create file "foo" containing 2048 chars = "-"
      - Start "fastboot udp" on device and run
        "fastboot -s udp:$RPI_IP flash boot foo" from host
      - Observe that rpi received 2048 bytes of data, and
        CONFIG_FASTBOOT_BUF_ADDR contains "-"*2048

Change-Id: Ib42378448627b48c629af89f39a0394db93c3824
2017-11-14 10:55:44 +08:00
Jocelyn Bohr 02ad78925c Handle Fastboot packet types, implement getvar.
This patch adds functionality to parse Fastboot packet types, and send
a response to getvar commands.

Bug: 31887729
Test: Responds to getvar commands with correct values for variables
      version, bootloader-version, downloadsize, serialno.

Change-Id: I752a6119d3019745f20defbb1f0c13dba1f24221
2017-11-14 10:55:44 +08:00
Jocelyn Bohr 965eda410b Add support for fastboot command over UDP
The Raspberry Pi does not support USB device mode, so fastboot over
USB does not work. This patch adds support for and partially
implements the device side fastboot UDP protocol as a U-boot command.
It requires an ip address set and ethernet initialized.

- Modify U-boot fastboot command to do fastboot over UDP
- Add net/fastboot.c, which implements fastboot server functions
- Handle QUERY and INIT fastboot packets
- Add CONFIG_UDP_FUNCION_FASTBOOT to enable fastboot over UDP

Bug: 31887729
Test: Tested with fastboot, responds correctly to query and init
      packets.

Change-Id: I4045abaf7a4455d756b7c1c00215afaa90c70a6e
2017-11-14 10:55:44 +08:00