aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/entry.py
AgeCommit message (Collapse)AuthorFilesLines
2020-11-05binman: Correct calculation for image-posSimon Glass1-1/+1
A recent change removed the base offset from the calculation. This is used on coral to find the FSP-S binary. Fix it. Fixes: a9fad07d4b8 ("binman: Avoid reporting image-pos with compression") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-11-05binman: Update intel_ifwi to store padded sectionSimon Glass1-0/+16
With a recent change this entry stores only part of the section data, leaving out the padding at the end. Fix this by using GetPaddedData() to get the data. Add this function to the base Entry class also. Fixes: d1d3ad7d1fe ("binman: Move section padding to the parent") Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Drop Entry.CheckOffset()Simon Glass1-1/+1
This function just calls CheckEntries() in the only non-trivial implementation. Drop it and use CheckEntries() directly. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Avoid reporting image-pos with compressionSimon Glass1-4/+14
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-10-29binman: Set section contents in GetData()Simon Glass1-0/+6
Section contents is not set up when ObtainContents() is called, since packing often changes the layout of the contents. Ensure that the contents are correctly recorded by making this function regenerate the section. It is normally only called by the parent section (when packing) or by the top-level image code, when writing out the image. So the performance impact is fairly small. Now that sections have their contents in their 'data' property, update testSkipAtStartSectionPad() to check it. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Store the original data before compressionSimon Glass1-1/+6
When compressing an entry, the original uncompressed data is overwritten. Store it so it is available if needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Expand docs and test for alignmentSimon Glass1-2/+4
Alignment does form part of the entry once the image is written out, but within binman the entry contents does not include the padding. Add documentation to make this clear, as well as a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Expand docs and test for paddingSimon Glass1-3/+8
Padding becomes part of the entry once the image is written out, but within binman the entry contents does not include the padding. Add documentation to make this clear, as well as a test. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-10-29binman: Move CompressData() into Entry base classSimon Glass1-0/+17
At present this is only used by blobs. To allow it to be used by other entry types (such as sections), move it into the base class. Also read the compression type in the base class. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22binman: Support help messages for missing blobsSimon Glass1-0/+9
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: Move 'external' support into base classSimon Glass1-0/+14
At present we have an Entry_blob_ext which implement a blob which holds an external binary. We need to support other entry types that hold external binaries, e.g. Entry_blob_named_by_arg. Move the support into the base Entry class to allow this. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-09-22tools: Drop unnecessary use of __file__Simon Glass1-2/+0
There are few places where the path of the current modules is calculated but not used. Drop them. Signed-off-by: Simon Glass <sjg@chromium.org>
2020-07-25binman: Detect when valid images are not producedSimon Glass1-0/+12
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-0/+9
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-21/+0
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-0/+12
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-0/+9
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-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-11/+5
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-11-04binman: Remember the pre-reset entry sizeSimon Glass1-1/+8
When preparing to possible expand or contract an entry we reset the size to the original value from the binman device-tree definition, which is often None. This causes binman to forget the original size of the entry. Remember this so that it can be used when needed. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-11-04pylibfdt: Convert to Python 3Simon Glass1-14/+2
Build this swig module with Python 3. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-10-15binman: Allow use of help and entry-docs without libfdtSimon Glass1-1/+4
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: Handle reading data for end-at-4gb sectionsSimon Glass1-2/+4
Some x86 sections have special offsets which currently result in empty data being returned from the 'extract' command. Fix this by taking account of the skip-at-start property. Add a little more debugging while we are here. Signed-off-by: Simon Glass <sjg@chromium.org> Acked-by: Bin Meng <bmeng.cn@gmail.com>
2019-10-08binman: Add a base implementation of Entry.ReadChildData()Simon Glass1-0/+16
At present this function is not present in the Entry base class so it is hard to find the documentation for it. Move the docs from the section class and expand it a little. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2019-07-29binman: Update Entry.WriteData() to handle special sectionsSimon Glass1-1/+20
At present this method assumes that the parent section does not need to recalculate its position or adjust any metadata it may contain. But when the entry changes size this may not be true. Also if the parent section is more than just a container (e.g. it is a CBFS) then the section may need to regenerate its output. Add a new WriteChildData() method to sections and call this from the WriteData() method, to handle this situation. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Update Entry.ReadEntry() to work through classesSimon Glass1-5/+2
At present we simply extract the data directly from entries using the image_pos information. This happens to work on current entry types, but cannot work if the entry type encodes the data in some way. Update the ReadData() method to provide the data by calling a new ReadChildData() method in the parent. This allows the entry_Section class, or possibly any other container class, to return the correct data in all cases. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support shrinking a entry after packingSimon Glass1-9/+19
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: Add more tests for image header positionSimon Glass1-0/+15
The positioning does not currently work correctly if at the end of an image with no fixed size. Also if the header is in the middle of an image it can cause a gap in the image since the header position is normally at the image end, so entries after it are placed after the end of the image. Fix these problems and add more tests to cover these cases. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Add info to allow safely repacking an image laterSimon Glass1-2/+16
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-0/+23
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: Add a function to obtain the image for an EntrySimon Glass1-0/+8
At present we have an 'image' property in the entry for this purpose, but this is not necessary and seems error-prone in the presence of inheritance. Add a function instead. The Entry_section class overrides this with a special version, since top-level sections are in fact images, since Image inherits Entry_section. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Adjust Entry to read the node in a separate callSimon Glass1-3/+3
At present the Entry constructor sets up the object and then immediately reads its device-tree node to obtain its properties. This breaks a convention that constructors should not do any processing. A consequence is that we must pass all arguments to the constructor and cannot have the node-reading proceed in a different way unless we pass flags to that constructor. We already have a 'test' flag in a few cases, and now need to control whether the 'orig_offset' and 'orig_size' properties are set or not. Adjust the code to require a separate call to ReadNode() after construction. The Image class remains as it was. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Support loading entry data from a fileSimon Glass1-0/+5
When modifying an image it is convenient to load the data from the file into each entry so that it can be reprocessed. Add a new LoadData() method to handle this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Add a bit of logging in entries when packingSimon Glass1-2/+18
Use the new logging feature to log information about progress with packing. This is useful to see how binman is figuring things out. Also update elf.py to use the same feature. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-29binman: Adjust GetFdt() to be keyed by etypeSimon Glass1-1/+3
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: Convert GetFdtSet() to use a dictSimon Glass1-5/+7
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-29binman: Move GetFdtSet() into blob_dtbSimon Glass1-5/+0
At present we check the filename to see if an entry holds a device-tree file. It is easier to use the base class designed for this purpose. Move this method implementation into Entry_blob_dtb and update the default one to return an empty set. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow reading an entry from an imageSimon Glass1-0/+21
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: Allow for logging information to be displayedSimon Glass1-1/+2
Binman generally operates silently but in some cases it is useful to see what Binman is actually doing at each step. Enable some logging output with different logging levels selectable via the -v flag. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Convert Image to a subclass of EntrySimon Glass1-4/+4
When support for sections (and thus hierarchical images) was added to binman, the decision was made to create a new Section class which could be used by both Image and an Entry_section class. The decision between using inheritance and composition was tricky to make, but in the end it was decided that Image was different enough from Entry that it made sense to put the implementation of sections in an entirely separate class. It also has the advantage that core Image code does have to rely on an entry class in the etype directory. This work was mostly completed in commit: 8f1da50ccc "binman: Refactor much of the image code into 'section' As a result of this, the Section class has its own version of things like offset and size and these must be kept in sync with the parent Entry_section class in some cases. In the last year it has become apparent that the cost of keeping things in sync is larger than expected, since more and more code wants to access these properties. An alternative approach, previously considered and rejected, now seems better. Adjust Image to be a subclass of Entry_section. Move the code from Section (in bsection.py) to Entry_section and delete Section. Update all tests accordingly. This requires substantial changes to Image. Overall the changes reduce code size by about 240 lines. While much of that is just boilerplate from Section, there are quite a few functions in Entry_section which now do not need to be overiden from Entry. This suggests the change is beneficial even without further functionality being added. A side benefit is that the properties of sections are now consistent with other entries. This fixes a problem in testListCmd() where some properties are missing for sections. Unfortunately this is a very large commit since it is not feasible to do the migration piecemeal. Given the substantial tests available and the 100% code coverage of binman, we should be able to do this safely. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Support reading an image into an Image objectSimon Glass1-0/+5
It is possible to read an Image, locate its FDT map and then read it into the binman data structures. This allows full access to the entries that were written to the image. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow listing the entries in an imageSimon Glass1-0/+36
It is useful to be able to summarise all the entries in an image, e.g. to display this to this user. Add a new ListEntries() method to Entry, and set up a way to call it through the Image class. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow entries to expand after packingSimon Glass1-2/+19
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: Add a return value to ProcessContentsUpdate()Simon Glass1-2/+20
At present if this function tries to update the contents such that the size changes, it raises an error. We plan to add the ability to change the size of entries after packing is completed, since in some cases it is not possible to determine the size in advance. An example of this is with a compressed device tree, where the values of the device tree change in SetCalculatedProperties() or ProcessEntryContents(). While the device tree itself does not change size, since placeholders for any new properties have already bee added by AddMissingProperties(), we cannot predict the size of the device tree after compression. If a value changes from 0 to 0x1234 (say), then the compressed device tree may expand. As a first step towards supporting this, make ProcessContentsUpdate() return a value indicating whether the content size is OK. For now this is always True (since otherwise binman raises an error), but later patches will adjust this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Fix up ProcessUpdateContents error and commentsSimon Glass1-4/+4
This function raises an exception with its arguments around the wrong way so the message is incorrect. Fix this as well as a few minor comment problems. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Allow easy importing of entry modulesSimon Glass1-0/+2
At present entry modules can only be accessed using Entry.Lookup() or Entry.Create(). Most of the time this is fine, but sometimes a module needs to provide constants or helper functions useful to other modules. It is easier in this case to use 'import'. Add an __init__ file to permit this. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Drop an unused arg in Entry.Lookup()Simon Glass1-4/+3
The first argument is not used. Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Move compression into the Entry base classSimon Glass1-0/+9
Compression is currently available only with blobs. However we want to report the compression algorithm and uncompressed size for all entries, so that other entry types can support compression. This will help with the forthcoming 'list' feature which lists entries in the image. Move the compression properties into the base class. Also fix up the docs which had the wrong property name. Signed-off-by: Simon Glass <sjg@chromium.org>
2019-07-24binman: Add an image headerSimon Glass1-0/+11
It is useful to be able to quickly locate the FDT map in the image. An easy way to do this is with a pointer at the start or end of the image. Add an 'image header' entry, which places a magic number followed by a pointer to the FDT map. This can be located at the start or end of the image, or at a chosen location. As part of this, update GetSiblingImagePos() to detect missing siblings. Signed-off-by: Simon Glass <sjg@chromium.org>