summaryrefslogtreecommitdiff
path: root/tools/fit_image.c
AgeCommit message (Collapse)Author
2026-02-02mkimage: fit: align DTs in external data to 8 Bytes by defaultMarek Vasut
Unless specified otherwise using the mkimage -B n option, align DTs in fitImage external data to 8 Bytes, and retain alignment of everything else to 4 Bytes. This should fulfill the DTspec requirement, that DTs must be placed at 8 Byte aligned addresses, even for DTs that are part of fitImage with external data. For fitImage with embedded data, there is nothing we can do, as the embedded data are aligned to 4 Bytes, just like any other DT property. Replace fdtdec_get_child_count() counting of images with counting of padding using fdt_for_each_subnode(). This is much more useful, as the added up padding can be passed directly to calloc() when allocating the buffer which holds the external data. The image count is no longer needed. Adjust the image layouting such, that buf_ptr is incremented to place the next image at align_size aligned offset. This is done at the beginning of the loop, once the align_size for current image can be determined from the current image type. Update binman test to validate the new 8 Byte alignment. Signed-off-by: Marek Vasut <[email protected]>
2025-12-06Merge patch series "test/py: fit: Deduplicate the test"Tom Rini
This series from Marek Vasut <[email protected]> cleans up some of the FIT pytests we have and then extends mkimage to support including the TEE in FIT images when using "-f auto" to create the resulting FIT. Link: https://lore.kernel.org/r/[email protected]
2025-12-06mkimage: Add support for bundling TEE in mkimage -f autoMarek Vasut
Introduce two new parameters to be used with mkimage -f auto to bundle TEE image into fitImage, using auto-generated fitImage. Add -z to specify TEE file name and -Z to specify TEE load and entry point address. This is meant to be used with systems which boot all of TEE, Linux and its DT from a single fitImage, all booted by U-Boot. Example invocation: " $ mkimage -E -A arm -C none -e 0xc0008000 -a 0xc0008000 -f auto \ -d arch/arm/boot/zImage \ -b arch/arm/boot/dts/st/stm32mp135f-dhcor-dhsbc.dtb \ -z ../optee_os/out/arm-plat-stm32mp1/core/tee-raw.bin \ -Z 0xde000000 \ /path/to/output/fitImage " Documentation update and test are also included, the test validates both positive and negative test cases, where fitImage does not include TEE and does include TEE blobs. Acked-by: Quentin Schulz <[email protected]> Signed-off-by: Marek Vasut <[email protected]>
2025-12-06fit: support signing with only an engine_idQuentin Schulz
Currently, when one wants to use an OpenSSL engine to sign a FIT image, one needs to pass a keydir (via -k) to mkimage which will then be prepended to the value of the key-name-hint before being passed as key_id argument to the OpenSSL Engine API, or pass a keyfile (via -G) to mkimage. My OpenSSL engine only has "slots" which are not mapped like directories, so using keydir is not proper, though I could simply have -k '' I guess but this won't work currently with binman anyway. Additionally, passing a keyfile (-G) when using an engine doesn't make sense as the key is stored in the engine. Let simply allow FIT images be signed if both keydir and keyfile are missing but an engine is to be used. The keyname member is already filled by looking at key-name-hint property in the FIT and passed to the engine, which is exactly what is needed here. Reviewed-by: Wolfgang Wallner <[email protected]> Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Quentin Schulz <[email protected]>
2025-10-10mkimage: fit: erase data-size property when importing dataQuentin Schulz
When importing data, the data-offset property is removed and the data content is imported inside the data property of the node. When mkimage is run twice on the same FIT, data-size property is already set in the second run, from the first run (via the fit_export_data function). If we don't remove the data-size property, nothing guarantees it matches the actual size of data within the data property. To avoid possible mistakes when handling the data property, let's simply remove the data-size property as well. This also fixes an ordering issue of the data-size and data-offset properties in FIT when comparing the FIT after one run of mkimage and a second run. This is due to fit_export_data setting data-offset property first (it doesn't exist so it's added) and then data-size (it doesn't exist so it's added) for the first run, while it sets data-offset property first (removed in fit_import_data, so it doesn't exist so it's added) and then data-size (it exists already from the first run, so it's simply modified) for the second run. Signed-off-by: Quentin Schulz <[email protected]>
2025-10-10mkimage: fit: do not ignore fdt_setprop return codeQuentin Schulz
All explicit calls to fdt_setprop* in tools/ are checked except those three. Let's add a check for the return code of fdt_setprop_u32() calls. Signed-off-by: Quentin Schulz <[email protected]>
2025-10-10mkimage: fit: do not overwrite fdt_setprop return valueQuentin Schulz
The return code of fdt_setprop is overwritten by the one from fdt_delprop meaning we could very well have an issue when setting the property that would be ignored if the deletion of the property that comes right after passes. Let's add a separate check for each. Fixes: 4860ee9b09e0 ("mkimage: allow internalization of data-position") Signed-off-by: Quentin Schulz <[email protected]>
2025-09-24Revert "Merge patch series "mkimage: Detect FIT image load address overlaps ↵Tom Rini
and fix related test/DTS issues"" This reverts commit 4d84fa1261eb27d57687f2e4c404a78b8653c183, reversing changes made to b82a1fa7ddc7f3be2f3b75898d5dc44c34420bdd. I had missed some feedback on this series from earlier, and we have since had reports of regressions due to this as well. For now, revert this. Signed-off-by: Tom Rini <[email protected]>
2025-09-23Merge patch series "mkimage: Detect FIT image load address overlaps and fix ↵Tom Rini
related test/DTS issues" Aristo Chen <[email protected]> says: This patch series enhances FIT image robustness by adding **memory region overlap detection** to `mkimage` and fixing existing overlaps in DTS files and `binman` tests. The primary goal is to prevent runtime memory corruption from conflicting load addresses in FIT images. Key Changes: 1. `mkimage` Overlap Detection: A new validation in `tools/fit_image.c` checks for overlapping load addresses within FIT configurations. `mkimage` now errors out with detailed info on conflicts, preventing bad FIT image creation. 2. New Test Case: A Python test verifies the new detection. It intentionally creates an overlap (kernel and FDT) to confirm correct error handling. 3. Fixes for Existing Overlaps: * Board DTS (k3-am6xx): Adjusted load addresses for TI firmware stubs to prevent conflicts. This resolves previously undetected overlaps. * `binman` Tests: Fixed several tests. U-Boot load addresses were shifted to avoid ATF conflicts. A new linker script for TEE ELF sections ensures distinct memory layouts. 4. Documentation: Added guidance for developers on how to determine ELF load addresses using readelf, linker scripts, and objdump when working with binman FIT images. Impact: This series improves FIT image reliability by catching overlaps at build time, helping developers resolve issues before runtime failures. Link: https://lore.kernel.org/r/[email protected]
2025-09-23tools: mkimage: detect overlapping load regions in FIT configurationsAristo Chen
This patch adds a validation step in mkimage to detect memory region overlaps between images specified in the same configuration of a FIT image. If any overlaps are found, the tool prints an error and aborts the build. This helps prevent runtime memory corruption caused by conflicting load addresses between images. Signed-off-by: Aristo Chen <[email protected]>
2025-09-12mkimage: Add support for bundling TFA BL31 in mkimage -f autoMarek Vasut
Introduce two new parameters to be used with mkimage -f auto to bundle TFA BL31 image into fitImage, using auto-generated fitImage. Add -y to specify TFA BL31 file name and -Y to specify TFA BL31 load and entry point address. This is meant to be used with systems which boot all of TFA BL31, Linux and its DT from a single fitImage, all booted by U-Boot. Example invocation: " $ mkimage -E -A arm64 -C none -e 0x50200000 -a 0x50200000 -f auto \ -d arch/arm64/boot/Image \ -b arch/arm64/boot/dts/renesas/r8a779g3-sparrow-hawk.dtb \ -y ../tfa/build/rcar_gen4/release/bl31.bin -Y 0x46400000 \ /path/to/output/fitImage " Documentation update and test are also included, the test validates both positive and negative test cases, where fitImage does not include TFA BL31 and does include TFA BL31 blobs. Signed-off-by: Marek Vasut <[email protected]>
2025-07-23Merge patch series "mkimage: validate default configuration reference"Tom Rini
Aristo Chen <[email protected]> says: This patch series introduces a validation step in `mkimage` to ensure that the `default` property under the `/configurations` node in a FIT image references a valid subnode. If the referenced node does not exist, mkimage now prints an error and fails early. This helps prevent runtime failures when U-Boot attempts to boot using an undefined configuration. The first patch implements the validation logic in `fit_image.c`. The second patch fixes an invalid default configuration reference exposed by this new check in the `k3-am65-iot2050-boot-image.dtsi`. The final patch adds a test case to verify that mkimage correctly fails when an invalid default configuration is present in the ITS file. This series improves the robustness of FIT image generation and helps catch malformed image trees during build time. Link: https://lore.kernel.org/r/[email protected]
2025-07-23tools: fit_image: validate existence of default configuration nodeAristo Chen
When a FIT image declares a default configuration via the 'configurations/default' property, it must reference a valid subnode under the /configurations node. If the named default does not exist, U-Boot will fail to boot the image when no explicit configuration is provided. This patch adds a validation step in mkimage to check that the referenced default configuration node is present. If not, mkimage will print an error and abort. This helps catch malformed or outdated ITS files early at build time instead of deferring failure to runtime. Signed-off-by: Aristo Chen <[email protected]>
2025-07-15tools: mkimage: make size_inc a signed typeRasmus Villemoes
In the Fixes commit, I initialized size_inc from the return value of the new fit_estimate_hash_sig_size() helper. That helper may fail and report that by returning a negative value, but I overlooked that size_inc had type size_t, and hence the error check doesn't work. Change size_inc to have type int so the error check works. Inside the loop, it is passed to another function as a size_t parameter, but that's fine, because we know it is non-negative, and its value may be incremented in steps of 1024 and is capped at ~64K, so it will certainly never overflow an int. Fixes: 7d4eacb0e68 ("mkimage: do a rough estimate for the size needed for hashes/signatures") Addresses-Coverity-ID: 569495: Integer handling issues (NEGATIVE_RETURNS) Signed-off-by: Rasmus Villemoes <[email protected]>
2025-06-26mkimage: do a rough estimate for the size needed for hashes/signaturesRasmus Villemoes
Background: I have several customers that will be using a certain remote signing service for signing their images, in order that the private keys are never exposed outside that company's secure servers. This is done via a pkcs#11 interface that talks to the remote signing server, and all of that works quite well. However, the way this particular signing service works is that one must upfront create a "signing session", where one indicates which keys one will use and, importantly, how many times each key will (may) be used. Then, depending on the keys requested and the customer's configuration, one or more humans must authorize that signing session So for example, if official release keys are to be used, maybe two different people from upper management must authorize, while if development keys are requested, the developer himself can authorize the session. Once authorized, the requester receives a token that must then be used for signing via one of the keys associated to that session. I have that integrated in Yocto in a way that when a CI starts a BSP build, it automatically works out which keys will be needed (e.g. one for signing U-Boot, another for signing a kernel FIT image) based on bitbake metadata, requests an appropriate signing session, and the appropriate people are then notified and can then look at the details of that CI pipeline and confirm that it is legitimate. The problem: The way mkimage does FIT image signing means that the remote server can be asked to perform a signature an unbounded number of times, or at least a number of times that cannot be determined upfront. This means that currently, I need to artificially say that a kernel key will be used, say, 10 times, even when only a single FIT image with just one configuration node is created. Part of the security model is that once the number of signings using a given key has been depleted, the authorization token becomes useless even if somehow leaked from the CI - and _if_ it is leaked/compromised and abused before the CI has gotten around to do its signings, the build will then fail with a clear indication of the compromise. Clearly, having to specify a "high enough" expected use count is counter to that part of the security model, because it will inevitably leave some allowed uses behind. While not perfect, we can give a reasonable estimate of an upper bound on the necessary extra size by simply counting the number of hash and signature nodes in the FIT image. As indicated in the comments, one could probably make it even more precise, and if there would ever be signatures larger than 512 bytes, probably one would have to do that. But this works well enough in practice for now, and is in fact an improvement in the normal case: Currently, starting with size_inc of 0 is guaranteed to fail, so we always enter the loop at least twice, even when not doing any signing but merely filling hash values. Just in case I've missed anything, keep the loop incrementing 1024 bytes at a time, and also, in case the estimate turns out to be over 64K, ensure that we do at least one attempt by changing to a do-while loop. With a little debug printf, creating a FIT image with three configuration nodes previously resulted in Trying size_inc=0 Trying size_inc=1024 Trying size_inc=2048 Trying size_inc=3072 Succeeded at size_inc=3072 and dumping info from the signing session (where I've artifically asked for 10 uses of the kernel key) shows "keyid": "kernel-dev-20250218", "usagecount": 9, "maxusagecount": 10 corresponding to 1+2+3+3 signatures requested (so while the loop count is roughly linear in the number of config nodes, the number of signings is quadratic). With this, I instead get Trying size_inc=3456 Succeeded at size_inc=3456 and the expected "keyid": "kernel-dev-20250218", "usagecount": 3, "maxusagecount": 10 thus allowing me to set maxusagecount correctly. Update a binman test case accordingly: With the previous behaviour, mkimage would try size_inc=0 and then size_inc=1024 and then succeed. With this patch, we first try, and succeed, with 4*128=512 due to the four hash nodes (and no signature nodes) in 161_fit.dts, so the image ends up 512 bytes smaller. Signed-off-by: Rasmus Villemoes <[email protected]>
2025-06-26tools: mkimage: validate image references in FIT configurationsAristo Chen
When parsing a FIT image source (ITS), mkimage does not currently check whether the image names referenced in the /configurations section (e.g. "kernel", "fdt", "ramdisk", "loadables") actually exist in the /images node. This patch introduces a validation step during FIT import that iterates over each configuration and verifies that all referenced image names are defined under /images. If a missing image is detected, an appropriate error is reported and mkimage exits with FDT_ERR_NOTFOUND. This ensures that configuration integrity is validated at build time. Signed-off-by: Aristo Chen <[email protected]>
2025-06-26tools: mkimage: propagate error codes from fit_handle_file()Aristo Chen
The fit_handle_file() function previously returned a hardcoded -1 on error. This change updates the logic to return the actual error code stored in `ret`, allowing for error propagation. This improves debuggability and enables downstream callers to distinguish different failure causes, such as FDT_ERR_NOTFOUND or other errors. Signed-off-by: Aristo Chen <[email protected]>
2025-01-22boot: Rename fit_image_get_data_and_size()Simon Glass
This function is really just getting the data. The size comes along for the ride. In fact this function is only reliable way to obtain the data for an image in a FIT, since the FIT may use external data. Rename it to fit_image_get_data() Signed-off-by: Simon Glass <[email protected]>
2024-04-10tools: open FIT image read-onlyAhelenia Ziemiańska
Open for reading as O_RDONLY instead of O_RDWR: the only usage of the fd is for the single read() below; this prevented mkimage -f auto -A arm64 \ -T kernel -C lz4 -d Image-6.6.15.lz4 \ -b mt8173-elm-hana-6.6.15.dtb outf when the inputs were unwritable. Link: https://bugs.debian.org/1063097 Signed-off-by: Ahelenia Ziemiańska <[email protected]> Reviewed-by: Dragan Simic <[email protected]>
2024-01-11tools: fix build without LIBCRYPTO supportPaul-Erwan Rio
Commit cb9faa6f98ae ("tools: Use a single target-independent config to enable OpenSSL") introduced a target-independent configuration to build crypto features in host tools. But since commit 2c21256b27d7 ("hash: Use Kconfig to enable hashing in host tools and SPL") the build without OpenSSL is broken, due to FIT signature/encryption features. Add missing conditional compilation tokens to fix this. Signed-off-by: Paul-Erwan Rio <[email protected]> Tested-by: Alexander Dahl <[email protected]> Cc: Simon Glass <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-10-11tools: ensure zeroed padding in external FIT imagesRoman Azarenko
Padding the header of an external FIT image is achieved by truncating the existing temporary FIT file to match the required alignment before appending image data. Reusing an existing file this way means that the padding will likely contain a portion of the original data not overwritten by the new header. Zero out any data past the end of the new header, and stop at either the end of the desired padding, or the end of the old FIT file, whichever comes first. Fixes: 7946a814a319 ("Revert "mkimage: fit: Do not tail-pad fitImage with external data"") Signed-off-by: Roman Azarenko <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-10-11mkimage: allow internalization of data-positionLars Feyaerts
Make it possible for data that was externalized using a static external position (-p) to be internalized. Enables the ability to convert existing FIT images built with -p to be converted to a FIT image where the data is internal, to be converted to a FIT image where the data is external relative to the end of the FIT (-E) or change the initial static external position to a different static external position (-p). Removing the original external-data-related properties ensures that they're not present after conversion. Without this, they would still be present in the resulting FIT even if the FIT has been, for example, internalized. Signed-off-by: Lars Feyaerts <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-04-13tools: imagetool: Extend print_header() by params argumentPali Rohár
This allows image type print_header() callback to access struct image_tool_params *params. Signed-off-by: Pali Rohár <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-01-27mkimage: fit: Support signed configurations in 'auto' FITsMassimo Pegorer
Extend support for signing in auto-generated (-f auto) FIT. Previously, it was possible to get signed 'images' subnodes in the FIT using options -g and -o together with -f auto. This patch allows signing 'configurations' subnodes instead of 'images' ones (which are hashed), using option -f auto-conf instead of -f auto. Adding also -K <dtb> and -r options, will add public key to <dtb> file with required = "conf" property. Summary: -f auto => FIT with crc32 images -f auto -g ... -o ... => FIT with signed images -f auto-conf -g ... -o ... => FIT with sha1 images and signed confs Example: FIT with kernel, two device tree files, and signed configurations; public key (needed to verify signatures) is added to u-boot.dtb with required = "conf" property. mkimage -f auto-conf -A arm -O linux -T kernel -C none -a 43e00000 \ -e 0 -d vmlinuz -b /path/to/first.dtb -b /path/to/second.dtb \ -k /folder/with/key-files -g keyname -o sha256,rsa4096 \ -K u-boot.dtb -r kernel.itb Example: Add public key with required = "conf" property to u-boot.dtb without needing to sign anything. This will also create a useless FIT named unused.itb. mkimage -f auto-conf -d /dev/null -k /folder/with/key-files \ -g keyname -o sha256,rsa4096 -K u-boot.dtb -r unused.itb Signed-off-by: Massimo Pegorer <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2023-01-18mkimage: Add a few more messages for FIT failuresSimon Glass
Add messages to make it clearer which part of the FIT creation is failing. This can happen when an invalid 'algo' property is provided in the .its file. Signed-off-by: Simon Glass <[email protected]>
2022-09-29treewide: Drop image_header_t typedefSimon Glass
This is not needed and we should avoid typedefs. Use the struct instead and rename it to indicate that it really is a legacy struct. Signed-off-by: Simon Glass <[email protected]>
2022-06-06mkimage: Support signing 'auto' FITsSean Anderson
This adds support for signing images in auto-generated FITs. To do this, we need to add a signature node. The algorithm name property already has its own option, but we need one for the key name hint. We could have gone the -G route and added an explicit name for the public key (like what is done for the private key). However, many places assume the public key can be constructed from the key dir and hint, and I don't want to do the refactoring necessary. As a consequence of this, it is now easier to add public keys to an existing image without signing something. This could be done all along, but now you don't have to create an its just to do it. Ideally, we wouldn't create a FIT at the end. This could be done by calling fit_image_setup_sig/info.crypto->add_verify_data directly. Signed-off-by: Sean Anderson <[email protected]>
2022-03-31mkimage: add public key for image pre-load stagePhilippe Reynes
This commit enhances mkimage to update the node /image/pre-load/sig with the public key. Reviewed-by: Simon Glass <[email protected]> Signed-off-by: Philippe Reynes <[email protected]>
2022-01-26tools: mkimage: Show where signatures/keys are writtenSimon Glass
At present mkimage displays the node information but it is not clear what signing action was taken. Add a message that shows it. For now it only supports showing a single signing action, since that is the common case. Sample: Signature written to 'sha1-basic/test.fit', node '/configurations/conf-1/signature' Public key written to 'sha1-basic/sandbox-u-boot.dtb', node '/signature/key-dev' Signed-off-by: Simon Glass <[email protected]>
2022-01-26tools: Move copyfile() into a common fileSimon Glass
This function is useful in other places. Move it to a common file. Signed-off-by: Simon Glass <[email protected]>
2022-01-25mkimage: Show the external-offset errorSimon Glass
This is a debug message at present, which is not very helpful. Print out the error so that action can be taken. Signed-off-by: Simon Glass <[email protected]>
2022-01-24mkimage: Allow to specify the signature algorithm on the command lineJan Kiszka
This permits to prepare FIT image description that do not hard-code the final choice of the signature algorithm, possibly requiring the user to patch the sources. When -o <algo> is specified, this information is used in favor of the 'algo' property in the signature node. Furthermore, that property is set accordingly when writing the image. Signed-off-by: Jan Kiszka <[email protected]>
2022-01-24tools/fitimage: remove redundant format checkStefan Eichenberger
fit_extract_contents does a fit_check_format even thought it was already checked during imagetool_verify_print_header. Therefore, this check is not necessary. This commit removes the redundancy. Signed-off-by: Stefan Eichenberger <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-07-14tools/fitimage: add missing linebreak for some messagesSven Roederer
Add a linebreak to two messages and fix punctuation. Signed-off-by: Sven Roederer <[email protected]>
2021-04-14mkimage: Add a 'keyfile' argument for image signingAlexandru Gagniuc
It's not always desirable to use 'keydir' and some ad-hoc heuristics to get the filename of the signing key. More often, just passing the filename is the simpler, easier, and logical thing to do. Since mkimage doesn't use long options, we're slowly running out of letters. I've chosen '-G' because it was available. Signed-off-by: Alexandru Gagniuc <[email protected]> Reviewed-by: Simon Glass <[email protected]>
2021-02-15image: Adjust the workings of fit_check_format()Simon Glass
At present this function does not accept a size for the FIT. This means that it must be read from the FIT itself, introducing potential security risk. Update the function to include a size parameter, which can be invalid, in which case fit_check_format() calculates it. For now no callers pass the size, but this can be updated later. Also adjust the return value to an error code so that all the different types of problems can be distinguished by the user. Signed-off-by: Simon Glass <[email protected]> Reported-by: Bruce Monroe <[email protected]> Reported-by: Arie Haenel <[email protected]> Reported-by: Julien Lenoir <[email protected]>
2020-08-07mkimage: fit: fix import of external dataPatrick Oppenlander
The external data is located after the mmapped FDT pointed to by 'old_fdt', not in the newly created FDT we are importing into at 'fdt'. Signed-off-by: Patrick Oppenlander <[email protected]>
2020-08-05fit_image: Use calloc() to fix reproducibility issueFabio Estevam
Vagrant Cascadian reported that mx6cuboxi target no longer builds reproducibility on Debian. One example of builds mismatches: 00096680: 696e 6700 736f 756e 642d 6461 6900 6465 ing.sound-dai.de -00096690: 7465 6374 2d67 7069 6f73 0000 tect-gpios.. +00096690: 7465 6374 2d67 7069 6f73 0061 tect-gpios.a This problem happens because all the buffers in fit_image.c are allocated via malloc(), which does not zero out the allocated buffer. Using calloc() fixes this unpredictable behaviour as it guarantees that the allocated buffer are zero initialized. Reported-by: Vagrant Cascadian <[email protected]> Suggested-by: Tom Rini <[email protected]> Signed-off-by: Fabio Estevam <[email protected]> Tested-by: Vagrant Cascadian <[email protected]>
2020-07-25mkimage: Allow updating the FIT timestampSimon Glass
Normally the FIT timestamp is created the first time mkimage is run on a FIT, when converting the source .its to the binary .fit file. This corresponds to using the -f flag. But if the original input to mkimage is a binary file (already compiled) then the timestamp is assumed to have been set previously. Add a -t flag to allow setting the timestamp in this case. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-07-24Revert "Merge tag 'dm-pull-20jul20' of git://git.denx.de/u-boot-dm"Tom Rini
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 <[email protected]>
2020-07-20mkimage: Allow updating the FIT timestampSimon Glass
Normally the FIT timestamp is created the first time mkimage is run on a FIT, when converting the source .its to the binary .fit file. This corresponds to using the -f flag. But if the original input to mkimage is a binary file (already compiled) then the timestamp is assumed to have been set previously. Add a -t flag to allow setting the timestamp in this case. Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Bin Meng <[email protected]>
2020-06-02mkimage: Default to adding a crc32 hash with '-f auto'Simon Glass
This option currently does not add any sort of hash to the images in the FIT. Add a hash node requesting a crc32 checksum, which at least provides some protection. The crc32 value is easily ignored (e.g. in SPL) if not needed. and takes up only about 48 bytes per image, including overhead. Suggested-by: Wolfgang Denk <[email protected]> Signed-off-by: Simon Glass <[email protected]> Reviewed-by: Wolfgang Denk <[email protected]>
2020-05-07Revert "mkimage: fit: Do not tail-pad fitImage with external data"Tom Rini
This has been reported to break booting of U-Boot from SPL on a number of platforms due to a lack of alignment of the external data. The issues this commit is addressing will need to be resolved another way. Re-introduce a data leak in the padding for now. This reverts commit 20a154f95bfe0a3b5bfba90bea7f001c58217536. Reported-by: Alex Kiernan <[email protected]> Reported-by: Michael Walle <[email protected]> Tested-by: Jan Kiszka <[email protected]> Signed-off-by: Tom Rini <[email protected]>
2020-05-04mkimage: fit: Do not tail-pad fitImage with external dataMarek Vasut
There is no reason to tail-pad fitImage with external data to 4-bytes, while fitImage without external data does not have any such padding and is often unaligned. DT spec also does not mandate any such padding. Moreover, the tail-pad fills the last few bytes with uninitialized data, which could lead to a potential information leak. $ echo -n xy > /tmp/data ; \ ./tools/mkimage -E -f auto -d /tmp/data /tmp/fitImage ; \ hexdump -vC /tmp/fitImage | tail -n 3 before: 00000260 61 2d 6f 66 66 73 65 74 00 64 61 74 61 2d 73 69 |a-offset.data-si| 00000270 7a 65 00 00 78 79 64 64 |ze..xydd| ^^ ^^ ^^ after: 00000260 61 2d 6f 66 66 73 65 74 00 64 61 74 61 2d 73 69 |a-offset.data-si| 00000270 7a 65 00 78 79 |ze.xy| Signed-off-by: Marek Vasut <[email protected]> Reviewed-by: Simon Glass <[email protected]> Cc: Heinrich Schuchardt <[email protected]> Cc: Tom Rini <[email protected]>
2020-05-01tools/fit-image: print a warning when cmd-line for dtc might be truncatedSven Roederer
Signed-off-by: Sven Roederer <[email protected]>
2020-04-24mkimage: fit: Free buf directly in fit_extract_data()Bin Meng
If given ptr to free() is NULL, no operation is performed. Hence we can just free buf directly in fit_extract_data(). Signed-off-by: Bin Meng <[email protected]>
2020-04-24mkimage: fit: Unmmap the memory before closing fd in fit_import_data()Lihua Zhao
Without calling munmap(), the follow-up call to open() the same file with a flag O_TRUNC seems not to cause any issue on Linux, but it fails on Windows with error like below: Can't open kernel_fdt.itb.tmp: Permission denied Fix this by unmapping the memory before closing fd in fit_import_data(). Signed-off-by: Lihua Zhao <[email protected]> Signed-off-by: Bin Meng <[email protected]>
2020-04-24mkimage: fit_image: Add option to make fit header alignKever Yang
The image is usually stored in block device like emmc, SD card, make the offset of image data aligned to block(512 byte) can avoid data copy during boot process. eg. SPL boot from FIT image with external data: - SPL read the first block of FIT image, and then parse the header; - SPL read image data separately; - The first image offset is the base_offset which is the header size; - The second image offset is just after the first image; - If the offset of imge does not aligned, SPL will do memcpy; The header size is a ramdon number, which is very possible not aligned, so add '-B size'to specify the align size in hex for better performance. example usage: ./tools/mkimage -E -f u-boot.its -B 0x200 u-boot.itb Signed-off-by: Kever Yang <[email protected]> Reviewed-by: Punit Agrawal <[email protected]> Reviewed-by: Tom Rini <[email protected]>
2020-04-24tool: use ALIGN() to align the sizeKever Yang
Use the ALIGN() for size align so that the code is more readable. Signed-off-by: Kever Yang <[email protected]> Reviewed-by: Punit Agrawal <[email protected]> Reviewed-by: Tom Rini <[email protected]> Reviewed-by: Heinrich Schuchardt <[email protected]>
2020-04-17mkimage: fit: don't create image with 0700 permissionsThomas Hebb
commit 7298e422504e ("mkimage: fit: add support to encrypt image with aes") added a new copyfile() function as part of the FIT image creation flow. This function as currently written creates the final image with a mode of 0700 (before umask), differing from the old behavior of 0666. Since there doesn't seem to be any reason to make the image executable or non-group, non-other readable, change the mask to 0666 to preserve the old behavior. Fixes: 7298e422504e ("mkimage: fit: add support to encrypt image with aes") Signed-off-by: Thomas Hebb <[email protected]>