summaryrefslogtreecommitdiff
path: root/tools/binman/cbfs_util.py
Commit message (Collapse)AuthorAgeFilesLines
* patman: Move library functions into a library directorySimon Glass2023-03-081-2/+2
| | | | | | | | | | | 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>
* binman: Select compression bintools in cbfs_util classStefan Herbrechtsmeier2022-08-201-9/+11
| | | | | | | | | Select the lz4 and lzma_alone bintools in cbfs_util class to centralize the supported compression algorithm evaluation inside the class and over multiple classes. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* binman: Remove obsolete compressed data header handlingStefan Herbrechtsmeier2022-08-201-4/+4
| | | | | | | | | 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 <stefan.herbrechtsmeier@weidmueller.com> Reviewed-by: Simon Glass <sjg@chromium.org>
* patman: Convert camel case in tools.pySimon Glass2022-02-091-6/+6
| | | | | | Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Tidy up pylint warnings in comp_utilSimon Glass2022-01-251-4/+4
| | | | | | | Tweak some naming and comments to resolve these. Use WriteFile() to write the file. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move compression into binmanSimon Glass2022-01-251-4/+5
| | | | | | | | | | The compression functions are not actually used by patman, so we don't need then in the tools module. Also we want to change them to use bintools, which patman will not support. Move these into a new comp_util module, within binman. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Convert to using the CBFS bintoolSimon Glass2022-01-251-24/+0
| | | | | | | | Update the CBFS tests to use this bintool, instead of running cbfstool directly. This simplifies the overall code and provides more consistency, as well as supporting missing bintools. Signed-off-by: Simon Glass <sjg@chromium.org>
* patman: Move to absolute importsSimon Glass2020-04-261-2/+2
| | | | | | | | | | | At present patman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary. Move patman to use absolute imports. This requires changes in tools which use the patman libraries (which is most of them). Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move to absolute importsSimon Glass2020-04-261-1/+1
| | | | | | | | | | | At present binman sets the python path on startup so that it can access the libraries it needs. If we convert to use absolute imports this is not necessary. Move binman to use absolute imports. This enables removable of the path adjusting in Entry also. Signed-off-by: Simon Glass <sjg@chromium.org>
* patman: Drop references to __future__Simon Glass2020-04-261-2/+0
| | | | | | We don't need these now that the tools using Python 3. Drop them. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support replacing data in a cbfsSimon Glass2019-07-291-4/+6
| | | | | | | | | | | | | | | | | | | At present binman cannot replace data within a CBFS since it does not allow rewriting of the files in that CBFS. Implement this by using the new WriteData() method to handle the case. Add a header to compressed data so that the amount of compressed data can be determined without reference to the size of the containing entry. This allows the entry to be larger that the contents, without causing errors in decompression. This is necessary to cope with a compressed device tree being updated in such a way that it shrinks after the entry size is already set (an obscure case). It is not used with CBFS since it has its own metadata for this. Increase the number of passes allowed to resolve the position of entries, to handle this case. Add a test for this new logic. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a prefix before CBFS hex offsetsSimon Glass2019-07-291-2/+2
| | | | | | Add a 0x prefix to these errors to avoid confusion. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support reading from CBFS entriesSimon Glass2019-07-241-0/+14
| | | | | | | | CBFS is a bit like a section but with a custom format. Provide the list of entries and the compression type to binman so that it can extract the data from the CBFS, just like any other part of the image. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Use the cbfs memlen field only for uncompressed lengthSimon Glass2019-07-241-4/+7
| | | | | | | | | | | | The purpose of this badly named field is a bit ambiguous. Adjust the code to use it only to store the uncompressed length of a file, leaving it set to None if there is no compression used. This makes it easy to see if the value in this field is relevant / useful. Also set data_len for compressed fields, since it should be the length of the compressed data, not the uncompressed data. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Provide the actual data address for cbfs filesSimon Glass2019-07-241-11/+20
| | | | | | | | At present a file with no explicit CBFS offset is placed in the next available location but there is no way to find out where it ended up. Update and rename the get_data() function to provide this information. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add support for fixed-offset files in CBFSSimon Glass2019-07-241-23/+102
| | | | | | | | | | A feature of CBFS is that it allows files to be positioned at particular offset (as with binman in general). This is useful to support execute-in-place (XIP) code, since this may not be relocatable. Add a new cbfs-offset property to control this. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Pad empty areas of the CBFS with filesSimon Glass2019-07-241-3/+65
| | | | | | | | | | When there is lots of open space in a CBFS it is normally padded with 'empty' files so that sequentially scanning the CBFS can skip from one to the next without a break. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a utility library for coreboot CBFSSimon Glass2019-07-241-0/+720
Coreboot uses a simple flash-based filesystem called Coreboot Filesystem (CBFS) to organise files used during boot. This allows files to be named and their position in the flash to be set. It has special features for dealing with x86 devices which typically memory-map their SPI flash to the top of 32-bit address space and need a 'boot block' ending there. Create a library to help create and read CBFS files. This includes a writer class, a reader class and associated other helpers. Only a subset of features are currently supported. Signed-off-by: Simon Glass <sjg@chromium.org>