binman: A tool for creating firmware images
Subsystems (4)
v2 cover binman: A tool for creating firmware images
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 v2:
- Add a new patch to fix a bug in GetProp()
- Add new patch to adjust GetProps() in fdt_normal to use the node path
- Add a new patch to allow testing of the fallback Fdt library
- 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 (12):
dtoc: Fix bug in GetProp()
dtoc: Adjust GetProps() in fdt_normal to use the node path
dtoc: Add a way for tests to request the fallback library
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
RFC: Use binman for a sunxi board
RFC: Use binman for an x86 board
Makefile | 55 +- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 + arch/x86/dts/binman.dtsi | 62 ++ arch/x86/dts/chromebook_link.dts | 1 + scripts/Makefile.lib | 5 + 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 + tools/dtoc/fdt_fallback.py | 2 +- tools/dtoc/fdt_normal.py | 9 +- tools/dtoc/fdt_select.py | 16 +- 83 files changed, 3425 insertions(+), 55 deletions(-) create mode 100644 arch/x86/dts/binman.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
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 1/12 dtoc: Fix bug in GetProp()
This does not actually call fdtget correctly when requesting a particular type. Fix it.
---
Changes in v2:
- Add a new patch to fix a bug in GetProp()
tools/dtoc/fdt_fallback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/dtoc/fdt_fallback.py +1 -1
@@ -160,7 +160,7 @@ class FdtFallback(Fdt): if default is not None: args += ['-d', str(default)] if typespec is not None: - args += ['-t%s' % typespec] + args += ['-t', typespec] out = command.Output('fdtget', *args) return out.strip()
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 1/12 dtoc: Fix bug in GetProp()
Quoted 11 lines · Simon Glass
This does not actually call fdtget correctly when requesting a particular type. Fix it.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add a new patch to fix a bug inGetProp()tools/dtoc/fdt_fallback.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm
PATCH v2 2/12 dtoc: Adjust GetProps() in fdt_normal to use the node path
In reply to Simon GlassThere is no need to pass a node path separately. Instead we should use the path for the node provided. Correct this.
---
Changes in v2:
- Add new patch to adjust GetProps() in fdt_normal to use the node path
tools/dtoc/fdt_normal.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
tools/dtoc/fdt_normal.py +3 -6
@@ -81,7 +81,7 @@ class Node(NodeBase): This fills in the props and subnodes properties, recursively searching into subnodes so that the entire tree is built. """ - self.props = self._fdt.GetProps(self, self.path) + self.props = self._fdt.GetProps(self) offset = libfdt.fdt_first_subnode(self._fdt.GetFdt(), self.Offset()) while offset >= 0:
@@ -159,7 +159,7 @@ class FdtNormal(Fdt): fdt_len = libfdt.fdt_totalsize(self._fdt) del self._fdt[fdt_len:] - def GetProps(self, node, path): + def GetProps(self, node): """Get all properties from a node. Args:
@@ -172,11 +172,8 @@ class FdtNormal(Fdt): Raises: ValueError: if the node does not exist. """ - offset = libfdt.fdt_path_offset(self._fdt, path) - if offset < 0: - libfdt.Raise(offset) props_dict = {} - poffset = libfdt.fdt_first_property_offset(self._fdt, offset) + poffset = libfdt.fdt_first_property_offset(self._fdt, node._offset) while poffset >= 0: dprop, plen = libfdt.fdt_get_property_by_offset(self._fdt, poffset) prop = Prop(node, poffset, libfdt.String(self._fdt, dprop.nameoff),
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 2/12 dtoc: Adjust GetProps() in fdt_normal to use the node path
Quoted 11 lines · Simon Glass
There is no need to pass a node path separately. Instead we should use the path for the node provided. Correct this.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add new patch to adjustGetProps()infdt_normalto use the node pathtools/dtoc/fdt_normal.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
Applied to u-boot-dm
PATCH v2 3/12 dtoc: Add a way for tests to request the fallback library
In reply to Simon GlassWe need to test both the normal (Python libfdt module) and fallback (fdtget) implementations of the Fdt class. Add a way to select which implementation to use.
---
Changes in v2:
- Add a new patch to allow testing of the fallback Fdt library
tools/dtoc/fdt_select.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
tools/dtoc/fdt_select.py +13 -3
@@ -6,6 +6,8 @@ # SPDX-License-Identifier: GPL-2.0+ # +import fdt_fallback + # Bring in either the normal fdt library (which relies on libfdt) or the # fallback one (which uses fdtget and is slower). Both provide the same # interface for this file to use.
@@ -14,13 +16,21 @@ try: have_libfdt = True except ImportError: have_libfdt = False - import fdt_fallback -def FdtScan(fname): +force_fallback = False + +def FdtScan(fname, _force_fallback=False): """Returns a new Fdt object from the implementation we are using""" - if have_libfdt: + if have_libfdt and not force_fallback and not _force_fallback: dtb = fdt_normal.FdtNormal(fname) else: dtb = fdt_fallback.FdtFallback(fname) dtb.Scan() return dtb + +def UseFallback(fallback): + global force_fallback + + old_val = force_fallback + force_fallback = fallback + return old_val
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 3/12 dtoc: Add a way for tests to request the fallback library
Quoted 4 lines · Simon Glass
We need to test both the normal (Python libfdt module) and fallback (fdtget) implementations of the Fdt class. Add a way to select which implementation to use.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add a new patch to allow testing of the fallback Fdt librarytools/dtoc/fdt_select.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
Applied to u-boot-dm
PATCH v2 4/12 binman: Introduce binman, a tool for building binary images
In reply to Simon GlassThis adds the basic code for binman, including command parsing, processing of entries and generation of images.
So far no entry types are supported. These will be added in future commits as examples of how to add new types.
See the README for documentation.
---
Changes in v2:
- Add test for code coverage
- drop the unused __len__() method
- Fix the -b option
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/etype/entry.py | 190 +++++++++++++++++ tools/binman/fdt_test.py | 48 +++++ tools/binman/image.py | 229 +++++++++++++++++++++ 9 files changed, 1247 insertions(+) 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/etype/entry.py create mode 100644 tools/binman/fdt_test.py create mode 100644 tools/binman/image.py
tools/binman/.gitignore new file +1 -0
@@ -0,0 +1 @@ +*.pyc
tools/binman/README new file +491 -0
491 lines not on this page · raw message
tools/binman/binman new file +1 -0
@@ -0,0 +1 @@ +binman.py
tools/binman/binman.py new file +116 -0
116 lines not on this page · raw message
tools/binman/cmdline.py new file +53 -0
53 lines not on this page · raw message
tools/binman/control.py new file +118 -0
118 lines not on this page · raw message
tools/binman/etype/entry.py new file +190 -0
190 lines not on this page · raw message
tools/binman/fdt_test.py new file +48 -0
48 lines not on this page · raw message
tools/binman/image.py new file +229 -0
229 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 5/12 binman: Add basic entry types for U-Boot
In reply to Simon GlassAdd entries to support some standard U-Boot binaries, such as u-boot.bin, u-boot.dtb, etc. Also add some tests for these.
---
Changes in v2: None
tools/binman/entry_test.py | 27 + tools/binman/etype/_testing.py | 26 + tools/binman/etype/blob.py | 37 ++ tools/binman/etype/u_boot.py | 17 + tools/binman/etype/u_boot_dtb.py | 17 + tools/binman/etype/u_boot_nodtb.py | 17 + tools/binman/etype/u_boot_spl.py | 17 + tools/binman/func_test.py | 542 +++++++++++++++++++++ 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 + 34 files changed, 1080 insertions(+) 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/u_boot.py create mode 100644 tools/binman/etype/u_boot_dtb.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/func_test.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
tools/binman/entry_test.py new file +27 -0
@@ -0,0 +1,27 @@ +# +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Test for the Entry class + +import collections +import unittest + +import entry + +class TestEntry(unittest.TestCase): + def testEntryContents(self): + """Test the Entry bass class""" + base_entry = entry.Entry(None, None, None, read_node=False) + self.assertEqual(True, base_entry.ObtainContents()) + + def testUnknownEntry(self): + """Test that unknown entry types are detected""" + Node = collections.namedtuple('Node', ['name', 'path']) + node = Node('invalid-name', 'invalid-path') + with self.assertRaises(ValueError) as e: + entry.Entry.Create(None, node, node.name) + self.assertIn("Unknown entry type 'invalid-name' in node " + "'invalid-path'", str(e.exception))
tools/binman/etype/_testing.py new file +26 -0
@@ -0,0 +1,26 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for testing purposes. Not used in real images. +# + +from entry import Entry +import fdt_util +import tools + +class Entry__testing(Entry): + def __init__(self, image, etype, node): + Entry.__init__(self, image, etype, node) + + def ObtainContents(self): + self.data = 'a' + self.contents_size = len(self.data) + return True + + def ReadContents(self): + return True + + def GetPositions(self): + return {'invalid-entry': [1, 2]}
tools/binman/etype/blob.py new file +37 -0
@@ -0,0 +1,37 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for blobs, which are binary objects read from files +# + +from entry import Entry +import fdt_util +import tools + +class Entry_blob(Entry): + def __init__(self, image, etype, node): + Entry.__init__(self, image, etype, node) + self._filename = fdt_util.GetString(self._node, "filename", self.etype) + + def ObtainContents(self): + self._filename = self.GetDefaultFilename() + self._pathname = tools.GetInputFilename(self._filename) + self.ReadContents() + return True + + def ReadContents(self): + with open(self._pathname) as fd: + # We assume the data is small enough to fit into memory. If this + # is used for large filesystem image that might not be true. + # In that case, Image.BuildImage() could be adjusted to use a + # new Entry method which can read in chunks. Then we could copy + # the data in chunks and avoid reading it all at once. For now + # this seems like an unnecessary complication. + self.data = fd.read() + self.contents_size = len(self.data) + return True + + def GetDefaultFilename(self): + return self._filename
tools/binman/etype/u_boot.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for U-Boot binary +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'u-boot.bin'
tools/binman/etype/u_boot_dtb.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for U-Boot device tree +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_dtb(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'u-boot.dtb'
tools/binman/etype/u_boot_nodtb.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for 'u-boot-nodtb.bin' +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_nodtb(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'u-boot-nodtb.bin'
tools/binman/etype/u_boot_spl.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for spl/u-boot-spl.bin +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_spl(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'spl/u-boot-spl.bin'
tools/binman/func_test.py new file +542 -0
542 lines not on this page · raw message
tools/binman/test/01_invalid.dts new file +5 -0
@@ -0,0 +1,5 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>;
tools/binman/test/02_missing_node.dts new file +6 -0
@@ -0,0 +1,6 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; +};
tools/binman/test/03_empty.dts new file +9 -0
@@ -0,0 +1,9 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + }; +};
tools/binman/test/04_invalid_entry.dts new file +11 -0
@@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + not-a-valid-type { + }; + }; +};
tools/binman/test/05_simple.dts new file +11 -0
@@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + }; +};
tools/binman/test/06_dual_image.dts new file +22 -0
@@ -0,0 +1,22 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + multiple-images; + image1 { + u-boot { + }; + }; + + image2 { + pad-before = <3>; + pad-after = <5>; + + u-boot { + }; + }; + }; +};
tools/binman/test/07_bad_align.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + align = <23>; + }; + }; +};
tools/binman/test/08_pack.dts new file +30 -0
@@ -0,0 +1,30 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + + u-boot-align { + type = "u-boot"; + align = <16>; + }; + + u-boot-size { + type = "u-boot"; + size = <23>; + }; + + u-boot-next { + type = "u-boot"; + }; + + u-boot-fixed { + type = "u-boot"; + pos = <61>; + }; + }; +};
tools/binman/test/09_pack_extra.dts new file +35 -0
@@ -0,0 +1,35 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + pad-before = <3>; + pad-after = <5>; + }; + + u-boot-align-size-nop { + type = "u-boot"; + align-size = <4>; + }; + + u-boot-align-size { + type = "u-boot"; + align = <16>; + align-size = <32>; + }; + + u-boot-align-end { + type = "u-boot"; + align-end = <64>; + }; + + u-boot-align-both { + type = "u-boot"; + align= <64>; + align-end = <128>; + }; + }; +};
tools/binman/test/10_pack_align_power2.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + align = <5>; + }; + }; +};
tools/binman/test/11_pack_align_size_power2.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + align-size = <55>; + }; + }; +};
tools/binman/test/12_pack_inv_align.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + pos = <5>; + align = <4>; + }; + }; +};
tools/binman/test/13_pack_inv_size_align.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + size = <5>; + align-size = <4>; + }; + }; +};
tools/binman/test/14_pack_overlap.dts new file +16 -0
@@ -0,0 +1,16 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + + u-boot-align { + type = "u-boot"; + pos = <3>; + }; + }; +};
tools/binman/test/15_pack_overflow.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + size = <3>; + }; + }; +};
tools/binman/test/16_pack_image_overflow.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <3>; + + u-boot { + }; + }; +};
tools/binman/test/17_pack_image_size.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <7>; + + u-boot { + }; + }; +};
tools/binman/test/18_pack_image_align.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + align-size = <16>; + + u-boot { + }; + }; +};
tools/binman/test/19_pack_inv_image_align.dts new file +14 -0
@@ -0,0 +1,14 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <7>; + align-size = <8>; + + u-boot { + }; + }; +};
tools/binman/test/20_pack_inv_image_align_power2.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + align-size = <131>; + + u-boot { + }; + }; +};
tools/binman/test/21_image_pad.dts new file +16 -0
@@ -0,0 +1,16 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + pad-byte = <0xff>; + u-boot-spl { + }; + + u-boot { + pos = <12>; + }; + }; +};
tools/binman/test/22_image_name.dts new file +21 -0
@@ -0,0 +1,21 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + multiple-images; + image1 { + filename = "test-name"; + u-boot { + }; + }; + + image2 { + filename = "test-name.xx"; + u-boot { + }; + }; + }; +};
tools/binman/test/23_blob.dts new file +12 -0
@@ -0,0 +1,12 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + blob { + filename = "blobfile"; + }; + }; +};
tools/binman/test/24_sorted.dts new file +17 -0
@@ -0,0 +1,17 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + u-boot { + pos = <10>; + }; + + u-boot-spl { + pos = <5>; + }; + }; +};
tools/binman/test/25_pack_zero_size.dts new file +15 -0
@@ -0,0 +1,15 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot { + }; + + u-boot-spl { + pos = <0>; + }; + }; +};
tools/binman/test/26_pack_u_boot_dtb.dts new file +14 -0
@@ -0,0 +1,14 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot-nodtb { + }; + + u-boot-dtb { + }; + }; +};
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 6/12 binman: Add support for building x86 ROMs
In reply to Simon GlassThe structure of x86 ROMs is pretty complex. There are various binary blobs to place in the image. Microcode requires special handling so that it is available to very early code and can be used without any memory whatsoever.
Add support for the various entry types that are currently needed, along with some tests.
---
Changes in v2: None
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_dtb_with_ucode.py | 72 ++++++++++++++ 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/func_test.py | 145 ++++++++++++++++++++++++++++ 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/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 ++++ 21 files changed, 693 insertions(+) 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_dtb_with_ucode.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/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 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
tools/binman/etype/intel_descriptor.py new file +55 -0
@@ -0,0 +1,55 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for 'u-boot' +# + +import struct + +from entry import Entry +from blob import Entry_blob + +FD_SIGNATURE = struct.pack('<L', 0x0ff0a55a) +MAX_REGIONS = 5 + +(REGION_DESCRIPTOR, REGION_BIOS, REGION_ME, REGION_GBE, + REGION_PDATA) = range(5) + +class Region: + def __init__(self, data, frba, region_num): + pos = frba + region_num * 4 + val = struct.unpack('<L', data[pos:pos + 4])[0] + self.base = (val & 0xfff) << 12 + self.limit = ((val & 0x0fff0000) >> 4) | 0xfff + self.size = self.limit - self.base + 1 + +class Entry_intel_descriptor(Entry_blob): + """Intel flash descriptor block (4KB) + + This is placed at the start of flash and provides information about + the SPI flash regions. In particular it provides the base address and + size of the ME region, allowing us to place the ME binary in the right + place. + """ + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + self._regions = [] + + def GetDefaultFilename(self): + return 'descriptor.bin' + + def GetPositions(self): + pos = self.data.find(FD_SIGNATURE) + if pos == -1: + self.Raise('Cannot find FD signature') + flvalsig, flmap0, flmap1, flmap2 = struct.unpack('<LLLL', + self.data[pos:pos + 16]) + frba = ((flmap0 >> 16) & 0xff) << 4 + for i in range(MAX_REGIONS): + self._regions.append(Region(self.data, frba, i)) + + # Set the offset for ME only, for now, since the others are not used + return {'intel-me': [self._regions[REGION_ME].base, + self._regions[REGION_ME].size]}
tools/binman/etype/intel_me.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for 'u-boot' +# + +from entry import Entry +from blob import Entry_blob + +class Entry_intel_me(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'me.bin'
tools/binman/etype/intel_mrc.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for 'u-boot' +# + +from entry import Entry +from blob import Entry_blob + +class Entry_intel_mrc(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'mrc.bin'
tools/binman/etype/intel_vga.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for 'u-boot' +# + +from entry import Entry +from blob import Entry_blob + +class Entry_intel_vga(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'vga.bin'
tools/binman/etype/u_boot_dtb_with_ucode.py new file +72 -0
72 lines not on this page · raw message
tools/binman/etype/u_boot_ucode.py new file +77 -0
77 lines not on this page · raw message
tools/binman/etype/u_boot_with_ucode_ptr.py new file +73 -0
73 lines not on this page · raw message
tools/binman/etype/x86_start16.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for the 16-bit x86 start-up code for U-Boot +# + +from entry import Entry +from blob import Entry_blob + +class Entry_x86_start16(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'u-boot-x86-16bit.bin'
tools/binman/func_test.py +145 -0
158 lines not on this page · raw message
tools/binman/test/27_pack_4gb_no_size.dts new file +18 -0
@@ -0,0 +1,18 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + u-boot { + pos = <0xfffffff0>; + }; + + u-boot-spl { + pos = <0xfffffff7>; + }; + }; +};
tools/binman/test/28_pack_4gb_outside.dts new file +19 -0
@@ -0,0 +1,19 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <16>; + u-boot { + pos = <0>; + }; + + u-boot-spl { + pos = <0xfffffff7>; + }; + }; +};
tools/binman/test/29_x86-rom.dts new file +19 -0
@@ -0,0 +1,19 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <16>; + u-boot { + pos = <0xfffffff0>; + }; + + u-boot-spl { + pos = <0xfffffff7>; + }; + }; +};
tools/binman/test/30_x86-rom-me-no-desc.dts new file +15 -0
@@ -0,0 +1,15 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <16>; + intel-me { + pos-unset; + }; + }; +};
tools/binman/test/31_x86-rom-me.dts new file +18 -0
@@ -0,0 +1,18 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x800000>; + intel-descriptor { + }; + + intel-me { + pos-unset; + }; + }; +};
tools/binman/test/32_intel-vga.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + intel-vga { + }; + }; +};
tools/binman/test/33_x86-start16.dts new file +13 -0
@@ -0,0 +1,13 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + size = <16>; + + x86-start16 { + }; + }; +};
tools/binman/test/34_x86_ucode.dts new file +29 -0
@@ -0,0 +1,29 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + + u-boot-dtb-with-ucode { + }; + + u-boot-ucode { + }; + }; + + microcode { + update at 0 { + data = <0x12345678 0x12345679>; + }; + update at 1 { + data = <0xabcd0000 0x78235609>; + }; + }; +};
tools/binman/test/35_x86_single_ucode.dts new file +26 -0
@@ -0,0 +1,26 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + + u-boot-dtb-with-ucode { + }; + + u-boot-ucode { + }; + }; + + microcode { + update at 0 { + data = <0x12345678 0x12345679>; + }; + }; +};
tools/binman/test/u_boot_ucode_ptr new file binary +0 -0
zgM)i3QgG0CU(yE=7YE1p!Ew2t at 9xWVH@o|LsZ@#-(v%@sqt7rjSl=(i5rZlmsZoxy zQ9SaF!jM>&I0rHVXMs3_>*wPh=u>4I0zc&NRXVJG0rgz2p&8H&Xa+OngPv#W<WEb z8PE)91~dczzyR*A5=(}qebAw|qP00Wx+^}sOy2XS&mWD8@+0oQG~%t+cBR&_15XAO zLu?77z7|AQ^SWt>h9TCMV?U7?UiPJBvzCKcpQta-m##SW0$~TeGpF8jNCaKqaY=Oj ze&6*ZKlNvnIWxzCEXm}&a5V?u^%8<um|=meT89(@6%cSR#15x>_A>)8o(X9qLQXD z#1~o6OQFqqJIY{<8~_@#DLmzgZrQ+Xi@EVGZrnMRWWNeKSJ|ha`YAi9u{Z4aQjhnG z?c~ddtBklhOXCp#9(;g{)Q?Fq+c>PTU-d6wo4~YvUz*V$GtcEfbjfs-ZCgXv9QLkU KGKbO{NcskUZF7hK
literal 0
HcmV?d00001
tools/binman/test/u_boot_ucode_ptr.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright (c) 2016 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +* +* Simple program to create a _dt_ucode_base_size symbol which can be read +* by 'nm'. This is used by binman tests. +* +* Build with: +* cc -march=i386 -m32 -o u_boot_ucode_ptr -T u_boot_ucode_ptr.lds -nostdlib \ +u_boot_ucode_ptr.c +*/ + +static unsigned long _dt_ucode_base_size[2] + __attribute__((section(".ucode"))) = {1, 2};
tools/binman/test/u_boot_ucode_ptr.lds new file +18 -0
@@ -0,0 +1,18 @@ +/* + * Copyright (c) 2016 Google, Inc + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") +OUTPUT_ARCH(i386) +ENTRY(_start) + +SECTIONS +{ + . = 0xfffffdf0; + _start = .; + .ucode : { + *(.ucode) + } +}
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 7/12 binman: Add support for u-boot.img as an input binary
In reply to Simon GlassAdd an entry type for u-boot.img (a legacy U-Boot image) and a simple test.
---
Changes in v2: None
tools/binman/etype/u_boot_img.py | 17 +++++++++++++++++ tools/binman/func_test.py | 5 +++++ tools/binman/test/36_u_boot_img.dts | 11 +++++++++++ 3 files changed, 33 insertions(+) create mode 100644 tools/binman/etype/u_boot_img.py create mode 100644 tools/binman/test/36_u_boot_img.dts
tools/binman/etype/u_boot_img.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for U-Boot binary +# + +from entry import Entry +from blob import Entry_blob + +class Entry_u_boot_img(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'u-boot.img'
tools/binman/func_test.py +5 -0
@@ -685,3 +685,8 @@ class TestFunctional(unittest.TestCase): first = data[:len(U_BOOT_NODTB_DATA)] self.assertEqual('nodtb with microcode' + pos_and_size + ' somewhere in here', first) + + def testUBootImg(self): + """Test that u-boot.img can be put in a file""" + data = self._DoReadFile('36_u_boot_img.dts') + self.assertEqual(U_BOOT_IMG_DATA, data)
tools/binman/test/36_u_boot_img.dts new file +11 -0
@@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + u-boot-img { + }; + }; +};
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 8/12 binman: Add support for building x86 ROMs with SPL
In reply to Simon GlassWhen building for 64-bit x86 we need an SPL binary in the ROM. Add support for this. Also increase entry test code coverage to 100%.
---
Changes in v2: None
tools/binman/etype/u_boot_spl_bss_pad.py | 26 +++++++++ tools/binman/etype/u_boot_spl_with_ucode_ptr.py | 28 +++++++++ tools/binman/etype/x86_start16_spl.py | 17 ++++++ tools/binman/func_test.py | 71 +++++++++++++++++++++++ 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 +++++ 11 files changed, 265 insertions(+) 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/x86_start16_spl.py 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
tools/binman/etype/u_boot_spl_bss_pad.py new file +26 -0
@@ -0,0 +1,26 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for BSS padding for spl/u-boot-spl.bin. This padding +# can be added after the SPL binary to ensure that anything concatenated +# to it will appear to SPL to be at the end of BSS rather than the start. +# + +import command +from entry import Entry +from blob import Entry_blob +import tools + +class Entry_u_boot_spl_bss_pad(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def ObtainContents(self): + fname = tools.GetInputFilename('spl/u-boot-spl') + args = [['nm', fname], ['grep', '__bss_size']] + out = command.RunPipe(args, capture=True).stdout.splitlines() + bss_size = int(out[0].split()[0], 16) + self.data = chr(0) * bss_size + self.contents_size = bss_size
tools/binman/etype/u_boot_spl_with_ucode_ptr.py new file +28 -0
@@ -0,0 +1,28 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for an SPL binary with an embedded microcode pointer +# + +import struct + +import command +from entry import Entry +from blob import Entry_blob +from u_boot_with_ucode_ptr import Entry_u_boot_with_ucode_ptr +import tools + +class Entry_u_boot_spl_with_ucode_ptr(Entry_u_boot_with_ucode_ptr): + """U-Boot SPL with embedded microcode pointer + + See Entry_u_boot_ucode for full details of the entries involved in this + process. + """ + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + self.elf_fname = 'spl/u-boot-spl' + + def GetDefaultFilename(self): + return 'spl/u-boot-spl.bin'
tools/binman/etype/x86_start16_spl.py new file +17 -0
@@ -0,0 +1,17 @@ +# Copyright (c) 2016 Google, Inc +# Written by Simon Glass <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# +# Entry-type module for the 16-bit x86 start-up code for U-Boot SPL +# + +from entry import Entry +from blob import Entry_blob + +class Entry_x86_start16_spl(Entry_blob): + def __init__(self, image, etype, node): + Entry_blob.__init__(self, image, etype, node) + + def GetDefaultFilename(self): + return 'spl/u-boot-x86-16bit-spl.bin'
tools/binman/func_test.py +71 -0
78 lines not on this page · raw message
tools/binman/test/37_x86_no_ucode.dts new file +20 -0
@@ -0,0 +1,20 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + + u-boot-dtb-with-ucode { + }; + + u-boot-ucode { + }; + }; +};
tools/binman/test/38_x86_ucode_missing_node.dts new file +26 -0
@@ -0,0 +1,26 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + + u-boot-ucode { + }; + }; + + microcode { + update at 0 { + data = <0x12345678 0x12345679>; + }; + update at 1 { + data = <0xabcd0000 0x78235609>; + }; + }; +};
tools/binman/test/39_x86_ucode_missing_node2.dts new file +23 -0
@@ -0,0 +1,23 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + end-at-4gb; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + }; + + microcode { + update at 0 { + data = <0x12345678 0x12345679>; + }; + update at 1 { + data = <0xabcd0000 0x78235609>; + }; + }; +};
tools/binman/test/40_x86_ucode_not_in_image.dts new file +28 -0
@@ -0,0 +1,28 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + sort-by-pos; + size = <0x200>; + u-boot-with-ucode-ptr { + }; + + u-boot-dtb-with-ucode { + }; + + u-boot-ucode { + }; + }; + + microcode { + update at 0 { + data = <0x12345678 0x12345679>; + }; + update at 1 { + data = <0xabcd0000 0x78235609>; + }; + }; +};
tools/binman/test/41_unknown_pos_size.dts new file +11 -0
@@ -0,0 +1,11 @@ +/dts-v1/; + +/ { + #address-cells = <1>; + #size-cells = <1>; + + binman { + _testing { + }; + }; +};
tools/binman/test/u_boot_no_ucode_ptr new file binary +0 -0
zpFw;En;;05iM_7#<+2d5v9R2MkJ<U%oo}nTIXF5 at Bod@0NhyLgc%qheYX at xY_d2~ zpbVua@rie&6fxF02bhC1OPs;=i*XP1$+Hc>51hV9kJT?hJ(n9X3>XFs1BL;^fMLKe zU>GnA7zPXjhJk-z0Q*;tkz&+O8uWhlJbWr0zYHsC1(-IehePl*#DA<*J^uKq2We> zj4WGJg<af^CRX{nY>SdDb~a)^k?3D_Wz%IXd$B&(ry!KRXa|vSqt1m_?06)iR_OU8 zT4A^A2a>P)v#fDuhJp8Cx5S>ApQ*-t5W&D4m^1gKRF3!4c|L2=dAsaDUTGS at 9=oZN zrZL1<80e*?&UyRVV2vCIG~TA=ewpZ&4eYjfH}1ubyTF+3XR))wJ}tVRwr4fwh8=I} z at qDp8do$uXBd$)<SgrCAe1MC@kC)<YW3|P8-9L+IBF7Cw=>(xO84NJ_C$;LPaVgT TQ=i-H%b?z at X6`RW>3;L6WVxU
literal 0
HcmV?d00001
tools/binman/test/u_boot_no_ucode_ptr.c new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright (c) 2016 Google, Inc +* +* SPDX-License-Identifier: GPL-2.0+ +* +* Simple program to create a bad _dt_ucode_base_size symbol to create an +* error when it is used. This is used by binman tests. +* +* Build with: +* cc -march=i386 -m32 -o u_boot_no_ucode_ptr -T u_boot_ucode_ptr.lds \ +-nostdlib u_boot_no_ucode_ptr.c +*/ + +static unsigned long not__dt_ucode_base_size[2] + __attribute__((section(".ucode"))) = {1, 2};
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 9/12 binman: Add a build rule for binman
In reply to Simon GlassAdd a standard command definition for binman so that it can be used in makefiles.
---
Changes in v2: None
Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
Makefile +6 -0
@@ -889,6 +889,12 @@ u-boot.ldr: u-boot $(LDR) -T $(CONFIG_CPU) -c $@ $< $(LDR_FLAGS) $(BOARD_SIZE_CHECK) +# binman +# --------------------------------------------------------------------------- +quiet_cmd_binman = BINMAN $@ +cmd_binman = $(srctree)/tools/binman/binman -d u-boot.dtb -O . \ + -I . -I $(srctree)/board/$(BOARDDIR) $< + OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 10/12 binman: Allow configuration options to be used in .dts files
In reply to Simon GlassIt is sometimes useful to be able to reference configuration options in a device tree source file. Add the necessary includes so that this works.
---
Changes in v2: None
scripts/Makefile.lib | 5 +++++ 1 file changed, 5 insertions(+)
scripts/Makefile.lib +5 -0
@@ -168,6 +168,11 @@ ld_flags = $(LDFLAGS) $(ldflags-y) dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \ -I$(srctree)/arch/$(ARCH)/dts \ -I$(srctree)/arch/$(ARCH)/dts/include \ + -Iinclude \ + -I$(srctree)/include \ + -I$(srctree)/arch/$(ARCH)/include \ + -include $(srctree)/include/linux/kconfig.h \ + -D__ASSEMBLY__ \ -undef -D__DTS__ # Finds the multi-part object the current object will be linked into
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 11/12 RFC: Use binman for a sunxi board
In reply to Simon GlassAdd an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the Makefile.
This is for example only.
---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-)
Makefile +1 -3
@@ -1121,10 +1121,8 @@ u-boot-x86-16bit.bin: u-boot FORCE endif ifneq ($(CONFIG_SUNXI),) -OBJCOPYFLAGS_u-boot-sunxi-with-spl.bin = -I binary -O binary \ - --pad-to=$(CONFIG_SPL_PAD_TO) --gap-fill=0xff u-boot-sunxi-with-spl.bin: spl/sunxi-spl.bin u-boot.img FORCE - $(call if_changed,pad_cat) + $(call if_changed,binman) endif ifneq ($(CONFIG_TEGRA),)
arch/arm/dts/sun7i-a20-pcduino3.dts +12 -0
@@ -42,6 +42,7 @@ */ /dts-v1/; +#include <config.h> #include "sun7i-a20.dtsi" #include "sunxi-common-regulators.dtsi"
@@ -62,6 +63,17 @@ stdout-path = "serial0:115200n8"; }; + binman { + filename = "u-boot-sunxi-with-spl.bin"; + pad-byte = <0xff>; + blob { + filename = "spl/sunxi-spl.bin"; + }; + u-boot-img { + pos = <CONFIG_SPL_PAD_TO>; + }; + }; + leds { compatible = "gpio-leds"; pinctrl-names = "default";
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH v2 11/12 RFC: Use binman for a sunxi board
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ? u-boot.dtsi exists add in -include that/file.dtsi to the CPP rule so that we can keep the parts that will never get upstream separate.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160927/9871ffb7/attachment.sig>
PATCH v2 11/12 RFC: Use binman for a sunxi board
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++
Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.
We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
Regards,
Simon
PATCH v2 11/12 RFC: Use binman for a sunxi board
Quoted 27 lines · Simon Glass
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.
Quoted 7 lines
We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
I'd really like to try and better solve the generic problem we have tho too while we're at it. ie the u-boot,dm-pre-reloc tag on various nodes could also go into this file.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161001/de966193/attachment.sig>
PATCH v2 11/12 RFC: Use binman for a sunxi board
Hi Tom,
Quoted 32 lines · Tom Rini
Quoted 31 lines · Simon Glass
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
Quoted 7 lines
Quoted 3 lines
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
I'd really like to try and better solve the generic problem we have tho too while we're at it. ie the u-boot,dm-pre-reloc tag on various nodes could also go into this file.
What sort of solution are you thinking of? A U-Boot .dtsi include that is #included at the top of all files?
Regards,
Simon
PATCH v2 11/12 RFC: Use binman for a sunxi board
Quoted 39 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
Quoted 6 lines
Quoted 3 lines
I'd really like to try and better solve the generic problem we have tho too while we're at it. ie the u-boot,dm-pre-reloc tag on various nodes could also go into this file.
What sort of solution are you thinking of? A U-Boot .dtsi include that is #included at the top of all files?
Something like:
ifneq ($(wildcard $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi),) dtc_cpp_flags += -include $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi endif
And maybe a few other wildcards, I'm not sure, so that for everything rockchip related, ie what binman needs, what nodes need to be pre-reloc, etc, can end up in that one file. And we use -include to get it so that arch/arm/dts/ can be unmodified from upstream.
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161001/126726df/attachment.sig>
PATCH v2 11/12 RFC: Use binman for a sunxi board
Hi Tom,
Quoted 53 lines · Tom Rini
Quoted 39 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
Quoted 6 lines
Quoted 3 lines
I'd really like to try and better solve the generic problem we have tho too while we're at it. ie the u-boot,dm-pre-reloc tag on various nodes could also go into this file.
What sort of solution are you thinking of? A U-Boot .dtsi include that is #included at the top of all files?
Something like:
ifneq ($(wildcard $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi),)dtc_cpp_flags+= -include $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi endif
Quoted 4 lines
And maybe a few other wildcards, I'm not sure, so that for everything rockchip related, ie what binman needs, what nodes need to be pre-reloc, etc, can end up in that one file. And we use -include to get it so that
arch/arm/dts/can be unmodified from upstream.
OK, I was worried that's what you might mean :-)
I'll take a look.
Regards.
Simon
PATCH v2 11/12 RFC: Use binman for a sunxi board
Hi Tom,
Quoted 56 lines · Simon Glass
Hi Tom,
Quoted 53 lines · Tom Rini
Quoted 39 lines · Simon Glass
Hi Tom,
Quoted 36 lines · Tom Rini
Quoted 34 lines · Simon Glass
Hi Tom,
Quoted 15 lines · Tom Rini
Quoted 5 lines · Simon Glass
Add an example usage of binman for a sunxi board. This involves adding the image definition to the device tree and using it in the
Makefile.This is for example only.
Quoted 7 lines
Signed-off-by Simon Glass <[email protected]>---
Changes in v2: None
Makefile | 4 +--- arch/arm/dts/sun7i-a20-pcduino3.dts | 12 ++++++++++++Quoted 8 lines
I think this shows the big problem with using binman today. For the common case of ARM, where we sync in the dts* files from upstream, this will add hunks that must not be overwritten each time.
Looking at scripts/Makefile.lib::cmd_fdt I wonder if we couldn't come up with some wildcard rule and check if, somewhere CONFIG'd ? $(BOARDDIR)/ ?
u-boot.dtsiexists add in -includethat/file.dtsito the CPP rule so that we can keep the parts that will never get upstream separate.We can do that, but I have found that most boards with the same SoC are the same, or similar. So for x86 [1] I put it in a separate patch with just an #include in the .dts file.
We could have binman be a bit smarter about where it looks - e.g. if there is no binman node, it could look in the same directory for a file that matches the board name, or part of it?
Quoted 6 lines
Quoted 3 lines
I'd really like to try and better solve the generic problem we have tho too while we're at it. ie the u-boot,dm-pre-reloc tag on various nodes could also go into this file.
What sort of solution are you thinking of? A U-Boot .dtsi include that is #included at the top of all files?
Something like:
ifneq ($(wildcard $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi),)dtc_cpp_flags+= -include $(srctree)/arch/$(CONFIG_SYS_ARCH)/cpu/$(CONFIG_SYS_CPU)/$(CONFIG_SYS_SOC)/u-boot.dtsi endif
Quoted 8 lines
Quoted 4 lines
And maybe a few other wildcards, I'm not sure, so that for everything rockchip related, ie what binman needs, what nodes need to be pre-reloc, etc, can end up in that one file. And we use -include to get it so that
arch/arm/dts/can be unmodified from upstream.OK, I was worried that's what you might mean :-)
I'll take a look.
I've sent v3 with something along these lines. I could not use -include because I need to avoid having the .dts version header appear twice. So it has a little 'sed' in it...
Regards,
Simon
PATCH v2 12/12 RFC: Use binman for an x86 board
In reply to Simon GlassAdd an example usage of binman for an x86 board. This involves adding the image definition to the device tree and using it in the Makefile. The existing ifdtool features are no-longer needed.
This is for example only. Note that the binman.dtsi file is common and could be used for all x86 boards. However, FSP support is missing.
---
Changes in v2:
- 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
Makefile | 45 ++--------------------------- arch/x86/dts/binman.dtsi | 62 ++++++++++++++++++++++++++++++++++++++++ arch/x86/dts/chromebook_link.dts | 1 + 3 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 arch/x86/dts/binman.dtsi
Makefile +3 -42
@@ -1060,50 +1060,11 @@ endif # x86 uses a large ROM. We fill it with 0xff, put the 16-bit stuff (including # reset vector) at the top, Intel ME descriptor at the bottom, and U-Boot in -# the middle. +# the middle. This is handled by binman based on an image description in the +# board's device tree. ifneq ($(CONFIG_X86_RESET_VECTOR),) rom: u-boot.rom FORCE -IFDTOOL=$(objtree)/tools/ifdtool -IFDTOOL_FLAGS = -f 0:$(objtree)/u-boot.dtb -IFDTOOL_FLAGS += -m 0x$(shell $(NM) u-boot |grep _dt_ucode_base_size |cut -d' ' -f1) -IFDTOOL_FLAGS += -U $(CONFIG_SYS_TEXT_BASE):$(objtree)/u-boot-nodtb.bin -IFDTOOL_FLAGS += -w $(CONFIG_SYS_X86_START16):$(objtree)/u-boot-x86-16bit.bin -IFDTOOL_FLAGS += -C - -ifneq ($(CONFIG_HAVE_INTEL_ME),) -IFDTOOL_ME_FLAGS = -D $(srctree)/board/$(BOARDDIR)/descriptor.bin -IFDTOOL_ME_FLAGS += -i ME:$(srctree)/board/$(BOARDDIR)/me.bin -endif - -ifneq ($(CONFIG_HAVE_MRC),) -IFDTOOL_FLAGS += -w $(CONFIG_X86_MRC_ADDR):$(srctree)/board/$(BOARDDIR)/mrc.bin -endif - -ifneq ($(CONFIG_HAVE_FSP),) -IFDTOOL_FLAGS += -w $(CONFIG_FSP_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_FSP_FILE) -endif - -ifneq ($(CONFIG_HAVE_CMC),) -IFDTOOL_FLAGS += -w $(CONFIG_CMC_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_CMC_FILE) -endif - -ifneq ($(CONFIG_HAVE_VGA_BIOS),) -IFDTOOL_FLAGS += -w $(CONFIG_VGA_BIOS_ADDR):$(srctree)/board/$(BOARDDIR)/$(CONFIG_VGA_BIOS_FILE) -endif - -ifneq ($(CONFIG_HAVE_REFCODE),) -IFDTOOL_FLAGS += -w $(CONFIG_X86_REFCODE_ADDR):refcode.bin -endif - -quiet_cmd_ifdtool = IFDTOOL $@ -cmd_ifdtool = $(IFDTOOL) -c -r $(CONFIG_ROM_SIZE) u-boot.tmp; -ifneq ($(CONFIG_HAVE_INTEL_ME),) -cmd_ifdtool += $(IFDTOOL) $(IFDTOOL_ME_FLAGS) u-boot.tmp; -endif -cmd_ifdtool += $(IFDTOOL) $(IFDTOOL_FLAGS) u-boot.tmp; -cmd_ifdtool += mv u-boot.tmp $@ - refcode.bin: $(srctree)/board/$(BOARDDIR)/refcode.bin FORCE $(call if_changed,copy)
@@ -1113,7 +1074,7 @@ cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \ u-boot.rom: u-boot-x86-16bit.bin u-boot.bin FORCE \ $(if $(CONFIG_HAVE_REFCODE),refcode.bin) - $(call if_changed,ifdtool) + $(call if_changed,binman) OBJCOPYFLAGS_u-boot-x86-16bit.bin := -O binary -j .start16 -j .resetvec u-boot-x86-16bit.bin: u-boot FORCE
arch/x86/dts/binman.dtsi new file +62 -0
62 lines not on this page · raw message
arch/x86/dts/chromebook_link.dts +1 -0
@@ -1,6 +1,7 @@ /dts-v1/; #include <dt-bindings/gpio/x86-gpio.h> +#include "binman.dtsi" /include/ "skeleton.dtsi" /include/ "keyboard.dtsi"
Signature · 1 line
2.8.0.rc3.226.g39d4020