aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/state.py
AgeCommit message (Collapse)AuthorFilesLines
2023-07-20binman: Reduce state.SetInt and bintool cmd to debug levelSimon Glass1-2/+2
These are not very important message. Change them to use the 'debug' level instead of 'detail'. Signed-off-by: Simon Glass <sjg@chromium.org>
2023-03-08patman: Move library functions into a library directorySimon Glass1-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>
2023-03-08binman: Fix spelling of nodes in code commentsJonas Karlman1-1/+1
Replace notes with nodes in code comments and docstrings. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Simon Glass <sjg@chromium.org>
2022-09-12binman: Add VPL supportSimon Glass1-1/+2
Add support for U-Boot's Verifying Program Loader phase. Signed-off-by: Simon Glass <sjg@chromium.org>
2022-02-22binman: Correct the error message for a bad hash algorithmSimon Glass1-1/+1
This shows an internal type at present, rather than the algorithm name. Fix it and update the test to catch this. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2022-02-09patman: Convert camel case in tout.pySimon Glass1-8/+8
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 Glass1-9/+9
Convert this file to snake case and update all files which use it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-12-02binman: Add a way to obtain the versionSimon Glass1-0/+18
Add a -V option which shows the version number of binman. For now this just uses a local 'version' file. Once the tool is packaged in some way we can figure out an approach that suits. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21binman: Add basic support for debugging performanceSimon Glass1-0/+72
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/+23
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: Automatically expand phase binaries into sectionsSimon Glass1-1/+18
When creating an entry, check for an expanded version of that entry, then use it instead. This allows, for example use of: u-boot { }; instead of having to write out in full: u-boot { type = "section"; u-boot-nodtb { }; u-boot-dtb { }; }; Add an implementaion of this and associated documentation. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Use standard filenames for SPL/TPL devicetreeSimon Glass1-11/+10
At present, before any entry expansion is done (such as a 'files' entry expanding out to individual entries for each file it contains), we check the binman definition (i.e. '/binman' node) to find out what devicetree files are used in the images. This is a pain, since the definition may change during expansion. For example if there is no u-boot-spl-dtb entry in the definition at the start, we assume that the SPL devicetree is not used. But if an entry later expands to include this, then we don't notice. In fact the flexibility provided by the current approach of checking the definition is not really useful. We know that we can have SPL and TPL devicetrees. We know the pathname to each, so we can simply check if the files are present. If they are present, we can prepare them and update them regardless of whether they are actually used. If they are not present, we cannot prepare/update them anyway, i.e. an error will be generated. Simplify state.Prepare() so it uses a hard-coded list of devicetree files. Note that state.PrepareFromLoadedData() is left untouched, since in that case we have a complete definition from the loaded file, but cannot of course rely on the devicetree files that created it still being present. So in that case we still check the image defitions. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Drop unnecessary field in output_fdt_infoSimon Glass1-12/+10
At present we store an entry as the third field in output_fdt_info[]. This is only used to get the type of the entry. Of course multiple entries may have this same type. Also the entry type is the key to this dict, so we can use that instead. Drop the field and update GetUpdateNodes() to suit. Improve the comment for output_fdt_info a little while here. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-26binman: Use the fake SPL/TPL only if requestedSimon Glass1-8/+15
At present we always use the main devicetree for SPL/TPL as well when setting up the state. But this it not needed if there is a real devicetree for SPL or TPL. In fact it confuses things since we cannot distinguish between one being provided and using the fake one. Update the code to create the fakes only when requested. Put the mapping in a constant so we can use it elsewhere. Rename 'other_fname' to 'fname' while we are here since there is nothing 'other' about it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-01-30binman: Support alignment of filesSimon Glass1-0/+10
When packing files it is sometimes useful to align the start of each file, e.g. if the flash driver can only access 32-bit-aligned data. Provides a new property to support this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-04-26patman: Move to absolute importsSimon Glass1-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>
2020-04-26binman: Move to absolute importsSimon Glass1-3/+3
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>
2019-07-29binman: Update state when replacing device-tree entriesSimon Glass1-0/+16
Since the state module holds references to all the device trees used by binman, it must be updated when the device trees are updated. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support shrinking a entry after packingSimon Glass1-0/+27
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-1/+2
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: Add info to allow safely repacking an image laterSimon Glass1-6/+15
At present it is not possible to discover the contraints to repacking an image (e.g. maximum section size) since this information is not preserved from the original image description. Add new 'orig-offset' and 'orig-size' properties to hold this. Add them to the main device tree in the image. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support updating entries in an existing imageSimon Glass1-21/+53
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: Store the entry in output_fdt_filesSimon Glass1-15/+34
In some cases we want to access the Entry object for a particular device tree. This allows us to read its contents or update it. Add this information to output_fdt_files and provide a function to read it. Also rename output_fdt_files since its name is no-longer descriptive. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Allow state functions to fail to return dataSimon Glass1-2/+7
At present these state functions raise an exception if they cannot find what is requested. But in some cases the information is optional (e.g. an fdtmap in a coming patch) so it is better to return gracefully. Update these two functions to return None when the data cannot be found. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Drop state.fdt_set as this is not neededSimon Glass1-10/+3
We can iterate through the output files so don't need this global anymore. Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Simplify state.fdt_subsetSimon Glass1-10/+11
At present this excludes the device tree passed in to binman since it is always returned first by GetAllFdts(). However, this is easy to ensure by adding a check in that function. Change this dict to includes all device trees, and rename it to fdt_set. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Adjust state.fdt_files to be keyed by entry typeSimon Glass1-24/+33
It makes more sense to use entry type as the key for this dictionary, since the filename can in principle be anything. Make this change and also rename fdt_files and add a comment to explain it better. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Adjust GetFdt() to be keyed by etypeSimon Glass1-5/+9
At present the FDTs are keyed by their default filename (not their actual filename). It seems easier to key by the entry type, since this is always the same for each FDT type. To do this, add a new Entry method called GetFdtEtype(). This is necessary since some entry types contain a device tree which are not the simple three entry types 'u-boot-dtb', 'u-boot-spl' or 'u-boot-tpl'. The code already returns a dict for GetFdt(). Update the value of that dict to include the filename so that existing code can work. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Rename state.GetFdt()Simon Glass1-3/+4
This function name conflicts with Fdt.Node.GetFdt() which has a different purpose. Rename it to avoid confusion. The new name suggests it is indexed by entry type rather than filename. This will be tidied up in a future commit. 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: Convert GetFdtSet() to use a dictSimon Glass1-8/+6
At present this function returns a set of device-tree filenames. It has no way of returning the actual device-tree object. Change it to a dictionary so that we can add this feature in a future patch. Also drop fdt_set since it is no-longer used. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add a control for post-pack entry expansionSimon Glass1-0/+24
We plan to support changing the size of entries after they have been packed. For now it will always be enabled. But to aid testing of both cases (in the event that we want to add a command-line flag, for example), add a setting to control it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add an FDT mapSimon Glass1-1/+1
An FDT map is an entry which holds a full description of the image entries, in FDT format. It can be discovered using the magic string at its start. Tools can locate and read this entry to find out what entries are in the image and where each entry is located. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-10binman: Remove use of Set()Simon Glass1-4/+3
A new built-in set() is used in both Python 2 and 3 now. Move it to use that instead of Set(). Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29binman: Support hashing entriesSimon Glass1-0/+25
Sometimesi it us useful to be able to verify the content of entries with a hash. Add an easy way to do this in binman. The hash information can be retrieved from the device tree at run time. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-29binman: Support adding filesSimon Glass1-0/+27
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>
2018-09-28binman: Support updating all device tree filesSimon Glass1-0/+30
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>
2018-09-28binman: Allow control of whether a fake DT is usedSimon Glass1-1/+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>
2018-09-28binman: Obtain the list of device trees from the configSimon Glass1-2/+18
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>
2018-09-28binman: Centralise device-tree updates within binmanSimon Glass1-0/+35
At present we have a few calls to device-tree functions in binman and plan to add more as we add new entry types which need to report their results. It makes sense to put this code in a central place so that we can make sure all device trees are updated. At present we only have U-Boot proper, but plan to add SPL and TPL too. Signed-off-by: Simon Glass <sjg@chromium.org>
2018-09-28binman: Move state logic into the state moduleSimon Glass1-0/+43
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>
2018-09-28binman: Move state information into a new moduleSimon Glass1-0/+77
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>