summaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
AgeCommit message (Collapse)Author
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 <[email protected]> Reviewed-by: Bryan Brattlof <[email protected]>
2025-06-26binman: drop "faked" return value from check_fake_fnameYannic Moog
check_fake_fname sets the faked member of the entry. Use that member to get the faked status instead of a returned value indicating the same. Add type annotations to the modified functions while at it. Signed-off-by: Yannic Moog <[email protected]> Reviewed-by: Simon Glass <[email protected]> Reviewed-by: Bryan Brattlof <[email protected]>
2025-03-04binman: Honour the skip-at-start property more faithfullySimon Glass
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 <[email protected]>
2025-03-04binman: Rename Entry.end_4gbSimon Glass
The property is named end_at_4gb so name the variable the same, to avoid confusion. Signed-off-by: Simon Glass <[email protected]>
2024-09-26binman: Unwind the end-at-4gb special-case a littleSimon Glass
Move the check for this further out, so that base_addr is computed in Entry.WriteSymbols() rather than at lower levels. Signed-off-by: Simon Glass <[email protected]>
2024-09-26binman: Provide a way to set the symbol base addressSimon Glass
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 <[email protected]>
2024-09-26binman: Tidy up comments for Entry.GetEntryArgsOrProps()Simon Glass
Improve the comments for this function. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2024-07-29binman: Allow entry types to override FDT contentsSimon Glass
At present the contents of an FDT (for each phase) are fixed, determined by the build and provided to Binman as input files. Provide a means for entry types to provide their own FDT, so that it can be processed, if needed. Signed-off-by: Simon Glass <[email protected]>
2024-07-29binman: Write the compressed output to a fileSimon Glass
When an entry is compressed, write the compressed contents to a file so that it is possible to see what was produced. This aids debugging with new images. Signed-off-by: Simon Glass <[email protected]>
2024-07-03binman: Support an assumed size for missing binariesSimon Glass
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 <[email protected]>
2024-07-03binman: Update the entrydocs headerSimon Glass
Reduce the length of the underline for this header, to match the heading itself. Signed-off-by: Simon Glass <[email protected]>
2023-07-20binman: Support writing symbols inside a mkimage imageSimon Glass
Add support for writing symbols and determining the assumed position of binaries inside a mkimage image. This is useful as an example for other entry types which might want to do the same thing. Signed-off-by: Simon Glass <[email protected]>
2023-07-20binman: Convert mkimage to Entry_sectionMarek Vasut
This is needed to handle mkimage with inner section located itself in a section. Signed-off-by: Marek Vasut <[email protected]> Use BuildSectionData() instead of ObtainContents(), add tests and a few other minor fixes: Signed-off-by: Simon Glass <[email protected]>
2023-07-20binman: Add more detail on how ObtainContents() worksSimon Glass
This area of binman can be a bit confusing. Add some more comments to help. Signed-off-by: Simon Glass <[email protected]>
2023-07-20binman: Allow disabling symbol writingSimon Glass
Some boards don't use symbol writing but do access the symbols in SPL. Provide an option to work around this. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]> 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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
2023-03-08binman: Use correct argument name in docstringsJonas Karlman
Use correct argument name in docstrings. Signed-off-by: Jonas Karlman <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-03-08binman: Support marking FMAP areas as preservedSimon Glass
Add an entry flag called 'preserve' to indicate that an entry should be preserved by firmware updates. Propagate this to FMAP too. Signed-off-by: Simon Glass <[email protected]>
2023-01-26binman: Add 'min-size' entry propertySamuel Holland
This property sets the minimum size of an entry, including padding but not alignment. It can be used to reserve space for growth of an entry, or to enforce a minimum offset for later entries in the section. Signed-off-by: Samuel Holland <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-01-18binman: Support positioning an entry by and ELF symbolSimon Glass
In some cases it is useful to position an entry over the top of a symbol in an ELF file. For example, if the symbol holds a version string then it allows the string to be accessed from the fdtmap. Add support for this. Suggested-by: Pali Rohár <[email protected]> Suggested-by: Keith Short <[email protected]> Signed-off-by: Simon Glass <[email protected]>
2023-01-18binman: Provide general support for updating ELF symbolsSimon Glass
The current support for updating variables in a binary is hard-coded to work with U-Boot: - It assumes the image starts at __image_copy_start - It uses the existing U-Boot-specific entry types It is useful for other projects to use these feature. Add properties to enable writing symbols for any blob, a way of specifying the base symbol and a way of providing the ELF filename to allow symbol lookup to take place. With this it is possible to update a Zephyr image, such as zephyr.bin after it has been built. Signed-off-by: Simon Glass <[email protected]>
2023-01-18binman: Support overlapping entriesSimon Glass
In some cases it is useful to have an entry overlap with another in a section, either to update the contents within a blob, or to add an entry to the fdtmap that covers only part of the blob. Add support for this. Signed-off-by: Simon Glass <[email protected]>
2023-01-18binman: Add a null entrySimon Glass
It is sometimes useful to define an entry which does not have its own contents but does appear in the image. The contents are set by the section which contains it, even though it appears as an entry in the fdtmap. Add support for this. Signed-off-by: Simon Glass <[email protected]>
2023-01-18binman: Clarify use of False when obtaining dataSimon Glass
This means that the data is not yet available. Update some comments to make this clearer. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2023-01-18binman: Support new op-tee binary formatSimon Glass
OP-TEE has a format with a binary header that can be used instead of the ELF file. With newer versions of OP-TEE this may be required on some platforms. Add support for this in binman. First, add a method to obtain the ELF sections from an entry, then use that in the FIT support. We then end up with the ability to support both types of OP-TEE files, depending on which one is passed in with the entry argument (TEE=xxx in the U-Boot build). Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2022-10-31binman: Support writing symbols into ELF filesSimon Glass
In some cases the ELF version of SPL builds may be packaged, rather than a binary .bin file. Add support for this. Signed-off-by: Simon Glass <[email protected]>
2022-10-31binman: Handle writing ELF symbols in the Entry classSimon Glass
This feature is used by several etypes and we plan to add more that use it. Make symbol writing a feature of the base class to reduce the code duplication. Signed-off-by: Simon Glass <[email protected]>
2022-08-20binman: Add zstd bintoolStefan Herbrechtsmeier
Add zstd bintool to binman to support on-the-fly compression. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Add xz bintoolStefan Herbrechtsmeier
Add xz bintool to binman to support on-the-fly compression. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Add lzop bintoolStefan Herbrechtsmeier
Add lzop bintool to binman to support on-the-fly compression. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Add gzip bintoolStefan Herbrechtsmeier
Add gzip bintool to binman to support on-the-fly compression of Linux kernel images and FPGA bitstreams. The SPL basic fitImage implementation supports only gzip decompression. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]> Rename the module and support this, since gzip.py is a system module: Signed-off-by: Simon Glass <[email protected]>
2022-08-20binman: Add bzip2 bintoolStefan Herbrechtsmeier
Add bzip2 bintool to binman to support on-the-fly compression. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Support missing compression toolsStefan Herbrechtsmeier
Handle missing compression tools by returning empty data and record missing bintool. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Move compression bintool management into entry classStefan Herbrechtsmeier
Move management of the bintool to compress and decompress data into the entry class and add the bintool to the list of required bintools. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Remove obsolete compressed data header handlingStefan Herbrechtsmeier
Remove the obsolete compressed data header handling from the utilities to compress and decompress data. The header is uncommon, not supported by U-Boot and incompatible with external compressed artifacts. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Disable compressed data headerStefan Herbrechtsmeier
Disable the compressed data header of the utilities to compress and decompress data. The header is uncommon, not supported by U-Boot and incompatible with external compressed artifacts. The header was introduced as part of commit eb0f4a4cb402 ("binman: Support replacing data in a cbfs") to allow device tree entries to be larger than the compressed contents. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Add DecompressData function to entry classStefan Herbrechtsmeier
Add a DecompressData function to entry class to allow override in child classes and to centralize the compress and decompress in a single class. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Avoid duplicates in bintool listsStefan Herbrechtsmeier
Avoid duplicate entries in the list of bintools used by the image and the list of missing bintools. Signed-off-by: Stefan Herbrechtsmeier <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-08-20binman: Allow collection to use entries from other sectionsSimon Glass
At present the collections etype only works with entries in the same section. This can be limiting, since in some cases the data may be inside a subsection, e.g. if there are alignment constraints. Add a function to find the entries in an etype and have it search recursively. Make use of this for mkimage also. Signed-off-by: Simon Glass <[email protected]>
2022-08-20binman: Add a way to check for missing propertiesSimon Glass
Some new entries are likely to have required properties. Support this in a standard way, with a list of required properties which can be set up by base classes. Check for missing properties when the entry is read. Signed-off-by: Simon Glass <[email protected]>
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 <[email protected]>
2022-08-13binman: Add rST references for binman entry typesSimon Glass
Add references in the documentation for each entry type, so we can refer to them from other documentation. Signed-off-by: Simon Glass <[email protected]>
2022-04-25binman: Fix unique names having '/.' for images read from filesAlper Nebi Yasak
Binman can embed a copy of the image description into the images it builds as a fdtmap entry, but it omits the /binman/<image-name> prefix from the node paths while doing so. When reading an already-built image file, entries are reconstructed using this fdtmap and their associated nodes still lack that prefix. Some entries like fit and vblock create intermediate files whose names are based on an entry unique name. This name is constructed from their node's path by concatenating the parents with dots up to the binman node, e.g. /binman/image/foo/bar becomes 'image.foo.bar'. However, we don't have this /binman/image prefix when replacing entries in such an image. The /foo/bar entry we read when doing so erroneously has the unique name of '/.foo.bar', causing permission errors when the entry attempts to create files based on that. Fix the unique-name generation by stopping at the '/' node like how it stops at the binman node. As the unique names are used as filenames, add tests that check if they're safe to use as filenames. Signed-off-by: Alper Nebi Yasak <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2022-03-18binman: Allow mkimage to use a non-zero fake-blob sizeSimon Glass
Unfortunately mkimage gets upset with zero-sized files. Update the ObtainContents() method to support specifying the size, if a fake blob is created. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alper Nebi Yasak <[email protected]>
2022-03-18binman: Make fake blobs zero-sized by defaultSimon Glass
On x86 devices having even a small amount of data can cause an overlap between regions. For example, bayleybay complains when the intel-vga region overlaps with u-boot-ucode: ImagePos Offset Size Name <none> 00000000 00800000 main-section <none> ff800000 00000080 intel-descriptor <none> ff800400 00000080 intel-me <none> fff00000 00098f24 u-boot-with-ucode-ptr <none> fff98f24 00001aa0 u-boot-dtb-with-ucode <none> fff9a9d0 0002a000 u-boot-ucode <none> fffb0000 00000080 intel-vga ... It is safer to use an empty file in most cases. Add an option to set the size for those uses that need it. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Alper Nebi Yasak <[email protected]>