Commit graph

392 commits

Author SHA1 Message Date
Jiaxun Yang
06a0d9eee8 binman: Workaround lz4 cli padding in test cases
Newer lz4 util is not happy with any padding at end of file,
it would abort with error message like:

Stream followed by undecodable data at position 43.

Workaround by skipping testCompUtilPadding test case and manually
strip padding in testCompressSectionSize test case.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
2025-04-11 14:29:52 -06:00
Neha Malcom Francis
42ce9ed7ff tools: binman: control.py: Delete template nodes after parsing
Dynamically going through the subnode array and deleting leads to
templates being skipped from deletion when templates are consecutive in
the subnode list. Prevent this from happening by first parsing the DT
and then deleting the nodes. Add a testcase as well for this cornercase.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
2025-04-03 11:37:45 -06:00
Tom Rini
1b42f57ec8 Prepare v2025.04-rc4
-----BEGIN PGP SIGNATURE-----
 
 iQGzBAABCgAdFiEEGjx/cOCPqxcHgJu/FHw5/5Y0tywFAmfPdnYACgkQFHw5/5Y0
 tyw17wv+KqFxDoJKTGVWeP4fu+zhTQlFo0f2tAlWylAdJnDP6nR/I49zid2mjRbZ
 2Bq3mE3G2Ag1efJ3UGHck0Zn1O9OpqVvk734IHSJFygN77l2xmNSMXZd8MLOsbaU
 4JXhxbLUdumCSkwVjjc9/sN+kJUfpwmFBwjqPWmE8rVU+IjApdZP0hBmfxACivl3
 p0JJZ870JkgSd5KuAGO/MUbinl/QYOdpitbo2EinOyqnLnivw5PzlcAYF0STNcgJ
 XfsT7Ap9T3woPTkT1mXGo+0gBs1OPxXcXp6nywFY75EVIGYRetDEXr8/jf74Jg83
 XK8+mqFP+bhlLOMydCdRHyQU8+WGNPfWtcOa7ekC3DjR9Kf7VwoTujqa9B9ILg6m
 UBagI/zUIWGAHi4oe2vMV16nR1cPT1ZexPoswZJrj/iDC6WaN0gWwDQgcPODm0UL
 rPYYNPWne/iGYgbkhy1zqZMEj7ytnvtjaVMRFdbTSwWUR3s23q9btqjlOwfXbtYZ
 0ENfAAu0
 =xGcd
 -----END PGP SIGNATURE-----

Merge tag 'v2025.04-rc4' into next

This uses Heinrich's merge of lib/efi_loader/efi_net.c which results in
no changes.
2025-03-10 20:18:51 -06:00
Tom Rini
986ab810fa Merge patch series "tools: Minor clean-ups for the command library"
Simon Glass <sjg@chromium.org> says:

This series adds comments and fixes pylint warnings in the command
library. It also introduces a new, simpler way of running a single
command.

Link: https://lore.kernel.org/r/20250203162704.627469-1-sjg@chromium.org
2025-03-04 13:32:15 -06:00
Simon Glass
3d094ce28a u_boot_pylib: Add a function to run a single command
Add a helper to avoid needing to use a list within a list for this
simple case.

Update existing users of runpipe() to use this where possible.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 13:31:49 -06:00
Simon Glass
d6900a778a u_boot_pylib: Correct case for test_result
This should be in capitals and defined at the start of the file. Update
it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 13:31:49 -06:00
Simon Glass
2c252d36b8 binman: Honour the skip-at-start property more faithfully
A discussion on the mailing list about dealing with block offsets and
binman symbols made me think that something is wrong with how Binman
deals with the skip-at-start property.

The feature was originally designed to handle x86 ROMs, which are mapped
at the top of the address space. That seemed too specific, whereas
skipping some space at the start seemed more generally useful.

It has proved useful. For example, rockchip images start at block 64,
so a skip-at-start of 0x8000 deals with this.

But it doesn't actually work correctly, since the image_pos value does
not give the actual position on the media.

Fix this and update the documentation, moving it into the 'section'
section.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 08:22:11 -06:00
Tom Rini
5bc4240eb6 Merge patch series "rsa: Add rsa_verify_openssl() to use openssl for host builds"
Paul HENRYS <paul.henrys_ext@softathome.com> says:

This serie of patches adds a new tool to authenticate files signed with
a preload header.  This tool is also used in the tests to actually
verify the authenticity of the file signed with such a preload header.

Link: https://lore.kernel.org/r/20250224212055.2992852-1-paul.henrys_ext@softathome.com
2025-02-28 16:51:10 -06:00
Paul HENRYS
b9b87d01ef binman: Authenticate the image when testing the preload signature
Use preload_check_sign to authenticate the generated image when testing the
preload signature in testPreLoad().

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-28 16:51:01 -06:00
Tom Rini
523a56cc54 Revert "Merge patch series "Add preload_check_sign tool""
This reverts commit c8750efe02, reversing
changes made to 8c6cf8aeea.

Unfortunately these changes do not build on macOS hosts.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-24 10:32:04 -06:00
Tom Rini
c8750efe02 Merge patch series "Add preload_check_sign tool"
Paul HENRYS <paul.henrys_ext@softathome.com> says:

This serie of patches adds a new tool to authenticate files signed
with a preload header.
This tool is also used in the tests to actually verify the
authenticity of the file signed with such a preload header.

Link: https://lore.kernel.org/r/20250212093126.3722186-1-paul.henrys_ext@softathome.com
2025-02-21 11:37:27 -06:00
Paul HENRYS
a9842ac634 binman: Authenticate the image when testing the preload signature
Use preload_check_sign to authenticate the generated image when testing the
preload signature in testPreLoad().

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-21 08:34:21 -06:00
Simon Glass
6e628c221e tools: Fix pylint 3.3.4 errors
This newer pylint produces errors about variables possibly being used
before being set. Adjust the code to pass these checks.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
2025-02-21 08:24:37 -06:00
Paul HENRYS
e7d7d3307c tools: binman: etype: fit: Append DTB directory to the list of input directories
When specifying a directory containing DTBs with 'fit,fdt-list-dir', it can be
handy not to have to also specify this directory to the input directories of
binman with '-I' option and use the method tools.append_input_dirs() append it.
This avoids to have to specify the DTB directory in both the device tree
provided to binman and through '-I' option to binman.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-19 09:10:34 -06:00
Paul HENRYS
a4345b1934 tools: binman: etype: Allow to replace 'NAME' in node names
This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a
sequence number and the name of the FDT to provide more flexibility in the node
name for the device trees included in the FIT.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-12-19 09:10:34 -06:00
Paul HENRYS
1a957ff5d4 tools: binman: Add tests for FIT with data encrypted by mkimage
Test the property 'fit,encrypt' to encrypt FIT data.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2024-12-19 09:10:34 -06:00
Alexander Kochetkov
133c000ca3 binman: implement signing FIT images during image build
The patch implement new property 'fit,sign' that can be declared
at the top-level 'fit' node. If that option is declared, fit tryies
to detect private keys directory among binman include directories.
That directory than passed to mkimage using '-k' flag and that enable
signing of FIT.

Signed-off-by: Alexander Kochetkov <al.kochet@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Renumbered files, moved new tests to end:
Signed-off-by: Simon Glass <sjg@chromium.org>
2024-10-18 14:10:22 -06:00
Simon Glass
ac0876c890 binman: Make a start on an iMX8 test
This patch is for Marek, to provide a starting point.

To try it, use 'binman test -T' and see the missing coverage.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:31 +02:00
Simon Glass
a96dda1a70 binman: Allow image_pos to be None when writing symbols
Some images do not have an image_pos value, for example an image which
is part of a compressed section and therefore cannot be accessed
directly.

Handle this case, returning None as the value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Simon Glass
bce055338e binman: Provide a way to set the symbol base address
The base address of the ELF containing symbols is normally added to
any symbols written, so that the value points to the correct address in
memory when everything is loaded. When the binary resides on disk, a
different offset may be needed, typically 0. Provide a way to specify
this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Simon Glass
01a609930b binman: Add minor improvements to symbol-writing
Add a clarification to the documentation and add a missing comment. Also
update the test so that when it fails it is easier to see what is going
on, rather than having to decode hex strings.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Simon Glass
c8b7d72b43 binman: fit: Refine handling of devicetrees for OF_UPSTREAM
With OF_UPSTREAM the dts files are in an SoC-specific subdirectory,
meaning that the resulting dtb files all end up in a similar
subdirectory.

We don't want the subdirectory name to appear as a node name in the FIT,
so handle this as a special case.

Also the default devicetree may have a directory-name prefix, so handle
that when searching through the available devicetree files.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Simon Glass
52983ff54b binman: Update fdt-list-dir to use the provided directory
Since the files are known to be in the provided directory, use that
instead of requiring it to be added to the list of input directories.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Simon Glass
7d77ad9061 binman: Fix up test coverage for mkeficapsule
Add tests for missing tools to complete the test coverage for this
etype.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-09-26 12:40:30 +02:00
Caleb Connolly
2bf0a87ae3 sandbox: switch to dynamic UUIDs
Migrate sandbox over to generating it's capsule update image GUIDs
dynamically from the namespace and board/image info. Update the
reference and tests to use the new GUIDs.

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
2024-09-12 17:35:37 +02:00
Simon Glass
34d4a5df1b binman: fit: Allow running fdtgrep on devicetree blobs
When using FIT to load firmware builds for multiple models, the FIT must
include a common binary along with a number of devicetree blobs, one for
each model. This is the same mechanism as is used for loading an OS.

However, SPL builds do not normally use the full devicetree, but instead
a cut-down version which various nodes and properties removed.

Add a new fit,fdt-phase property to allow binman to produce these
devicetree blobs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
57902e6941 binman: fit: Write the compatible string to configuration
FIT allows the FDT's root-node compatible string to be placed in a
configuration node to simplify and speed up finding the best match for
booting.

Add a new property to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
9db7a3a432 binman: fit: Allow providing FDT filenames in a directory
In some cases the list of available FDT files is not available in an
entryarg. Provide an option to point to a directory containing them
instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
7081a94ea4 binman: Add support for alternative FDTs
FIT provides a way to select between different devicetree blobs
depending on the model. This works fine for U-Boot proper and allows SPL
to select the correct blob for the current board at runtime. The boot
sequence (SPL->U-Boot proper) is therefore covered by the existing
feature set.

The first boot phase (typically TPL) cannot use FIT since SoC boot ROMs
don't currently support it. Therefore the TPL image must be specific to
each model it boots on.

To support booting on mulitple models, binman must therefore produce a
separate TPL image for each model, even if the images for the rest of
the phases are identical.

TPL needs to be packaged as an executable binary along with a reduced
devicetree. When multiple models are supported, a reduced devicetree
must be provided for each model.

U-Boot's build system is designed to build a single devicetree for SPL
builds, so does not support this requirement.

Add a new 'alternatives' feature to Binman, allowing it to automatically
subset a devicetree to produce the reduced devicetree for a particular
phase for each supported model. With this it is possible to produce a
separate TPL image for each of the models. The correct one can then be
loaded onto a board, along with the common FIT image(s).

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
a56ea60627 binman: Correct indentation in testSplPubkeyDtb
This function has strange indentation. Fix it.

Fixes: 8c1fbd1f60 ("binman: ftest: Add test for u_boot_spl_pubkey_dtb")

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
57208ddc8c binman: Fix a comment typo in _DoReadFileDtb()
Fix a minor typo in this function.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-29 08:42:18 -06:00
Simon Glass
404936e573 binman: Support an assumed size for missing binaries
Binman has a the useful feature of handling missing external blobs
gracefully, including allowing them to be missing, deciding whether the
resulting image is functional or not and faking blobs when this is
necessary for particular tools (e.g. mkimage).

This feature is widely used in CI. One drawback is that if U-Boot grows
too large to fit along with the required blobs, then this is not
discovered until someone does a 'real' build which includes the blobs.

Add a 'assume-size' property to entries to allow Binman to reserve a
given size for missing external blobs.

Signed-off-by: Simon Glass <sjg@chromium.org>
2024-07-03 07:36:33 +01:00
Brandon Maier
357bfca5e6 tools: binman: fix deprecated Python unittest methods
The methods `unittest.assertEquals()` and
`unittest.assertRegexpMatches()` are marked deprecated[1].

In Python 3.12 these aliases have been removed, so do a sed to replace
them with their new names.

[1] https://docs.python.org/3.11/library/unittest.html#deprecated-aliases

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
CC: Simon Glass <sjg@chromium.org>
CC: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-07-03 07:36:33 +01:00
Neha Malcom Francis
10fee88d42 tools: binman: ti_board_cfg: Check for linting problems
Use yamllint for checking whether YAML configuration files are adhering
to default yamllint rules.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
Suggested-by: Nishanth Menon <nm@ti.com>
2024-01-18 17:50:27 -05:00
Tom Rini
0d53be75c7 Merge patch series "ATF and OP-TEE Firewalling for K3 devices."
Manorit Chawdhry <m-chawdhry@ti.com> says:

K3 devices have firewalls that are used to prevent illegal accesses to
memory regions that are deemed secure. The series prevents the illegal
accesses to ATF and OP-TEE regions that are present in different K3
devices.

AM62X, AM62AX and AM64X are currently in hold due to some firewall
configurations that our System Controller (TIFS) needs to handle.
The devices that are not configured with the firewalling nodes will not
be affected and can continue to work fine until the firewall nodes are
added so will be a non-blocking merge.

Test Logs: https://gist.github.com/manorit2001/4cead2fb3a19eb5d19005b3f54682627
CICD Run: https://github.com/u-boot/u-boot/pull/442
2024-01-04 16:53:49 -05:00
Manorit Chawdhry
ba51299f60 binman: ftest: Add test for ti-secure firewall node
Add test for TI firewalling node in ti-secure.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Manorit Chawdhry <m-chawdhry@ti.com>
2024-01-04 16:48:00 -05:00
Heinrich Schuchardt
69c3705be9 binman: used-before-assignment in ftest.py
Pytest 7.4.3 complains if a variable is used in a finally clause without
having been initialized before the try clause.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-12-31 07:21:02 -07:00
Neha Malcom Francis
23d2ef91ef binman: etype: dm: Add entry type for TI DM
K3 devices introduces the concept of centralized power, resource and
security management to System Firmware. This is to overcome challenges
by the traditional approach that implements system control functions on
each of the processing units.

The software interface for System Firmware is split into TIFS and DM. DM
(Device Manager) is responsible for resource and power management from
secure and non-secure hosts. This additional binary is necessary for
specific platforms' ROM boot images and is to be packaged into tispl.bin

Add an entry for DM. The entry can be used for the packaging of
tispl.bin by binman along with ATF and TEE.

Signed-off-by: Neha Malcom Francis <n-francis@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-12-13 18:39:06 -05:00
Simon Glass
ab326010a9 binman: Replace FILENAME_ALIGN 16 with ATTRIBUTE_ALIGN 4
cbfsutil changed to 4-byte alignment for filenames instead of 16.
Adjust the binman implementation to do the same.

This mirrors commit 5779ca718c in coreboot.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-02 22:38:01 -04:00
Simon Glass
bd13255a91 binman: Don't add compression attribute for uncompressed files
cbfsutil changed to skip adding a compression attribute if there is no
compression. Adjust the binman implementation to do the same.

This mirrors commit 105cdf5625 in coreboot.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
2023-11-02 22:37:50 -04:00
Sughosh Ganu
74aae507bc binman: capsule: Add support for generating EFI empty capsules
Add support in binman for generating EFI empty capsules. These
capsules are used in the FWU A/B update feature. Also add test cases
in binman for the corresponding code coverage.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13 14:01:42 -06:00
Sughosh Ganu
809f28e721 binman: capsule: Use dumped capsule header contents for verification
The various fields of a generated capsule are currently verified
through hard-coded offsets. Use the dump-capsule feature for dumping
the capsule header contents and use those for capsule verification.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-10-13 14:01:42 -06:00
Sughosh Ganu
b617611b27 binman: capsule: Add support for generating EFI capsules
Add support in binman for generating EFI capsules. The capsule
parameters can be specified through the capsule binman entry. Also add
test cases in binman for testing capsule generation.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-29 13:37:54 -04:00
Lukas Funke
d8a2d3b290 binman: ftest: Add test for xilinx-bootgen etype
Add test for the 'xilinx-bootgen' etype

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Allow missing bootgen tool; comment testXilinxBootgenMissing() comment:
Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-05 11:38:59 -06:00
Simon Glass
93a203d38b binman: Renumber 291 and 292 test files
These have ended up with the same numbers as earlier files. Fix them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-05 11:31:59 -06:00
Simon Glass
d4d97661d2 binman: Support templates containing phandles
This provides support for phandles to be copied over from templates. This
is not quite safe, since if the template is instantiated twice (i.e. in
two different nodes), then duplicate phandles will be found. This will
result in an error.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02 12:05:57 -06:00
Simon Glass
af41b24eba binman: Remove templates after use
It is not necessary to keep templates around after they have been
processed. They can cause confusion and potentially duplicate phandles.

Remove them.

Use the same means of detecting a template node in _ReadImageDesc so that
the two places are consistent.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02 12:05:57 -06:00
Simon Glass
b2f47a599c binman: Produce a template-file after processing
This file aids debugging when binman fails to get far enough to write out
the final devicetree file. Write it immediate after template processing.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02 12:05:57 -06:00
Jonas Karlman
8f452bc557 binman: Show filename in missing blob help message
Show the filename next to the node path in missing blob help messages,
also show a generic missing blob message when there was no help message
for the help tag.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-02 12:05:57 -06:00
Jonas Karlman
49dcd1c0bb binman: Override CheckOptional in fit entry
Missing optional blobs was not reported for generated entries, e.g.
tee-os on rockchip targets. Implement a CheckOptional to fix this.

After this the following can be shown:

  Image 'simple-bin' is missing optional external blobs but is still functional: tee-os

  /binman/simple-bin/fit/images/@tee-SEQ/tee-os (tee-os):
     See the documentation for your board. You may need to build Open Portable
     Trusted Execution Environment (OP-TEE) and build with TEE=/path/to/tee.bin

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-02 12:05:57 -06:00