aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/control.py
AgeCommit message (Collapse)Author
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>
2022-01-12binman: Write fake blobs to the output directorySimon Glass
At present binman writes fake blobs to the current directory. This is not very helpful, since the files serve no useful purpose once binman has finished. They clutter up the source directory and affect future runs, since the files in the current directory are often used in preference to those in the board directory. To avoid these problems, write them to the output directory instead. Move the file-creation code to the Entry base class, so it can be used by any entry type that needs it. This is required since some entry types, such as Entry_blob_ext_list, are not subclasses of Entry_blob. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-01-10Merge branch 'next'Tom Rini
Signed-off-by: Tom Rini <trini@konsulko.com>
2022-01-07binman: add support for creating dummy files for external blobsHeiko Thiery
While converting to binman for an imx8mq board, it has been found that building in the u-boot CI fails. This is because an imx8mq requires an external binary (signed_hdmi_imx8m.bin). If this file cannot be found mkimage fails. To be able to build this board in the u-boot CI a binman option (--fake-ext-blobs) is introduced that can be switched on via the u-boot makefile option BINMAN_FAKE_EXT_BLOBS. With that the needed dummy files are created. Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-12-05binman: Allow extracting a file in an alternative formatSimon Glass
In some cases entries encapsulate other data and it is useful to access the data within. An example is the fdtmap which consists of a 16-byte header, followed by a devicetree. Provide an option to specify an alternative format when extracting files. In the case of fdtmap, this is 'fdt', which produces an FDT file which can be viewed with fdtdump. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-11-28binman: Fix extract command for using non-absolute image pathsJan Kiszka
Otherwise the updated image will end up in the temporary folder that is purged after completion. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-11-13binman: Fix replace subcommand help and commentsJan Kiszka
Fix some copy&paste artifacts. Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
2021-11-13binman: Support updating the dtb in an ELF fileSimon Glass
WIth EFI we must embed the devicetree in an ELF image so that it is loaded as part of the executable file. We want it to include the binman definition in there also, which in some cases cannot be created until the ELF (u-boot) is built. Add an option to binman to support writing the updated dtb to the ELF file u-boot.out This is useful with the EFI app, which is always packaged as an ELF file. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-09-24tools: Refactor full help printingPaul Barker
Collect the code for printing the full help message of patman, buildman and binman into a single function in patman.tools. Signed-off-by: Paul Barker <paul.barker@sancloud.com>
2021-07-21binman: Add basic support for debugging performanceSimon Glass
One of binman's attributes is that it is extremely fast, at least for a Python program. Add some simple timing around operations that might take a while, such as reading an image and compressing it. This should help to maintain the performance as new features are added. This is for debugging purposes only. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21binman: Support multithreading for building imagesSimon Glass
Some images may take a while to build, e.g. if they are large and use slow compression. Support compiling sections in parallel to speed things up. Signed-off-by: Simon Glass <sjg@chromium.org> (fixed to use a separate test file to fix flakiness)
2021-03-26binman: doc: Add documentation to htmldocsSimon Glass
Add a link to binman's documentation and adjust the files so that it is accessible. Use the name README.rst so it is easy to discover when binman is installed without U-Boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Plumb expanded entries through fullySimon Glass
Add support for this feature in the control, image and section modules, so that expanded entries will be selected by default. So far there are no expanded entry types, so this is a nop. Signed-off-by: Simon Glass <sjg@chromium.org>