summaryrefslogtreecommitdiff
path: root/tools/binman/control.py
AgeCommit message (Collapse)Author
2025-07-09binman: migrate from pkg_resources to importlibYannic Moog
pkg_resources is deprecated, use migration guide in [1] to migrate to importlib.resources. Keep the Python 3.6 backwards compatibility. This also fixes the binman version test which failed for setuptools versions that print the deprecation warning. Change from __name__ to __package__ as with the transition from pkg_resources to importlib_resources using __name__ results in TypeErrors [2]. [1] https://importlib-resources.readthedocs.io/en/latest/migration.html [2] https://github.com/python/importlib_resources/issues/60 Reviewed-by: Bryan Brattlof <bb@ti.com> Signed-off-by: Yannic Moog <y.moog@phytec.de>
2025-06-26Merge patch series "Propagate bootph-all and bootph-some-ram property to all ↵Tom Rini
supernodes" Moteen Shah <m-shah@ti.com> says: In the U-Boot pre-relocation stage, if the parent node lacks bootph-all/bootph-some-ram property and the driver lacks a pre-reloc flag, all of its subsequent subnodes gets skipped over from driver binding—even if they have a bootph* property. This series addresses the issue by scanning through all the nodes during build time and propagating the applicable property to all of its supernode. Link: https://lore.kernel.org/r/20250516114148.3862114-1-m-shah@ti.com
2025-06-26tools: binman: control.py: Propagate bootph-all/bootph-some-ram properties ↵Moteen Shah
to supernodes As per bootph schema, bootph-* property in child node should be implied in their parent, but this feature is not implemented in the U-Boot proper stage (before relocation) resulting in devices not being bound because of the missing bootph-all or bootph-some-ram property in the parent node. To mitigate this issue, add a function to scan through all the nodes in the device-tree for bootph-all and bootph-some-ram properties. If found, propagate it to all of its parent nodes up the hierarchy. Signed-off-by: Moteen Shah <m-shah@ti.com> Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
2025-06-26Merge patch series "Fix handling of optional blobs in binman"Tom Rini
Yannic Moog <y.moog@phytec.de> says: This series solves a contradiction regarding ext blobs packaged in binman. When they are marked as optional, by default they are faked, two messages are emitted. One says the image is not functional the other says the image is still functional. Both concern the same binman entry/blob. Binman is set up to have fake external blobs in case they are missing. This is regardless on whether they are optional or not. The implementation does not allow different types of entries to override the faking decision; at least there wouldn't be much sense in doing so. Here is an example build output of a phycore-imx8mp: BINMAN .binman_stamp Image 'image' is missing optional external blobs but is still functional: tee-os /binman/section/fit/images/tee/tee-os (tee.bin): 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 Image 'image' has faked optional external blobs and is still functional: tee.bin OFCHK .config The output stays to inform/warn the user, but in this case the tee-os entry will not be present in the final image. Link: https://lore.kernel.org/r/20250613-binman_faked_optional-v3-0-1e23dd7c41a2@phytec.de
2025-06-26binman: add faked optional entry case in CheckForProblemsYannic Moog
When having an entry that is marked as optional and is missing in the final image, the following output is observed: CFGS spl/u-boot-spl.cfgout BINMAN .binman_stamp Image 'image' has faked external blobs and is non-functional: tee.bin Image 'image' is missing optional external blobs but is still functional: tee-os /binman/section/fit/images/tee/tee-os (tee.bin): 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 Some images are invalid make: *** [Makefile:1135: .binman_stamp] Error 103 To solve this contradictory messaging, when checking the faked blob list, remove entries that are allowed to be missing. Instead add an info message for faked optional blobs. Also reduce verbosity of the optional image warning to an info message. Signed-off-by: Yannic Moog <y.moog@phytec.de> Reviewed-by: Bryan Brattlof <bb@ti.com>
2025-06-26binman: rework dropping absent entries from packaged imageYannic Moog
When blobs are absent and are marked as optional, they can be safely dropped from the binman tree. Use the drop_absent function for that. Rename drop_absent to drop_absent_optional as we do not want to drop any entries that are absent; they should be reported by binman as errors when they are missing. We also reorder the processing of the image the following: - We call the CheckForProblems function before the image is built. - We drop entries after we checked for problems with the image. This is okay because CheckForProblems does not look at the file we have written but rather queries the data structure (image) built with binman. This also allows us to get all error and warning messages that we want to report while avoiding putting missing optional entries in the final image. As only the blobs are dropped, the sections still remain in the assembled image. Thus add them to the expected test case checks where necessary. In addition, a rework of testPackTeeOsOptional test case is necessary. The test did not really do what it was supposed to. The description said that optional binary is tested, but the binary is not marked as optional. Further, the tee.elf file, when included in the image properly, also shows up in the image data. This must be added as well. As there is no global variable for the elf data, set the pathname to the elf file that was created when setting up the test suite. For the test case get the filename and read the contents, comparing them to the contents of the created binman image. Signed-off-by: Yannic Moog <y.moog@phytec.de> Reviewed-by: Bryan Brattlof <bb@ti.com>
2025-06-26binman: allow '.' to be included in the missing blob tagsBryan Brattlof
Extend the regex to add periods '.' in the tag so entries like ti-fs-enc.bin can be represented in the missing-blob-help file. Signed-off-by: Bryan Brattlof <bb@ti.com>
2025-05-27u_boot_pylib: Support a fatal level in toutSimon Glass
It is convenient to be able to print a message and exit. Add a new 'fatal' level to support this. Update some assumptions about the level, so that the tools continue to work as now. Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-03tools: binman: control.py: Delete template nodes after parsingNeha Malcom Francis
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>
2024-12-19tools: binman: Pass a list of input directory to EnsureCompiled()Paul HENRYS
Input directories can be passed to binman using the '-I' option and those input directories are now also passed to 'dtc' when run by binman. Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2024-07-29binman: Add support for alternative FDTsSimon Glass
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-29binman: Move problem-checking code into a functionSimon Glass
This has become quite long, so move it into a separate function. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-11-02binman: Reset missing bintools after testingSimon Glass
For tests which fake bintools being missing, we need to reset the list afterwards, to ensure that future tests do not also see the bintools as missing. Reset the list when processing is complete. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
2023-08-28Revert "binman: Add a temporary hack for duplicate phandles"Simon Glass
The affected boards have been fixed, so drop this hack. This reverts commit 288ae53cb73605500b7fc01e5919753c878466be. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Tim Harvey <tharvey@gateworks.com>
2023-08-02binman: Add a temporary hack for duplicate phandlesSimon Glass
Three boards use a phandle in a FIT generator and the maintainer is away. For now, add a hack to allow this. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-08-02binman: Support templates containing phandlesSimon Glass
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-02binman: Remove templates after useSimon Glass
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-02binman: Produce a template-file after processingSimon Glass
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-02binman: Show filename in missing blob help messageJonas Karlman
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-02binman: Fix blank line usage for invalid images warning textJonas Karlman
There is no blank line between last missing blob help message and the header line for optional blob help messages. Image 'simple-bin' is missing external blobs and is non-functional: atf-bl31 /binman/simple-bin/fit/images/@atf-SEQ/atf-bl31: See the documentation for your board. You may need to build ARM Trusted Firmware and build with BL31=/path/to/bl31.bin Image 'simple-bin' is missing external blobs but is still functional: tee-os /binman/simple-bin/fit/images/@tee-SEQ/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 Some images are invalid With this a blank line is inserted to make the text more readable. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-02binman: Report missing external blobs using error levelJonas Karlman
Print missing external blobs using error level and missing optional external blobs using warning level. Also change to only print the header line in color, red for missing and yellow for optional. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-08-02binman: Update missing optional external blob warning textJonas Karlman
Make it more clear that the missing external blob is optional in the printed warning message. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-24binman: Don't decompress data while signingLukas Funke
While signing a fit compressed data (i.e. 'blob-ext') is decompressed, but never compressed again. When compressed data was wrapped in a section, decompression leads to an error because the outer section had the original compressed size but the inner entry has the uncompressed size now. While singing there is no reason to decompress data. Thus, decompression should be disabled. Furthermore, bintools should be collected before loading the data. This way bintools are available if processing is required on a node. Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-07-20binman: Support templates at any levelSimon Glass
Allow templates to be used inside a section, not just in the top-level /binman node. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-20binman: Support templating with multiple imagesSimon Glass
Allow a template to appear in the top level description when using multiple images. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-20binman: Support simple templatesSimon Glass
Collections can used to collect the contents of other entries into a single entry, but they result in a single entry, with the original entries 'left behind' in their old place. It is useful to be able to specific a set of entries ones and have it used in multiple images, or parts of an image. Implement this mechanism. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-07-14binman: Correct coverage gap in controlSimon Glass
Add a pragma to deal with the code-coverage gap which drops binman down to 90% coverage. Fixes: de65b122a25 (tools: Fall back to importlib_resources on Python 3.6) Signed-off-by: Simon Glass <sjg@chromium.org>
2023-04-28tools: Fall back to importlib_resources on Python 3.6Jan Kiszka
importlib.resources became part of 3.7 only. Allow using distros with 3.6 and the importlib_resources backport. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2023-03-14binman: add tests for sign optionIvan Mikhaylov
Add the test which provides sequence of actions: 1. create the image from binman dts 2. create public and private keys 3. add public key into dtb with fdt_add_pubkey 4. 1. sign FIT container with new sign option with extracting from image 2. sign exact FIT container with replacing of it in image 5. check with fit_check_sign Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com> Renumber test file from 277 to 280; Move UpdateSignatures() to Entry base class; Don't allow missing mkimage as it doesn't make sense; Propagate --toolpath for CI; Call mark_build_done() to avoid regenerating FIT: Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-14binman: add sign option for binmanIvan Mikhaylov
Introduce proof of concept for binman's new option which provides sign and replace FIT containers in binary images. Usage as example: from: mkimage -G privateky -r -o sha256,rsa4096 -F fit binman replace -i flash.bin -f fit.fit fit to: binman sign -i flash.bin -k privatekey -a sha256,rsa4096 -f fit.fit fit and to this one if it's need to be extracted, signed with key and put it back in image: binman sign -i flash.bin -k privatekey -a sha256,rsa4096 fit Signed-off-by: Ivan Mikhaylov <fr0st61te@gmail.com>
2023-03-08binman: Support updating section contentsSimon Glass
Implement this feature since it is useful for updating FITs within an image. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Allow preserving the output dir when replacingSimon Glass
Add these flags for the 'replace' subcommand too, to aid debugging. Signed-off-by: Simon Glass <sjg@chromium.org> 44 2023 -0700
2023-03-08binman: Use importlib to find the helpSimon Glass
Use this function so that the help can be found even when binman is running from a package. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass
The patman directory has a number of modules which are used by other tools in U-Boot. This makes it hard to package the tools using pypi since the common files must be copied along with the tool that uses them. To address this, move these files into a new u_boot_pylib library. This can be packaged separately and listed as a dependency of each tool. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08binman: Make the tooldir configurableSimon Glass
Add a command-line argument for setting the tooldir, so that the default can be overridden. Add this directory to the toolpath automatically. Create the directory if it does not already exist. Put the default in the argument parser instead of the class, so that it is more obvious. Update a few tests that expect the utility name to be provided without any path (e.g. 'futility'), so they can accept a path, e.g. /path/to/futility Update the documentation and add a few tests. Improve the help for --toolpath while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18binman: Support optional external blobsSimon Glass
Some blobs are actually not necessary for the board to work correctly. Add a property to allow this to be indicated. Missing optional blobs do not cause a build failure. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18binman: Support optional entriesSimon Glass
Support entries which can be optional depending on their contents. This allows special entry types which appear in the image only when needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22binman: Use an exit code when blobs are missingSimon Glass
At present binman returns success when told to handle missing/faked blobs or missing bintools. This is confusing since in fact the resulting image cannot work. Use exit code 103 to signal this problem, with a -W option to convert it to a warning. Rename the flag to --ignore-missing since it controls bintools also. Add documentation about exit codes while we are here. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-08-20binman: Collect bintools before usageStefan Herbrechtsmeier
Collect and thereby initialize bintools before any usage but after generation of entries. This is needed to handle bintools for compress and decompress like other bintools. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-08-20binman: Put fake files in a subdirectorySimon Glass
At present fake files from a previous build appear to be real files for a subsequent build, since they sit in the output directory. This can cause problems, since binman may need to parse the file, e.g. with the Intel description.bin files. Fix this by putting them in a 'binman-fake' subdirectory. Keep a track of the fake filename so we only create it once. Subsequent builds will still see that the file is missing and mark it as fake. Update a few tests to check the behaviour. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-04-25binman: Don't reset offset/size if image doesn't allow repackingAlper Nebi Yasak
When an image has the 'allow-repack' property, binman includes the original offset and size properties from the image description in the fdtmap. These are later used as the packing constraints when replacing entries in an image, so other unconstrained entries can be freely positioned. Replacing an entry in an image without 'allow-repack' (and therefore the original offsets) follows the same logic and results in entries being merely concatenated. Instead, skip resetting the calculated offsets and sizes to the missing originals for these images so that every entry is constrained to its existing offset/size. Add tests that replace an entry with smaller or equal-sized data, in an image that doesn't allow repacking. Attempting to do so with bigger-size data is already an error that is already being tested. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-04-25binman: Collect bintools for images when replacing entriesAlper Nebi Yasak
Binman entries can use other executables to compute their data, usually in their ObtainContents() methods. Subclasses of Entry_section would use bintools in their BuildSectionData() method instead, which is called from several places including their Pack(). These binary tools are resolved correctly while building an image from a device-tree description so that they can be used from these methods. However, this is not being done when replacing entries in an image, which can result in an error as the Pack() methods attempt to use them. Collect and resolve entries' bintools also when replacing entries to fix Pack() errors. Add a way to mock bintool usage in the testing entry type and tests that check bintools are being resolved for such an entry. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-03-18binman: Rename ExpandEntries to gen_entriesSimon Glass
Leave the 'expand' term for use by entry types which have an expanded version of themselves. Rename this method to indicate that it generates subentries. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-03-02binman: Correct pylint errorsSimon Glass
Fix pylint errors that can be fixed and mask those that seem to be incorrect. A complication with binman is that it tries to avoid importing libfdt (or anything that imports it) unless needed, so that things like help still work if it is missing. Note that two tests are duplicated in binman and two others have duplicate names, so both of these issues are fixed also. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tout.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-09patman: Convert camel case in tools.pySimon Glass
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Add a command to generate bintool docsSimon Glass
Each bintool has some documentation which can be useful for the user. Add a new command that collects this and writes it into a .rst file. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Plumb in support for missing bintoolsSimon Glass
Bintools can be missing, in which case binman continues operation but reports an invalid image. Plumb in support for this and add tests for entry types which use bintools. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Plumb in support for bintoolsSimon Glass
Support collecting the available bintools needed by an image, by scanning the entries in the image. Also add a command-line interface to access the basic bintool features, such as listing the bintools and fetching them if needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-25binman: Drop the image name from the fake-blob messageSimon Glass
This is not really needed and it makes the message different from the missing-blob message. Update it. Signed-off-by: Simon Glass <sjg@chromium.org>