summaryrefslogtreecommitdiff
path: root/tools/binman/control.py
AgeCommit message (Collapse)AuthorFilesLines
2021-11-14binman: Fix replace subcommand help and commentsJan Kiszka1-2/+2
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 Glass1-0/+11
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 Barker1-6/+3
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 Glass1-0/+3
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 Glass1-0/+4
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 Glass1-1/+1
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 Glass1-6/+18
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>
2021-03-26binman: Allow extracting to current directorySimon Glass1-1/+1
Extracting files to the current directory is not normally a very friendly thing to do, but it can be warranted, e.g. in a new temporary dir. At present binman reports an error when such an attempt is made. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-31binman: Show the size when writing entriesSimon Glass1-1/+2
Update the log output to show the size, since this is useful information. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Drop CheckEntries()Simon Glass1-1/+0
This method introduces a separation between packing and checking that is different for sections. In order to handle compression properly, we need to be able to deal with a section's size being smaller than the uncompressed size of its contents. It is easier to make this work if everything happens in the Pack() method. The only real user of CheckEntries() is entry_Section and it can call it directly. Drop the call from 'control' and handle it locally. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Drop the Entry.CheckSize() methodSimon Glass1-1/+0
This is only used by entry_Section and that class already calls it. Avoid calling it twice. Also drop it from the documentation. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Avoid reporting image-pos with compressionSimon Glass1-1/+1
When a section is compressed, all entries within it are grouped together into a compressed block of data. This obscures the start of each individual child entry. Avoid reporting bogus 'image-pos' properties in this case, since it is not possible to access the entry at the location provided. The entire section must be decompressed first. CBFS does not support compressing whole sections, only individual files, so needs no special handling here. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22binman: Support help messages for missing blobsSimon Glass1-1/+68
When an external blob is missing it can be quite confusing for the user. Add a way to provide a help message that is shown. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2020-09-22binman: Fix up a few missing commentsSimon Glass1-0/+5
Tidy up a few test functions which lack argument comments. Rename one that has the same name as a different test. Also fix up the comment for PrepareImagesAndDtbs(). Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22binman: Use pkg_resources to find resourcesSimon Glass1-2/+4
At present we look for resources based on the path of the Python module that wants them. Instead we should use Python's pkg_resources feature which is designed for this purpose. Update binman to use this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-22binman: Correct some import statementsSimon Glass1-2/+2
Some of these were not converted when binman moved to use absolute paths. Fix them. Also drop the import of 'test' which is a directory, not a module. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-08-22binman: Move GetEntryModules() to controlSimon Glass1-0/+13
When binman is installed its main program is in a different directory to its modules. This means that __file__ is different and we cannot use it to obtain the path to etype/ from main.py To fix this, move the function to the 'control' module, since it is installed with all the other modules, including the etype/ directory. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-25binman: Detect when valid images are not producedSimon Glass1-2/+14
When external blobs are missing, show a message indicating that the images are not functional. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-25binman: Allow external binaries to be missingSimon Glass1-2/+5
Sometimes it is useful to build an image even though external binaries are not present. This allows the build system to continue to function without these files, albeit not producing valid images. U-Boot does with with ATF (ARM Trusted Firmware) today. Add a new flag to binman to request this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini1-17/+2
This reverts commit 5d3a21df6694ebd66d5c34c9d62a26edc7456fc7, reversing changes made to 56d37f1c564107e27d873181d838571b7d7860e7. Unfortunately this is causing CI failures: https://travis-ci.org/github/trini/u-boot/jobs/711313649 Signed-off-by: Tom Rini <trini@konsulko.com>
2020-07-20binman: Detect when valid images are not producedSimon Glass1-2/+14
When external blobs are missing, show a message indicating that the images are not functional. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-20binman: Allow external binaries to be missingSimon Glass1-2/+5
Sometimes it is useful to build an image even though external binaries are not present. This allows the build system to continue to function without these files, albeit not producing valid images. U-Boot does with with ATF (ARM Trusted Firmware) today. Add a new flag to binman to request this behaviour. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-04-26patman: Move to absolute importsSimon Glass1-3/+3
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>
2020-04-26binman: Move to absolute importsSimon Glass1-6/+6
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>
2020-04-26patman: Drop references to __future__Simon Glass1-2/+0
We don't need these now that the tools using Python 3. Drop them. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-15binman: Add logging for the number of pack passesSimon Glass1-0/+1
Sometimes binman takes multiple passes to complete packing an image. Add logging to indicate this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-15binman: Write symbol info before image inclusionSimon Glass1-1/+1
At present the symbol information is written to binaries just before binman exits. This is fine for entries within sections since the section contents is calculated when it is needed, so the updated symbol values are included in the image that is written. However some binaries are inside entries which have already generated their contents and do not notice that the entries have changed (e.g. Intel IFWI). Move the symbol writing earlier to cope with this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-15binman: Allow use of help and entry-docs without libfdtSimon Glass1-2/+10
At present if libfdt is not available binman can't do anything much. Improve the situation a little. Ideally there should be a test to cover this, but I'm not quite sure how to fake this. Signed-off-by: Simon Glass <sjg@chromium.org> (fixed up missing ReadChildData() enty test)
2019-10-08binman: Allow verbose output with all commandsSimon Glass1-21/+15
At present the verbose flag only works for the 'build' command. This is not intended, nor is it useful. Update the code to support the verbose flag and make use of a command exception handler. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> [bmeng: rebase the patch against u-boot-x86/next to get it applied cleanly] Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
2019-07-29binman: Add command-line support for replacing entriesSimon Glass1-0/+75
Add a 'replace' command to binman to permit entries to be replaced, either individually or all at once (using a filter). Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Correct the error message for invalid pathSimon Glass1-2/+2
At present this message references -o for output file. But binman uses -f now. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Split control.WriteEntryToImage() into separate functionsSimon Glass1-17/+59
This code has three distinct phases: 1. The image is loaded and the state module is set up 2. The entry is written to the image 3. The image is repacked and written back to the file Split the code out with three separate functions, one for each phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Update control.WriteEntry() to support writing the mapSimon Glass1-4/+6
Add the ability to write a new map file. Also tidy up a few comments and rename a misleading variable. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Move control.WriteEntry further down the fileSimon Glass1-41/+40
Move this function after the extraction logic so we can keep the writing logic in one place. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support replacing data in a cbfsSimon Glass1-1/+1
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>
2019-07-29binman: Support shrinking a entry after packingSimon Glass1-1/+1
Sometimes an entry may shrink after it has already been packed. In that case we must repack the items. Of course it is always possible to just leave the entry at its original size and waste space at the end. This is what binman does by default, since there is the possibility of the entry changing size every time binman calculates its contents, thus causing a loop. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Allow updating entries that change sizeSimon Glass1-5/+24
So far we don't allow entries to change size when repacking. But this is not very useful since it is common for entries to change size after an updated binary is built, etc. Add support for this, respecting the original offset/size/alignment constraints of the image layout. For this to work the original image must have been created with the 'allow-repack' property. This does not support entry types with sub-entries such as files and CBFS, but it does support sections. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Write the original input fdtmap to a fileSimon Glass1-1/+5
When reading an image in, write its fdtmap to a file in the output directory. This is useful for debugging. Update the 'ls' command to set up the output directory; otherwise it will fail. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support updating entries in an existing imageSimon Glass1-2/+31
While it is useful and efficient to build images in a single pass from a unified description, it is sometimes desirable to update the image later. Add support for replace an existing file with one of the same size. This avoids needing to repack the file. Support for more advanced updates will come in future patches. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Rename state.GetFdts()Simon Glass1-3/+3
This function name conflicts with Entry.GetFdts() which has a different purpose. Rename it to avoid confusion. Also update a stale comment relating to this function. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Move image/fdt code into PrepareImagesAndDtbs()Simon Glass1-54/+71
Further reduce the size of the main Binman() function by moving this setup code into its own function. Note that the 'images' value is accessed from other modules so must be made a global. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Move image-processing code into a functionSimon Glass1-46/+57
The Binman() function is very long. Split out the image code to make it more manageable. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add an 'extract' commandSimon Glass1-0/+60
It is useful to be able to extract all binaries from the image, or a subset of them. Add a new 'extract' command to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow reading an entry from an imageSimon Glass1-0/+20
It is useful to be able to extract entry contents from an image to see what is inside. Add a simple function to read the contents of an entry, decompressing it by default. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Support listing an imageSimon Glass1-0/+35
Add support for listing the entries in an image. This relies on the image having an FDT map. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow entries to expand after packingSimon Glass1-15/+36
Add support for detecting entries that change size after they have already been packed, and re-running packing when it happens. This removes the limitation that entry size cannot change after PackEntries() is called. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Convert to use ArgumentParserSimon Glass1-26/+25
This class is the new way to handle arguments in Python. Convert binman over to use it. At the same time, introduce commands so that we can separate out the different parts of binman functionality. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add support for CBFS entriesSimon Glass1-0/+2
Add support for putting CBFSs (Coreboot Filesystems) in an image. This allows binman to produce firmware images used by coreboot to boot. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add a --toolpath option to set the tool search pathSimon Glass1-0/+1
Sometimes tools used by binman may not be in the normal PATH search path, such as when the tool is built by the U-Boot build itself (e.g. mkimage). Provide a way to specify an additional search path for tools. The flag can be used multiple times. Update the help to describe this option. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-11binman: Avoid changing a dict during iterationSimon Glass1-2/+5
This code works OK in Python 2 but Python 3 complains. Adjust it to avoid deleting elements from a dict while iterating through it. Signed-off-by: Simon Glass <sjg@chromium.org>