summaryrefslogtreecommitdiff
path: root/tools/binman/control.py
Commit message (Collapse)AuthorAgeFilesLines
* patman: Move to absolute importsSimon Glass2020-04-261-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>
* binman: Move to absolute importsSimon Glass2020-04-261-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>
* 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: Add logging for the number of pack passesSimon Glass2019-10-151-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>
* binman: Write symbol info before image inclusionSimon Glass2019-10-151-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>
* binman: Allow use of help and entry-docs without libfdtSimon Glass2019-10-151-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)
* binman: Allow verbose output with all commandsSimon Glass2019-10-081-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>
* binman: Add command-line support for replacing entriesSimon Glass2019-07-291-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>
* binman: Correct the error message for invalid pathSimon Glass2019-07-291-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>
* binman: Split control.WriteEntryToImage() into separate functionsSimon Glass2019-07-291-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>
* binman: Update control.WriteEntry() to support writing the mapSimon Glass2019-07-291-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>
* binman: Move control.WriteEntry further down the fileSimon Glass2019-07-291-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>
* binman: Support replacing data in a cbfsSimon Glass2019-07-291-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>
* binman: Support shrinking a entry after packingSimon Glass2019-07-291-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>
* binman: Allow updating entries that change sizeSimon Glass2019-07-291-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>
* binman: Write the original input fdtmap to a fileSimon Glass2019-07-291-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>
* binman: Support updating entries in an existing imageSimon Glass2019-07-291-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>
* binman: Rename state.GetFdts()Simon Glass2019-07-291-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>
* binman: Move image/fdt code into PrepareImagesAndDtbs()Simon Glass2019-07-291-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>
* binman: Move image-processing code into a functionSimon Glass2019-07-291-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>
* binman: Add an 'extract' commandSimon Glass2019-07-241-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>
* binman: Allow reading an entry from an imageSimon Glass2019-07-241-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>
* binman: Support listing an imageSimon Glass2019-07-241-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>
* binman: Allow entries to expand after packingSimon Glass2019-07-241-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>
* binman: Convert to use ArgumentParserSimon Glass2019-07-241-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>
* binman: Add support for CBFS entriesSimon Glass2019-07-241-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>
* binman: Add a --toolpath option to set the tool search pathSimon Glass2019-07-231-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>
* binman: Avoid changing a dict during iterationSimon Glass2019-07-101-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>
* binman: Use items() instead of iteritems()Simon Glass2019-07-101-1/+1
| | | | | | | Python 3 requires this, and Python 2 allows it. Convert the code over to ensure compatibility with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Convert print statements to Python 3Simon Glass2019-07-101-2/+4
| | | | | | Update all print statements to be functions, as required by Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Don't show image-skip message by defaultSimon Glass2019-05-081-2/+2
| | | | | | | | | | | | This message is not very important since it is simply indicating that the user's instructions are being followed. Only show it when the verbosity level is above the default. Also drop the unnecessary extra newline on this message, which causes two line breaks. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
* binman: Allow writing a map file when something goes wrongSimon Glass2018-09-291-3/+9
| | | | | | | | | | | When we get a problem like overlapping regions it is sometimes hard to figure what what is going on. At present we don't write the map file in this case. However the file does provide useful information. Catch any packing errors and write a map file (if enabled with -m) to aid debugging. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support adding filesSimon Glass2018-09-291-0/+1
| | | | | | | | | | | | In some cases it is useful to add a group of files to the image and be able to access them at run-time. Of course it is possible to generate the binman config file with a set of blobs each with a filename. But for convenience, add an entry type which can do this. Add required support (for adding nodes and string properties) into the state module. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support updating all device tree filesSimon Glass2018-09-281-4/+2
| | | | | | | | | | | | | | Binman currently supports updating the main device tree with things like the position of each entry. Extend this support to SPL and TPL as well, since they may need (a subset of) this information. Also adjust DTB output files to have a .out extension since this seems clearer than having a .dtb extension with 'out' in the name somwhere. Also add a few missing comments and update the DT setup code to use ReadFile and WriteFile(). Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Allow control of whether a fake DT is usedSimon Glass2018-09-281-0/+1
| | | | | | | | | | | | | We use a fake device tree in tests most of the time since tests don't normally care about the actual data. For example, for U-Boot proper we use U_BOOT_DTB_DATA which is just a four-character string. This makes testing the image output against an expected value very easy. However in some cases, such as when the test wants to check that the DT output containing particular nodes, we do actually need the real DT. Add support for this, along with a command-line option to select 'test mode'. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Obtain the list of device trees from the configSimon Glass2018-09-281-1/+1
| | | | | | | | We always have a device tree for U-Boot proper. But we may also have one for SPL and TPL. Add a new Entry method to find out what DTs an entry has, and use that list when updating DTs. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move state logic into the state moduleSimon Glass2018-09-281-8/+13
| | | | | | | Rather than reaching into this module from control, move the code that needs this info into state. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Move state information into a new moduleSimon Glass2018-09-281-41/+9
| | | | | | | | | | | | At present the control module has state information in it, since it is the primary user of this. But it is a bit odd to have entries and other modules importing control to obtain this information. It seems better to have a dedicated state module, which control can use as well. Create a new module using code from control and update other modules to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
* dtoc: Allow syncing of the device tree back to a fileSimon Glass2018-09-281-0/+2
| | | | | | | | | | | At present we require the caller to manually update the device tree using individual calls to libfdt functions. This is not ideal. It would be better if we could make changes using the Python structure and then call a Sync() function to write them back. Add this feature to the Fdt class. Update binman and the tests to match. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support building a selection of imagesSimon Glass2018-09-281-0/+9
| | | | | | | | | Sometimes it is useful to build only a subset of the images provided by the binman configuration. Add a -i option for this. It can be given multiple times to build several images. If the option is not given, all images are built. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Allow creation of entry documentationSimon Glass2018-08-011-0/+4
| | | | | | | | | | | Binman supports quite a number of different entries now. The operation of these is not always obvious but at present the source code is the only reference for understanding how an entry works. Add a way to create documentation (from the source code) which can be put in a new 'README.entries' file. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Allow help to work without libfdtSimon Glass2018-08-011-2/+5
| | | | | | | | At present binman needs libfdt.py to be available before it will do anything, even print help. Import those modules later to avoid this, as it is bad practice to fail to even show help on startup. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add support for passing arguments to entriesSimon Glass2018-08-011-0/+19
| | | | | | | | | | | | | | | | | | Sometimes it is useful to pass binman the value of an entry property from the command line. For example some entries need access to files and it is not always convenient to put these filenames in the image definition (device tree). Add a -a option which can be used like this: -a<prop>=<value> where <prop> is the property to set <value> is the value to set it to Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a new 'image-pos' propertySimon Glass2018-08-011-0/+1
| | | | | | | | | | | | | | | | | At present each entry has an offset within its parent section. This is useful for figuring out how entries relate to one another. However it is sometimes necessary to locate an entry within an image, regardless of which sections it is nested inside. Add a new 'image-pos' property to provide this information. Also add some documentation for the -u option binman provides, which updates the device tree with final entry information. Since the image position is a better symbol to use for the position of U-Boot as obtained by SPL, update the SPL symbols to use this instead of offset, which might be incorrect if hierarchical sections are used. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Rename 'position' to 'offset'Simon Glass2018-08-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After some thought, I believe there is an unfortunate naming flaw in binman. Entries have a position and size, but now that we support hierarchical sections it is unclear whether a position should be an absolute position within the image, or a relative position within its parent section. At present 'position' actually means the relative position. This indicates a need for an 'image position' for code that wants to find the location of an entry without having to do calculations back through parents to discover this image position. A better name for the current 'position' or 'pos' is 'offset'. It is not always an absolute position, but it is always an offset from its parent offset. It is unfortunate to rename this concept now, 18 months after binman was introduced. However I believe it is the right thing to do. The impact is mostly limited to binman itself and a few changes to in-tree users to binman: tegra sunxi x86 The change makes old binman definitions (e.g. downstream or out-of-tree) incompatible if they use the 'pos = <...>' property. Later work will adjust binman to generate an error when it is used. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Support updating the device tree with calc'd infoSimon Glass2018-07-091-0/+2
| | | | | | | | It is useful to write the position and size of each entry back to the device tree so that U-Boot can access this at runtime. Add a feature to support this, along with associated tests. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a SetCalculatedProperties() methodSimon Glass2018-07-091-0/+4
| | | | | | | | | | | | Once binman has packed the image, the position and size of each entry is known. It is then possible for binman to update the device tree with these positions. Since placeholder values have been added, this does not affect the size of the device tree and therefore the packing does not need to be performed again. Add a new SetCalculatedProperties method to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add a ProcessFdt() methodSimon Glass2018-07-091-1/+51
| | | | | | | | | | | | | | | | Some entry types modify the device tree, e.g. to remove microcode or add a property. So far this just modifies their local copy and does not affect a 'shared' device tree. Rather than doing this modification in the ObtainContents() method, and a new ProcessFdt() method which is specifically designed to modify this shared device tree. Move the existing device-tree code over to use this method, reducing ObtainContents() to the goal of just obtaining the contents without any processing, even for device tree. Signed-off-by: Simon Glass <sjg@chromium.org>
* binman: Add support for outputing a map fileSimon Glass2018-06-071-0/+2
| | | | | | | | It is useful to be able to see a list of regions in each image produced by binman. Add a -m option to output this information in a '.map' file alongside the image file. Signed-off-by: Simon Glass <sjg@chromium.org>
* SPDX: Convert all of our single license tags to Linux Kernel styleTom Rini2018-05-071-2/+1
| | | | | | | | | | | | | | | | | | | | When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>