[U-Boot] [PATCH v3 00/10] binman: A tool for creating firmware images

Simon Glass sjg at chromium.org
Wed Oct 5 02:25:30 CEST 2016


This series introduces binman, a tool designed to create firmware images.
It provides a way to bring together various binaries and place them in an
image, at particular positions and with configurable alignment.

Packaging of firmware is quite a different task from building the various
parts. In many cases the various binaries which go into the image come from
separate build systems. For example, ARM Trusted Firmware is used on ARMv8
devices but is not built in the U-Boot tree. If a Linux kernel is included
in the firmware image, it is built elsewhere.

It is of course possible to add more and more build rules to the U-Boot
build system to cover these cases. It can shell out to other Makefiles and
build scripts. But it seems better to create a clear divide between building
software and packaging it.

U-Boot supports a very large number of boards. Many of these have their own
specific rules for how an image should be put together so that it boots
correctly. At present these rules are described by manual instructions,
different for each board. By turning these instructions into a standard
format, we can support making valid images for any board without manual
effort, lots of READMEs, etc.

Images consist of a number of entries which are combined to make up the
final image. The image is described in the device tree for the board, meaning
that it can be accessed at run-time if desired.

Binman is an extensible tool. A set of standard entries is provides, but
new entries can be created fairly easily. Entries can be as simple as
providing the name of a file to include. They can also handle more complex
requirements, such as adjusting the input file or reading header information
from one entry to control the position of another.

U-Boot's mkimage builds FIT images and various other binaries. Binman
augments this by allowing these binaries to be packed together. While FIT
should be used where possible, it cannot be used everywhere. For example,
many devices require executable code at a particular offset in the image.
X86 machines require lots of binary blobs at particular places, and a
microcode collection easily accessible at boot.

So far binman has enough functionality to be useful, but apart from a few RFC
patches, no attempt is made to switch boards over to use it. There should be
enough material to permit review and comments.

The series is available at u-boot-dm/binman-working

Future work and missing features are documented in the README.

Changes in v3:
- Add a new patch to automatically include a U-Boot .dtsi file
- Use a <dts>-u-boot.dtsi file for the binman changes
- Put the binman definition in u-boot.dtsi

Changes in v2:
- Add test for code coverage
- drop the unused __len__() method
- Fix the -b option
- Add automated test coverage
- Various changes and improvements based on using this tool for a while
- Put the binman definition in a common file for x86

Simon Glass (10):
  binman: Introduce binman, a tool for building binary images
  binman: Add basic entry types for U-Boot
  binman: Add support for building x86 ROMs
  binman: Add support for u-boot.img as an input binary
  binman: Add support for building x86 ROMs with SPL
  binman: Add a build rule for binman
  binman: Allow configuration options to be used in .dts files
  binman: Automatically include a U-Boot .dtsi file
  RFC: Use binman for a sunxi board
  RFC: Use binman for an x86 board

 Makefile                                           |  55 +-
 arch/arm/dts/sun7i-a20-pcduino3-u-boot.dtsi        |  14 +
 arch/x86/dts/u-boot.dtsi                           |  62 ++
 scripts/Makefile.lib                               |  20 +-
 tools/binman/.gitignore                            |   1 +
 tools/binman/README                                | 491 +++++++++++++
 tools/binman/binman                                |   1 +
 tools/binman/binman.py                             | 116 ++++
 tools/binman/cmdline.py                            |  53 ++
 tools/binman/control.py                            | 118 ++++
 tools/binman/entry_test.py                         |  27 +
 tools/binman/etype/_testing.py                     |  26 +
 tools/binman/etype/blob.py                         |  37 +
 tools/binman/etype/entry.py                        | 190 +++++
 tools/binman/etype/intel_descriptor.py             |  55 ++
 tools/binman/etype/intel_me.py                     |  17 +
 tools/binman/etype/intel_mrc.py                    |  17 +
 tools/binman/etype/intel_vga.py                    |  17 +
 tools/binman/etype/u_boot.py                       |  17 +
 tools/binman/etype/u_boot_dtb.py                   |  17 +
 tools/binman/etype/u_boot_dtb_with_ucode.py        |  72 ++
 tools/binman/etype/u_boot_img.py                   |  17 +
 tools/binman/etype/u_boot_nodtb.py                 |  17 +
 tools/binman/etype/u_boot_spl.py                   |  17 +
 tools/binman/etype/u_boot_spl_bss_pad.py           |  26 +
 tools/binman/etype/u_boot_spl_with_ucode_ptr.py    |  28 +
 tools/binman/etype/u_boot_ucode.py                 |  77 +++
 tools/binman/etype/u_boot_with_ucode_ptr.py        |  73 ++
 tools/binman/etype/x86_start16.py                  |  17 +
 tools/binman/etype/x86_start16_spl.py              |  17 +
 tools/binman/fdt_test.py                           |  48 ++
 tools/binman/func_test.py                          | 763 +++++++++++++++++++++
 tools/binman/image.py                              | 229 +++++++
 tools/binman/test/01_invalid.dts                   |   5 +
 tools/binman/test/02_missing_node.dts              |   6 +
 tools/binman/test/03_empty.dts                     |   9 +
 tools/binman/test/04_invalid_entry.dts             |  11 +
 tools/binman/test/05_simple.dts                    |  11 +
 tools/binman/test/06_dual_image.dts                |  22 +
 tools/binman/test/07_bad_align.dts                 |  12 +
 tools/binman/test/08_pack.dts                      |  30 +
 tools/binman/test/09_pack_extra.dts                |  35 +
 tools/binman/test/10_pack_align_power2.dts         |  12 +
 tools/binman/test/11_pack_align_size_power2.dts    |  12 +
 tools/binman/test/12_pack_inv_align.dts            |  13 +
 tools/binman/test/13_pack_inv_size_align.dts       |  13 +
 tools/binman/test/14_pack_overlap.dts              |  16 +
 tools/binman/test/15_pack_overflow.dts             |  12 +
 tools/binman/test/16_pack_image_overflow.dts       |  13 +
 tools/binman/test/17_pack_image_size.dts           |  13 +
 tools/binman/test/18_pack_image_align.dts          |  13 +
 tools/binman/test/19_pack_inv_image_align.dts      |  14 +
 .../binman/test/20_pack_inv_image_align_power2.dts |  13 +
 tools/binman/test/21_image_pad.dts                 |  16 +
 tools/binman/test/22_image_name.dts                |  21 +
 tools/binman/test/23_blob.dts                      |  12 +
 tools/binman/test/24_sorted.dts                    |  17 +
 tools/binman/test/25_pack_zero_size.dts            |  15 +
 tools/binman/test/26_pack_u_boot_dtb.dts           |  14 +
 tools/binman/test/27_pack_4gb_no_size.dts          |  18 +
 tools/binman/test/28_pack_4gb_outside.dts          |  19 +
 tools/binman/test/29_x86-rom.dts                   |  19 +
 tools/binman/test/30_x86-rom-me-no-desc.dts        |  15 +
 tools/binman/test/31_x86-rom-me.dts                |  18 +
 tools/binman/test/32_intel-vga.dts                 |  13 +
 tools/binman/test/33_x86-start16.dts               |  13 +
 tools/binman/test/34_x86_ucode.dts                 |  29 +
 tools/binman/test/35_x86_single_ucode.dts          |  26 +
 tools/binman/test/36_u_boot_img.dts                |  11 +
 tools/binman/test/37_x86_no_ucode.dts              |  20 +
 tools/binman/test/38_x86_ucode_missing_node.dts    |  26 +
 tools/binman/test/39_x86_ucode_missing_node2.dts   |  23 +
 tools/binman/test/40_x86_ucode_not_in_image.dts    |  28 +
 tools/binman/test/41_unknown_pos_size.dts          |  11 +
 tools/binman/test/u_boot_no_ucode_ptr              | Bin 0 -> 4182 bytes
 tools/binman/test/u_boot_no_ucode_ptr.c            |  15 +
 tools/binman/test/u_boot_ucode_ptr                 | Bin 0 -> 4175 bytes
 tools/binman/test/u_boot_ucode_ptr.c               |  15 +
 tools/binman/test/u_boot_ucode_ptr.lds             |  18 +
 79 files changed, 3423 insertions(+), 46 deletions(-)
 create mode 100644 arch/arm/dts/sun7i-a20-pcduino3-u-boot.dtsi
 create mode 100644 arch/x86/dts/u-boot.dtsi
 create mode 100644 tools/binman/.gitignore
 create mode 100644 tools/binman/README
 create mode 120000 tools/binman/binman
 create mode 100755 tools/binman/binman.py
 create mode 100644 tools/binman/cmdline.py
 create mode 100644 tools/binman/control.py
 create mode 100644 tools/binman/entry_test.py
 create mode 100644 tools/binman/etype/_testing.py
 create mode 100644 tools/binman/etype/blob.py
 create mode 100644 tools/binman/etype/entry.py
 create mode 100644 tools/binman/etype/intel_descriptor.py
 create mode 100644 tools/binman/etype/intel_me.py
 create mode 100644 tools/binman/etype/intel_mrc.py
 create mode 100644 tools/binman/etype/intel_vga.py
 create mode 100644 tools/binman/etype/u_boot.py
 create mode 100644 tools/binman/etype/u_boot_dtb.py
 create mode 100644 tools/binman/etype/u_boot_dtb_with_ucode.py
 create mode 100644 tools/binman/etype/u_boot_img.py
 create mode 100644 tools/binman/etype/u_boot_nodtb.py
 create mode 100644 tools/binman/etype/u_boot_spl.py
 create mode 100644 tools/binman/etype/u_boot_spl_bss_pad.py
 create mode 100644 tools/binman/etype/u_boot_spl_with_ucode_ptr.py
 create mode 100644 tools/binman/etype/u_boot_ucode.py
 create mode 100644 tools/binman/etype/u_boot_with_ucode_ptr.py
 create mode 100644 tools/binman/etype/x86_start16.py
 create mode 100644 tools/binman/etype/x86_start16_spl.py
 create mode 100644 tools/binman/fdt_test.py
 create mode 100644 tools/binman/func_test.py
 create mode 100644 tools/binman/image.py
 create mode 100644 tools/binman/test/01_invalid.dts
 create mode 100644 tools/binman/test/02_missing_node.dts
 create mode 100644 tools/binman/test/03_empty.dts
 create mode 100644 tools/binman/test/04_invalid_entry.dts
 create mode 100644 tools/binman/test/05_simple.dts
 create mode 100644 tools/binman/test/06_dual_image.dts
 create mode 100644 tools/binman/test/07_bad_align.dts
 create mode 100644 tools/binman/test/08_pack.dts
 create mode 100644 tools/binman/test/09_pack_extra.dts
 create mode 100644 tools/binman/test/10_pack_align_power2.dts
 create mode 100644 tools/binman/test/11_pack_align_size_power2.dts
 create mode 100644 tools/binman/test/12_pack_inv_align.dts
 create mode 100644 tools/binman/test/13_pack_inv_size_align.dts
 create mode 100644 tools/binman/test/14_pack_overlap.dts
 create mode 100644 tools/binman/test/15_pack_overflow.dts
 create mode 100644 tools/binman/test/16_pack_image_overflow.dts
 create mode 100644 tools/binman/test/17_pack_image_size.dts
 create mode 100644 tools/binman/test/18_pack_image_align.dts
 create mode 100644 tools/binman/test/19_pack_inv_image_align.dts
 create mode 100644 tools/binman/test/20_pack_inv_image_align_power2.dts
 create mode 100644 tools/binman/test/21_image_pad.dts
 create mode 100644 tools/binman/test/22_image_name.dts
 create mode 100644 tools/binman/test/23_blob.dts
 create mode 100644 tools/binman/test/24_sorted.dts
 create mode 100644 tools/binman/test/25_pack_zero_size.dts
 create mode 100644 tools/binman/test/26_pack_u_boot_dtb.dts
 create mode 100644 tools/binman/test/27_pack_4gb_no_size.dts
 create mode 100644 tools/binman/test/28_pack_4gb_outside.dts
 create mode 100644 tools/binman/test/29_x86-rom.dts
 create mode 100644 tools/binman/test/30_x86-rom-me-no-desc.dts
 create mode 100644 tools/binman/test/31_x86-rom-me.dts
 create mode 100644 tools/binman/test/32_intel-vga.dts
 create mode 100644 tools/binman/test/33_x86-start16.dts
 create mode 100644 tools/binman/test/34_x86_ucode.dts
 create mode 100644 tools/binman/test/35_x86_single_ucode.dts
 create mode 100644 tools/binman/test/36_u_boot_img.dts
 create mode 100644 tools/binman/test/37_x86_no_ucode.dts
 create mode 100644 tools/binman/test/38_x86_ucode_missing_node.dts
 create mode 100644 tools/binman/test/39_x86_ucode_missing_node2.dts
 create mode 100644 tools/binman/test/40_x86_ucode_not_in_image.dts
 create mode 100644 tools/binman/test/41_unknown_pos_size.dts
 create mode 100755 tools/binman/test/u_boot_no_ucode_ptr
 create mode 100644 tools/binman/test/u_boot_no_ucode_ptr.c
 create mode 100755 tools/binman/test/u_boot_ucode_ptr
 create mode 100644 tools/binman/test/u_boot_ucode_ptr.c
 create mode 100644 tools/binman/test/u_boot_ucode_ptr.lds

-- 
2.8.0.rc3.226.g39d4020



More information about the U-Boot mailing list