summaryrefslogtreecommitdiffstats
path: root/tools/binman/state.py
Commit message (Collapse)AuthorAgeFilesLines
* 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-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>
* binman: Update state when replacing device-tree entriesSimon Glass2019-07-291-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>
* binman: Support shrinking a entry after packingSimon Glass2019-07-291-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>
* binman: Allow updating entries that change sizeSimon Glass2019-07-291-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>
* binman: Add info to allow safely repacking an image laterSimon Glass2019-07-291-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>
* binman: Support updating entries in an existing imageSimon Glass2019-07-291-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>
* binman: Store the entry in output_fdt_filesSimon Glass2019-07-291-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>
* binman: Allow state functions to fail to return dataSimon Glass2019-07-291-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>
* binman: Drop state.fdt_set as this is not neededSimon Glass2019-07-291-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>
* binman: Simplify state.fdt_subsetSimon Glass2019-07-291-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>
* binman: Adjust state.fdt_files to be keyed by entry typeSimon Glass2019-07-291-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>
* binman: Adjust GetFdt() to be keyed by etypeSimon Glass2019-07-291-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>
* binman: Rename state.GetFdt()Simon Glass2019-07-291-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>
* 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: Convert GetFdtSet() to use a dictSimon Glass2019-07-291-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>
* binman: Add a control for post-pack entry expansionSimon Glass2019-07-241-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>
* binman: Add an FDT mapSimon Glass2019-07-241-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>
* binman: Remove use of Set()Simon Glass2019-07-101-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>
* binman: Support hashing entriesSimon Glass2018-09-291-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>
* binman: Support adding filesSimon Glass2018-09-291-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>
* binman: Support updating all device tree filesSimon Glass2018-09-281-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>
* binman: Allow control of whether a fake DT is usedSimon Glass2018-09-281-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>
* binman: Obtain the list of device trees from the configSimon Glass2018-09-281-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>
* binman: Centralise device-tree updates within binmanSimon Glass2018-09-281-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>
* binman: Move state logic into the state moduleSimon Glass2018-09-281-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>
* binman: Move state information into a new moduleSimon Glass2018-09-281-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>