summaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)AuthorFilesLines
2021-07-21binman: Add basic support for debugging performanceSimon Glass4-0/+88
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-21patman: Use bytearray instead of stringSimon Glass1-3/+3
If the process outputs a lot of data on stdout this can be quite slow, since the bytestring is regenerated each time. Use a bytearray instead. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21binman: Use bytearray instead of stringSimon Glass2-3/+3
This is faster if data is being concatenated. Update the section and collection etypes. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21binman: Split node-reading out from constructor in filesSimon Glass1-0/+3
The constructor should not read the node information. Move it to the ReadNode() method instead. This allows this etype to be subclassed. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21binman: Support multithreading for building imagesSimon Glass8-6/+136
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-07-21binman: Put compressed data into separate filesSimon Glass1-2/+7
At present compression uses the same temporary file for all invocations. With multithreading this causes the data to become corrupted. Use a different filename each time. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Detect drivers which do not parse correctlySimon Glass2-1/+44
At present if a driver is missing a uclass or compatible stirng, this is silently ignored. This makes sense in most cases, particularly for the compatible string, since it is not required except when the driver is used with of-platdata. But it is also not very helpful. When there is some sort of problem with a driver, the missing compatible string (for example) may be the cause. Add a warning in this case, showing it only for drivers which are used by the build. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Detect unexpected suffix on .of_matchSimon Glass2-3/+101
Some rockchip drivers use a suffix on the of_match line which is not strictly valid. At present this causes the parsing to fail. Fix this and offer a warning. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Add a stdout check in test_normalized_name()Simon Glass1-2/+1
This test captures output but does not always check it. Add the missing code and drop the old comment. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-21dtoc: Correct the re_compat regular expressionSimon Glass1-2/+2
This expects a . before the field name (.e.g '.compatible = ...) but presently accepts anything at all. Fix it. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Allow multiple warnings for a driverSimon Glass1-4/+20
At present we show when a driver is missing but this is not always that useful. There are various reasons why a driver may appear to be missing, such as a parse error in the source code or a missing field in the driver declaration. Update the implementation to record all warnings for each driver, showing only those which relate to drivers that are actually used. This avoids spamming the user with warnings related to a driver for a different board. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Convert to use ArgumentParserSimon Glass1-24/+27
Use this parser instead of OptionParser, which is deprecated. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-21dtoc: Avoid using subscripts on match objectsSimon Glass1-1/+1
These are not supported before Python 3.6 so avoid them. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Walter Lozano <walter.lozano@collabora.com>
2021-07-18mkeficapsule: Remove dtb related optionsIlias Apalodimas1-222/+7
commit 322c813f4bec ("mkeficapsule: Add support for embedding public key in a dtb") added a bunch of options enabling the addition of the capsule public key in a dtb. Since now we embedded the key in U-Boot's .rodata we don't this this functionality anymore Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2021-07-16tools: Use a single target-independent config to enable OpenSSLAlexandru Gagniuc2-17/+42
Host tool features, such as mkimage's ability to sign FIT images were enabled or disabled based on the target configuration. However, this misses the point of a target-agnostic host tool. A target's ability to verify FIT signatures is independent of mkimage's ability to create those signatures. In fact, u-boot's build system doesn't sign images. The target code can be successfully built without relying on any ability to sign such code. Conversely, mkimage's ability to sign images does not require that those images will only work on targets which support FIT verification. Linking mkimage cryptographic features to target support for FIT verification is misguided. Without loss of generality, we can say that host features are and should be independent of target features. While we prefer that a host tool always supports the same feature set, we recognize the following - some users prefer to build u-boot without a dependency on OpenSSL. - some distros prefer to ship mkimage without linking to OpenSSL To allow these use cases, introduce a host-only Kconfig which is used to select or deselect libcrypto support. Some mkimage features or some host tools might not be available, but this shouldn't affect the u-boot build. I also considered setting the default of this config based on FIT_SIGNATURE. While it would preserve the old behaviour it's also contrary to the goals of this change. I decided to enable it by default, so that the default build yields the most feature-complete mkimage. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2021-07-16common: Move host-only logic in image-sig.c to separate fileAlexandru Gagniuc2-1/+134
image-sig.c is used to map a hash or crypto algorithm name to a handler of that algorithm. There is some similarity between the host and target variants, with the differences worked out by #ifdefs. The purpose of this change is to remove those ifdefs. First, copy the file to a host-only version, and remove target specific code. Although it looks like we are duplicating code, subsequent patches will change the way target algorithms are searched. Besides we are only duplicating three string to struct mapping functions. This isn't something to fuss about. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-07-16tools: Avoid showing return value of clock_gettime()Simon Glass1-4/+4
This value is either 0 for success or -1 for error. Coverity reports that "ret" is passed to a parameter that cannot be negative, pointing to the condition 'if (ret < 0)'. Adjust it to just check for non-zero and avoid showing -1 in the error message, which is pointless. Perhaps these changes will molify Coverity. Reported-by: Coverity (CID: 312956) Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-15dtoc: Check that a parent is not missingSimon Glass3-0/+51
With of-platdata-inst we want to set up a reference to each devices' parent device, if there is one. If we find that the device has a parent (i.e. is not a root node) but it is not in the list of devices being written, then we cannot create the reference. Report an error in this case, since it indicates that the parent node is either missing a compatible string, is disabled, or perhaps does not have any properties because it was not tagged for SPL. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-07-14tools: image-host: fix wrong return valueMing Liu1-1/+3
The return value '-ENOSPC' of fit_set_timestamp function does not match the caller fit_image_write_sig's expection which is '-FDT_ERR_NOSPACE'. Fix it by not calling fit_set_timestamp, but call fdt_setprop instead. This fixes a following mkimage error: | Can't write signature for 'signature@1' signature node in | 'conf@imx6ull-colibri-wifi-eval-v3.dtb' conf node: <unknown error> | mkimage Can't add hashes to FIT blob: -1 Signed-off-by: Ming Liu <liu.ming50@gmail.com> Tested-by: Igor Opaniuk <igor.opaniuk@foundries.io>
2021-07-14tools/fitimage: add missing linebreak for some messagesSven Roederer1-2/+2
Add a linebreak to two messages and fix punctuation. Signed-off-by: Sven Roederer <devel-sven@geroedel.de>
2021-07-14mkimage: allow -l to work on block devices on LinuxYann Dirson1-3/+27
When "mkimage -l" was run on a block device it would fail with erroneous message, because fstat reports a size of zero for those: mkimage: Bad size: "/dev/sdb4" is not valid image This patch identifies the "is a block device" case and reports it as such, and if it knows how to determine the size of a block device on the current OS, proceeds. As shown in http://www.mit.edu/afs.new/sipb/user/tytso/e2fsprogs/lib/blkid/getsize.c this is no portable task, and I only handled the case of a modern Linux kernel, which is what I can test. Signed-off-by: Yann Dirson <yann@blade-group.com>
2021-07-07Merge tag 'dm-pull-6jul21' of https://source.denx.de/u-boot/custodians/u-boot-dmTom Rini1-2/+0
various minor sandbox improvements
2021-07-07Azure/GitLab: Move to gcc-11.1.0 and LLVM-11Tom Rini1-51/+34
- Move to gcc-11.1.0 builds from kernel.org for supported platforms and LLVM-11 for those tests. - As Heinrich has noted, the RISC-V platform specification has a profile OS-A for running rich operating systems like Linux and BSD. This profile requires 64bit and UEFI conforming to the EBBR. Only the 'embedded' profile may use 32bit. Given this, drop grub for 32bit RISC-V as it no longer compiles with gcc-11.1 and upstream is unlikely to fix it: https://www.mail-archive.com/grub-devel@gnu.org/msg30736.html - Update to grub-2.06 release to address other issues of building with gcc-11.1. - Update to newer Xtensa (gcc-9.2.0) and ARC (gcc-10.2) toolchains Cc: Heinrich Schuchardt <xypron.glpk@gmx.de> Cc: Bin Meng <bmeng.cn@gmail.com> Cc: Simon Glass <sjg@chromium.org> Cc: Rick Chen <rick@andestech.com> Signed-off-by: Tom Rini <trini@konsulko.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2021-07-06tools: Fix default target compile tools in Python toolsAlper Nebi Yasak1-2/+0
In commit 1e4687aa47ed ("binman: Use target-specific tools when cross-compiling"), a utility function was implemented to get preferred compilation tools using environment variables like CC and CROSS_COMPILE. Although it intended to provide custom default tools (same as those in the global Makefile) when no relevant variables were set (for example using "gcc" for "cc"), it is only doing so when CROSS_COMPILE is set and returning the literal name of the tool otherwise. Remove the check for an empty CROSS_COMPILE, which makes the function use it as an empty prefix to the custom defaults and return the intended executables. Fixes: 1e4687aa47ed ("binman: Use target-specific tools when cross-compiling") Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2021-07-05Docker/CI: Update to "focal" and latest buildTom Rini1-11/+9
Move us up to being based on Ubuntu 20.04 "focal" and the latest tag from Ubuntu for this release. For this, we make sure that "python" is now python3 but still include python2.7 for the rx51 qemu build as that is very old and does not support python3. Signed-off-by: Tom Rini <trini@konsulko.com>
2021-07-05tools: docker: Install a readable kernel for libguestfs-toolsAlper Nebi Yasak1-0/+4
The filesystem and EFI (capsule and secure boot) test setups try to use guestmount and virt-make-fs respectively to prepare disk images to run tests on. However, these libguestfs tools need a kernel image and fail with the following message (revealed in debug/trace mode) if it can't find one: supermin: failed to find a suitable kernel (host_cpu=x86_64). I looked for kernels in /boot and modules in /lib/modules. If this is a Xen guest, and you only have Xen domU kernels installed, try installing a fullvirt kernel (only for supermin use, you shouldn't boot the Xen guest with it). This failure then causes these tests to be skipped in CIs. Install a kernel package in the Docker containers so the CIs can run these tests with libguestfs tools again (assuming the container is run with necessary host devices and privileges). As this kernel would be only used for virtualization, we can use the kernel package specialized for that. On Ubuntu systems kernel images are not readable by non-root users, so explicitly add read permissions with chmod as well. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com> Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-06-11tools: k3_fit_atf: add DM binary to the FIT imageTero Kristo1-1/+18
Add DM (device manager) firmware image to the fit image that is loaded by R5 SPL. This is needed with the HSM rearch where the firmware allocation has been changed slightly. Signed-off-by: Tero Kristo <t-kristo@ti.com> Signed-off-by: Tero Kristo <kristo@kernel.org>
2021-06-09tools: k3_fit_atf: Add support for providing ATF load address using a ↵Aswath Govindraju1-3/+6
Kconfig symbol Add support for providing ATF load address with a Kconfig symbol. Signed-off-by: Aswath Govindraju <a-govindraju@ti.com> Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com> Reviewed-by: Suman Anna <s-anna@ti.com> Link: https://lore.kernel.org/r/20210604163043.12811-2-a-govindraju@ti.com
2021-05-19binman: Support packaging U-Boot for scenarios like OF_BOARD or OF_PRIOR_STAGEBin Meng1-0/+24
For scenarios like OF_BOARD or OF_PRIOR_STAGE, no device tree blob is provided in the U-Boot build phase hence the binman node information is not available. In order to support such use case, a new Kconfig option BINMAN_STANDALONE_FDT is introduced, to tell the build system that a device tree blob containing binman node is explicitly required when using binman to package U-Boot. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-19binman: Add support for RISC-V OpenSBI fw_dynamic blobBin Meng4-0/+57
Add an entry for RISC-V OpenSBI's 'fw_dynamic' firmware payload. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rick Chen <rick@andestech.com> Reviewed-by: Rick Chen <rick@andestech.com>
2021-05-19binman: test: Rename 172_fit_fdt.dts to 170_fit_fdt.dtsBin Meng2-5/+5
Currently there are 2 binman test cases using the same 172 number. It seems that 172_fit_fdt.dts was originally named as 170_, but commit c0f1ebe9c1b9 ("binman: Allow selecting default FIT configuration") changed its name to 172_ for no reason. Let's change it back. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-19binman: Correct the comment for ATF entry typeBin Meng1-1/+1
This is wrongly referring to Intel ME, which should be ATF. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-05-19binman: Correct '-a' description in the docBin Meng1-2/+2
It needs a space around '-a'. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Reviewed-by: Rick Chen <rick@andestech.com>
2021-04-29buildman: Use bytes for the environmentSimon Glass3-11/+30
At present we sometimes see problems in gitlab where the environment has 0x80 characters or sequences which are not valid UTF-8. Avoid this by using bytes for the environment, both internal to buildman and when writing out the 'env' file. Add a test to make sure this works as expected. Reported-by: Marek Vasut <marex@denx.de> Fixes: e5fc79ea718 ("buildman: Write the environment out to an 'env' file") Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29buildman: Handle exceptions in threads gracefullySimon Glass4-11/+56
There have been at least a few cases where an exception has occurred in a thread and resulted in buildman hanging: running out of disk space and getting a unicode error. Handle these by collecting a list of exceptions, printing them out and reporting failure if any are found. Add a test for this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29buildman: Use common code to send an resultSimon Glass1-8/+13
At present the code to report a build result is duplicated. Put it in a common function to avoid this. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29buildman: Tidy up a few commentsSimon Glass3-5/+20
Add some function comments which are missing, or missing arguments. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29binman: Support adding sections to FMAPsSimon Glass4-9/+50
When used with hierarchical images, use the Chromium OS convention of adding a section before all the subentries it contains. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29binman: Tweak implementation of fmapSimon Glass1-31/+38
Use an interator in two of the fmap tests so it is easier to add new items. Also check the name first since that is the first indication that something is wrong. Use a variable for the expected size of the fmap to avoid repeating the code. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29patman: Parse checkpatch by message instead of by lineEvan Benn1-84/+134
Parse each empty-line-delimited message separately. This saves having to deal with all the different line content styles, we only care about the header ERROR | WARNING | NOTE... Also make checkpatch print line information for a uboot specific warning. Signed-off-by: Evan Benn <evanbenn@chromium.org> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-29patman: Assume we always have pygit2 for testsTom Rini1-17/+2
Given that we have tests that require pygit2 and it can be installed like any other python module, fail much more loudly if it is missing. Cc: Simon Glass <sjg@chromium.org> Signed-off-by: Tom Rini <trini@konsulko.com>
2021-04-29dtoc: Correct dtoc output when testingSimon Glass2-53/+22
At present each invocation of run_steps() updates OUTPUT_FILES_COMMON, since it does not make a copy of the dict. This is fine for a single invocation, but for tests, run_steps() is invoked many times. As a result it may include unwanted items from the previous run, if it happens that a test runs twice on the same CPU. The problem has not been noticied previously, as there are few enough tests and enough CPUs that is is rare for the 'wrong' combination of tests to run together. Fix this by making a copy of the dict, before updating it. Update the tests to suit, taking account of the files that are no-longer generated. With this fix, we no-longer generate files which are not needed for a particular state of OF_PLATDATA_INST, so the check_instantiate() function is not needed anymore. It has become dead code and so fails the code-coverage test (dtoc -T). Remove it. Signed-off-by: Simon Glass <sjg@chromium.org>
2021-04-29binman: Correct testSplNoDtb() and Tpl alsoSimon Glass1-0/+2
These two tests require an ELF image so that symbol information can be written into the SPL/TPL binary. At present they rely on other tests having set it up first, but every test must run independently. This can cause occasional errors in CI. Fix this by setting up the required files, as other tests do. Signed-off-by: Simon Glass <sjg@chromium.org> Reviewed-by: Tom Rini <trini@konsulko.com>
2021-04-14mkimage: Add a 'keyfile' argument for image signingAlexandru Gagniuc4-28/+40
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 <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-14lib: Add support for ECDSA image signingAlexandru Gagniuc1-0/+3
mkimage supports rsa2048, and rsa4096 signatures. With newer silicon now supporting hardware-accelerated ECDSA, it makes sense to expand signing support to elliptic curves. Implement host-side ECDSA signing and verification with libcrypto. Device-side implementation of signature verification is beyond the scope of this patch. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-14lib/rsa: Make fdt_add_bignum() available outside of RSA codeAlexandru Gagniuc1-0/+5
fdt_add_bignum() is useful for algorithms other than just RSA. To allow its use for ECDSA, move it to a common file under lib/. The new file is suffixed with '-libcrypto' because it has a direct dependency on openssl. This is due to the use of the "BIGNUM *" type. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-14lib: Rename rsa-checksum.c to hash-checksum.cAlexandru Gagniuc1-1/+2
rsa-checksum.c sontains the hash_calculate() implementations. Despite the "rsa-" file prefix, this function is useful for other algorithms. To prevent confusion, move this file to lib/, and rename it to hash-checksum.c, to give it a more "generic" feel. Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-13moveconfig.py: add to the "do not process" listTrevor Woerner1-1/+1
Skip the processing of *.aml and *.dat files while iterating through the source in order to process header files. Signed-off-by: Trevor Woerner <twoerner@gmail.com>
2021-04-13checkpatch: Add warnings for using strn(cat|cpy)Sean Anderson1-1/+13
strn(cat|cpy) has a bad habit of not nul-terminating the destination, resulting in constructions like strncpy(foo, bar, sizeof(foo) - 1); foo[sizeof(foo) - 1] = '\0'; However, it is very easy to forget about this behavior and accidentally leave a string unterminated. This has shown up in some recent coverity scans [1, 2] (including code recently touched by yours truly). Fortunately, the guys at OpenBSD came up with strl(cat|cpy), which always nul-terminate strings. These functions are already in U-Boot, so we should encourage new code to use them instead of strn(cat|cpy). [1] https://lists.denx.de/pipermail/u-boot/2021-March/442888.html [2] https://lists.denx.de/pipermail/u-boot/2021-January/438073.html Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org>
2021-04-10tools/mkeficapsule: improve online helpHeinrich Schuchardt1-8/+8
Show short arguments along with long arguments in online help: $ tools/mkeficapsule -h Usage: mkeficapsule [options] <output file> Options: -f, --fit <fit image> new FIT image file -r, --raw <raw image> new raw image file -i, --index <index> update image index -I, --instance <instance> update hardware instance -K, --public-key <key file> public key esl file -D, --dtb <dtb file> dtb file -O, --overlay the dtb file is an overlay -h, --help print a help message Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>