Skip to content

fastboot: block: Add GPT/MBR and device selection

Balaji Selvanathan u-boot 3 versions – In review

Get series with b4
b4 am [email protected] change-id 20260410-fb_block-14f90c7d6b37

Versions newest first

  1. v3 Latest6 patches 11 repliesIn review
  2. v24 patches 5 repliesSuperseded inferred link
  3. v12 patches 2 repliesSuperseded

Changes in v3 from the cover letter

- Rebase on master, which now has SPL fastboot support
- Split the blk_get_dev() NULL check fix into its own patch
- Use '#' to select a partition by name, as the rest of the disk layer
does, and reuse part_get_info_by_dev_and_name_or_num() instead of a
local parser. This also fixes "foo:boot" being taken as device 0
- Pass a block descriptor to the GPT/MBR helpers, so fb_mmc.c keeps
its DEV_TYPE_UNKNOWN check, and share the validate/write code between
them. Move them to fb_block.c
- Check the interface name and the device prefix in the block caller,
and report an invalid prefix instead of ignoring it
- Add a sandbox test for the partition table target lookup
- Doc: use sentence case headings, cut the duplicated GPT/MBR text down
to one example and mention erase and partition-size
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6fastboot: block: Fix NULL check on blk_get_dev() resultdrivers/fastboot/fb_block.c+1 -11 reply
2/6fastboot: block: Add device selection syntaxdrivers/fastboot/fb_block.c include/fb_block.h+12 -42 replies
3/6fastboot: Add GPT/MBR partition table flashing helper functionsdrivers/fastboot/fb_block.c drivers/fastboot/fb_mmc.c include/fb_block.h+96 -392 replies
4/6fastboot: block: Add GPT/MBR partition table flashing supportdrivers/fastboot/Kconfig drivers/fastboot/fb_block.c include/fb_block.h+100 -82 replies
5/6test: fastboot: Add test for block partition table targetstest/dm/fastboot.c+61 -02 replies
6/6doc: fastboot: Document block device selection syntaxdoc/android/fastboot.rst+32 -02 replies

Reviews trailers per patch

4 of 6 patches have a Reviewed-by or Acked-by.

PatchGuillaume La Roque
1/6R-b
2/6R-b
3/6R-b
4/6R-b
5/6
6/6

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCH v3 0/6] fastboot: block: Add GPT/MBR and device selection

This series adds GPT and MBR partition table flashing to the fastboot block backend and lets the host select which device on the configured interface to use. For example, with FASTBOOT_FLASH_BLOCK:

  fastboot flash gpt gpt.img        # GPT on the default device
  fastboot flash 1#gpt gpt.img      # GPT on device 1
  fastboot flash 1#mbr mbr.img      # MBR on device 1
  fastboot flash 1#boot boot.img    # partition "boot" on device 1
  fastboot erase 1:3                # partition 3 on device 1

A name without a device prefix, such as "fastboot flash boot boot.img", works as before with CONFIG_FASTBOOT_FLASH_BLOCK_DEVICE_ID.

---
Changes in v3:
- Rebase on master, which now has SPL fastboot support
- Split the blk_get_dev() NULL check fix into its own patch
- Use '#' to select a partition by name, as the rest of the disk layer
does, and reuse part_get_info_by_dev_and_name_or_num() instead of a
local parser. This also fixes "foo:boot" being taken as device 0
- Pass a block descriptor to the GPT/MBR helpers, so fb_mmc.c keeps
its DEV_TYPE_UNKNOWN check, and share the validate/write code between
them. Move them to fb_block.c
- Check the interface name and the device prefix in the block caller,
and report an invalid prefix instead of ignoring it
- Add a sandbox test for the partition table target lookup
- Doc: use sentence case headings, cut the duplicated GPT/MBR text down
to one example and mention erase and partition-size
- Link to v2: https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Separate adding device selection syntax and GPT/MBR flashing support
into separate patches.
- Introduce common helper functions such as
fastboot_flash_gpt_partition_table and
fastboot_flash_mbr_partition_table functions that can be used both
in fb_mmc.c and fb_block.c for GPT and MBR flashing.
- Link to v1: https://lore.kernel.org/u-boot/[email protected]/

---
Balaji Selvanathan (6):
fastboot: block: Fix NULL check on blk_get_dev() result
fastboot: block: Add device selection syntax
fastboot: Add GPT/MBR partition table flashing helper functions
fastboot: block: Add GPT/MBR partition table flashing support
test: fastboot: Add test for block partition table targets
doc: fastboot: Document block device selection syntax

 doc/android/fastboot.rst    |  32 +++++++++
 drivers/fastboot/Kconfig    |   4 +-
 drivers/fastboot/fb_block.c | 158 +++++++++++++++++++++++++++++++++++++++++---
 drivers/fastboot/fb_mmc.c   |  45 ++-----------
 include/fb_block.h          |  52 +++++++++++++++
 test/dm/fastboot.c          |  61 +++++++++++++++++
 6 files changed, 301 insertions(+), 51 deletions(-)

---
base-commit: 6487c50b8a40f2668ab98a892b9300ad5c181f38
change-id: 20260427-fb_gpt-86d7d6595dad

Best regards,

Signature · 1 line
Balaji Selvanathan <[email protected]>