[U-Boot] [RFC PATCH v2 0/8] GPT over MTD

Patrick Delaunay patrick.delaunay73 at gmail.com
Wed Nov 30 12:01:20 CET 2016


I have a request to support GPT over MTD to be able to have dynamic
MTD informations without U-Boot environment(CONFIG_ENV_IS_NOWHERE
is a other requirement of my project).

The idea is to use the GPT header to save partitioning information directly
in flash device (NOR or NAND), then the MTD variables are rebuild from
these GPT partitions and can be used by DISTRO to search bootable binary.

I make a first prototyping for this request but I want ask you if this
feature is acceptable for U-Boot and if this patches, after some update
and cleanups, would be merged in U-Boot mainline.
Do you see already some blocking points ?

- added code is under a new CONFIG : CONFIG_EFI_PARTITION_MTD
- for implementation details, see doc/README.gpt.mtd

TODO:
- full support for modified command
  today I limit the support for the command used by DISTRO macro:
  + gpt write
  + part list
- DISTRO macro update for automatic boot on GPT bootable partition
  found in MTD devices

the current level is tested manually on sandbox with :

> make O=sandbox
> sandbox/u-boot -d sandbox/arch/sandbox/dts/test.dtb

=> sf probe
SF: Detected M25P16 with page size 256 Bytes, erase size 64 KiB, total 2 MiB

=> setenv nor_part "name=part1,size=64KiB;name=part2,size=128KiB;\
   name=boot,type=linux,bootable,size=512KiB"
=> gpt write nor 0 $nor_part
Writing GPT: success!

=> part list nor 0
Part	Start LBA	End LBA		Name
	Attributes
	Type GUID
	Partition GUID
  1	0x00000080	0x000000ff	"part1"
	attrs:	0x0000000000000000
	type:	ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
	type:	data
	guid:	d117f98e-6f2c-0040-00b2-331a19f91cb2
  2	0x00000100	0x000001ff	"part2"
	attrs:	0x0000000000000000
	type:	ebd0a0a2-b9e5-4433-87c0-68b6b72699c7
	type:	data
	guid:	25718777-d0ad-0000-8060-02cb591c9737
  3	0x00000200	0x000005ff	"boot"
	attrs:	0x0000000000000004
	type:	0fc63daf-8483-4772-8e79-3d69d8477de4
	type:	linux
	guid:	8a4bb8b4-e304-0040-0036-aff5c9c495b1

=> setenv mtdids "nor0=nor0"
=> setenv mtdparts "mtdparts="
=> mtdparts gpt nor0
=> mtdparts
device nor0 <nor0>, # parts = 3
 #: name		size		offset		mask_flags
 0: part1               0x00010000	0x00010000	0
 1: part2               0x00020000	0x00020000	0
 2: boot                0x00080000	0x00040000	0

active partition: nor0,0 - (part1) 0x00010000 @ 0x00010000

defaults:
mtdids  : none
mtdparts: none

=> part list nor 0 -bootable nor_boot_part
=> printenv nor_boot_part
nor_boot_part=3


test filtering feature (can be used to mask some partitions to linux
according the GUID)
1/ only add MTD for some guid = linux
2/ then add MTD for some guid = data

=> mtdparts delall
=> setenv mtdparts "mtdparts="
=> setenv mtdids "nor0=nor0"
=> mtdparts gpt nor0 linux
=> mtdparts

device nor0 <nor0>, # parts = 1
 #: name		size		offset		mask_flags
 0: boot                0x00080000	0x00040000	0

active partition: nor0,0 - (boot) 0x00080000 @ 0x00040000

defaults:
mtdids  : none
mtdparts: none

=> mtdparts gpt nor0 data
=> mtdparts

device nor0 <nor0>, # parts = 3
 #: name		size		offset		mask_flags
 0: part1               0x00010000	0x00010000	0
 1: part2               0x00020000	0x00020000	0
 2: boot                0x00080000	0x00040000	0

active partition: nor0,2 - (boot) 0x00080000 @ 0x00040000

defaults:
mtdids  : none
mtdparts: none


Changes in v2:
- split serie to reduce patches size
  (seperate disk part and cmd impact and add precursor patch)
- split large function

Patrick Delaunay (8):
  uuid: add function for GUID string parsing
  disk: part: refactor to prepare GPT over MTD
  disk: part: add support of GPT partitioning over MTD
  cmd: gpt: update command to support GPT over MTD
  cmd: part: update command to support GPT over MTD
  cmd: mtdparts: update command to support GPT over MTD
  uuid: remove dependency with io.h
  sandbox: GPT over MTD test

 Kconfig                   |  12 +
 cmd/gpt.c                 |  98 ++++++--
 cmd/mtdparts.c            | 121 +++++++++-
 cmd/part.c                |  48 +++-
 configs/sandbox_defconfig |   2 +
 disk/part_efi.c           | 560 +++++++++++++++++++++++++++++++++++++++++-----
 doc/README.gpt.mtd        | 189 ++++++++++++++++
 include/configs/sandbox.h |   7 +
 include/part.h            |  13 +-
 include/uuid.h            |   1 +
 lib/uuid.c                |  46 +++-
 11 files changed, 1011 insertions(+), 86 deletions(-)
 create mode 100644 doc/README.gpt.mtd

-- 
1.9.1



More information about the U-Boot mailing list