Commit Graph

97169 Commits

Author SHA1 Message Date
Leonard Anderweit
5d32fc0fbb binman: build_from_git: Add optional make path inside git repo
Add optional argument make_path to build_from git. The new argument
allows specifying the path to a Makefile in case it is not in the root
of the git repo.
Also adjust the corresponding test.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
2025-03-04 12:29:50 -07:00
Leonard Anderweit
7190844262 binman: build_from_git: Add argument specifying branch
Add optional argument git_branch to build_from_git. The new argument
allows specifying which branch of the repo to use.

Signed-off-by: Leonard Anderweit <l.anderweit@phytec.de>
2025-03-04 12:29:50 -07:00
Simon Glass
61f6f714ea CI: Run code-coverage test for Binman
Binman includes a good set of tests covering all of its functionality.
This includes a code-coverage test.

However to date the code-coverage test has not been checked
automatically by CI, relying on people to run 'binman test -T'
themselves.

Plug the gap to avoid bugs creeping in future.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2025-03-04 12:29:50 -07:00
Simon Glass
dda327db40 binman: Work around missing test coverage
The iMX8 entry-types don't have proper test coverage. Add a work-around
to skip this for now.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Jiaxun Yang
2b5ae10acb binman: Workaround lz4 cli padding in test cases
Newer lz4 util is not happy with any padding at end of file,
it would abort with error message like:

Stream followed by undecodable data at position 43.

Workaround by skipping testCompUtilPadding test case and manually
strip padding in testCompressSectionSize test case.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Simon Glass
c0ce3cc4ba binman: Drop algo check in CheckSetHashValue()
The CheckAddHashValue() function is always called before this one, so
the algorithm check is never used. Replace it with an assert to avoid a
coverage error.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Simon Glass
3b352f2428 binman: fit: Drop unused code
The key-name-hint case is not tested so is presumably not used. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Simon Glass
ba1fa8950c binman: Drop GetRootSkipAtStart()
This method is not called anymore, so drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Simon Glass
ab18daed18 binman: Exclude dist-packages and site-packages
Newer versions of the python3-coverage tool require a directory
separator before and after the directory name. Add this so that system
package are not included in the coverage report.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-03-04 12:29:50 -07:00
Marek Vasut
0bbccfdfe1 image: Add support for starting TFA BL31 as fitImage loadables
Add support for starting TFA from U-Boot running in EL3 as part of
fitImage boot, so the user can start U-Boot in the highest privilege
level on the platform, bundle TFA, Linux, DT into a single fitImage
and boot such a bundle as a whole.

There are two main benefits of this approach. First is the ability
to run U-Boot in EL3, where it has unrestricted access to the entire
system and can act as a useful debug tool, as it was always intended
to be used. Second is the ability to easily and safely update of any
component in the fitImage, be it TFA, Linux or DT.

The boot process is similar to regular Linux with DT fitImage boot
process, except the TFA has to be bundled into the fitImage. For the
bundling instructions, see below. The TFA is started as a 'loadables'
with custom U_BOOT_FIT_LOADABLE_HANDLER and armv8_switch_to_el2_prep()
handling implemented in board code, and performing the handoff and
boot in case the TFA was loaded.

The loadables handler is optional and meant to set up any sort of
handoff structures used by the TFA BL31 or perform any other setup
that is needed by the blob. The custom armv8_switch_to_el2_prep()
has to implement the jump to TFA BL31 with return to U-Boot just
before booting the Linux kernel.

Example fitImage image and configuration section:

/dts-v1/;

/ {
    description = "Linux kernel with FDT blob and TFA BL31";

    images {
        kernel-1 { ... };
        fdt-1 { ... };
        atf-1 {                  /* This is the TFA BL31 image */
            description = "TFA BL31";
            data = /incbin/("../build/plat/release/bl31.bin");
            type = "tfa-bl31";
            arch = "arm64";
            os = "arm-trusted-firmware";
            compression = "none";
            load = <0x46400000>;
            entry = <0x46400000>;
        };
    };

    configurations {
        default = "conf-1";
        conf-1 {
            description = "Boot Linux";
            kernel = "kernel-1";
            fdt = "fdt-1";
            loadables = "atf-1"; /* This is the TFA BL31 loadable */
        };
    };
};

Reviewed-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org>
2025-03-04 12:16:29 -07:00
Simon Glass
6ae1e363ca Merge branch 'ci' into 'master'
membuff: Rename functions to have membuf_ prefix

See merge request u-boot/u-boot!50
2025-03-04 13:07:35 +00:00
Simon Glass
b5b151cfb5 membuf: Support a flag for being full
At present the membuf implementation wastes a slot in the fifo so it can
detect the difference between a full and an empty buffer.

Add the option of supporting a boolean flag, if desired. For now it is
off.

The code-size penalty is non-zero, but the space penalty is small and
could be reduced on 64-bit machines by using a u32 offset for head and
tail.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:57 -07:00
Simon Glass
372ad68148 membuf: Minor code-style improvements
Show the start in end in the comment. Comment a missing variable in
membuf_readline() and fix its line length.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:57 -07:00
Simon Glass
1b920199d0 membuf: Add some tests
Add tests for the membuf implementation.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:57 -07:00
Simon Glass
bfb34cc3d5 membuf: Correct implementation of membuf_dispose()
This should free the pointer, not the address of the pointer. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:30 -07:00
Simon Glass
5303e0b6e4 membuf: Include stdbool
This uses a bool type so include the required header.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:30 -07:00
Simon Glass
ff5eb481d8 membuf: Rename struct
Rename the struct to match the function prefix and filenames.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:30 -07:00
Simon Glass
e6b8a50af2 membuff: Rename the files to membuf
Rename the C and header files to use the membuf basename, to match the
functions.

Add a MAINTAINERS entry while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:30 -07:00
Simon Glass
dcddf6aa83 membuff: Rename functions to have membuf_ prefix
The double 'f' is not necessary and is a bit annoying as elsewhere in
U-Boot we use 'buf'. Rename all the functions before it is used more
widely.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 16:39:19 -07:00
Simon Glass
813a785b1e Merge branch 'ci' into 'master'
Recent tools changes

See merge request u-boot/u-boot!49
2025-02-25 22:42:15 +00:00
Simon Glass
b06efead7f buildman: Update tests for newer filelock module
Recent versions of this module call time.perf_counter() so add a patch
for this also.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
2025-02-25 14:21:52 -07:00
Simon Glass
257ba68762 u_boot_pylib: Move gitutil into the library
Move this file into U-Boot's Python library, so that it is no-longer
part of patman.

This makes a start on:

https://source.denx.de/u-boot/custodians/u-boot-dm/-/issues/35

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
09684f0fb8 tools: binman: etype: fit: Append DTB directory to the list of input directories
When specifying a directory containing DTBs with 'fit,fdt-list-dir', it can be
handy not to have to also specify this directory to the input directories of
binman with '-I' option and use the method tools.append_input_dirs() append it.
This avoids to have to specify the DTB directory in both the device tree
provided to binman and through '-I' option to binman.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
3cadb7c73f tools: u_boot_pylib: Allow to append input directories to indir
append_input_dirs() can be used to append a list of input directories to indir
global list.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
e21cf7db4a tools: binman: etype: Allow to replace 'NAME' in node names
This change allows to replace both 'SEQ' and 'NAME' keywords by respectively a
sequence number and the name of the FDT to provide more flexibility in the node
name for the device trees included in the FIT.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
2e4bdac96c tools: binman: Pass a list of input directory to EnsureCompiled()
Input directories can be passed to binman using the '-I' option and those
input directories are now also passed to 'dtc' when run by binman.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
12b34e8809 tools: dtoc: Allow passing optional input directories
An optional list of input directories can be passed to EnsureCompiled() which
allows to pass a list of directories where input files can be searched.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
c1443cf90d tools: binman: Add tests for FIT with data encrypted by mkimage
Test the property 'fit,encrypt' to encrypt FIT data.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 14:21:52 -07:00
Paul HENRYS
76ff86f98d tools: binman: add 'fit, encrypt' property to pass keys directory to mkimage
mkimage can be used for both signing the FIT or encrypt its content and the
option '-k' can be used to pass a directory where both signing and encryption
keys can be retrieved. Adding 'fit,encrypt' property to the 'fit' node, leads to
try to find keys directory among binman include directories.
_get_priv_keys_dir() is renamed as _get_keys_dir() and adapted to support both
signing and encryption nodes in the FIT.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Paul HENRYS
3c70ace95c aes: Allow to store randomly generated IV in the FIT
When the initialisation vector is randomly generated, its value shall be
stored in the FIT together with the encrypted data. The changes allow to
store the IV in the FIT also in the case where the key is not stored in
the DTB but retrieved somewhere else at runtime.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 14:21:52 -07:00
Simon Glass
558aa24b46 Merge branch 'ci' into 'master'
tools: Update tools for 24.04

See merge request u-boot/u-boot!48
2025-02-25 19:45:33 +00:00
Tom Rini
915972962f Merge patch series "Add preload_check_sign tool"
Paul HENRYS <paul.henrys_ext@softathome.com> says:

This serie of patches adds a new tool to authenticate files signed
with a preload header.
This tool is also used in the tests to actually verify the
authenticity of the file signed with such a preload header.

Link: https://lore.kernel.org/r/20250212093126.3722186-1-paul.henrys_ext@softathome.com
2025-02-25 06:35:32 -07:00
Paul HENRYS
e79b61ff1a binman: Authenticate the image when testing the preload signature
Use preload_check_sign to authenticate the generated image when testing the
preload signature in testPreLoad().

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:35:02 -07:00
Paul HENRYS
da2a53dffa configs: Enable the pre-load signature in tools-only_defconfig
pre-load related config options are enabled to have support of it in host
tools.

'CONFIG_FIT_SIGNATURE=y' is being automatically removed since it is
selected by CONFIG_IMAGE_PRE_LOAD_SIG.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:45 -07:00
Paul HENRYS
57beac9f8a tools: Add preload_check_sign to authenticate images with a pre-load
preload_check_sign is added so that it can be used to authenticate images
signed with the pre-load signature supported by binman and U-Boot.
It could also be used to test the signature in binman tests signing
images with the pre-load.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:22 -07:00
Paul HENRYS
22f76b1c17 boot: Add support of the pre-load signature for host tools
Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:20 -07:00
Paul HENRYS
e32bb99667 image: Add an inline declaration of unmap_sysmem()
Add an empty inline declaration when compiling tools for a host where
unmap_sysmem() is not defined.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:17 -07:00
Paul HENRYS
42e0a88173 rsa: Add rsa_verify_openssl() to use openssl for host builds
rsa_verify_openssl() is used in lib/rsa/rsa-verify.c to authenticate data
when building host tools.

Signed-off-by: Paul HENRYS <paul.henrys_ext@softathome.com>
2025-02-25 06:34:16 -07:00
Tom Rini
d4492cca1f binman: Regenerate tools/binman/entries.rst
There have been a few changes to the areas that this file documents
without having regenerated the file. Do so now.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Lothar Rubusch
b749c5f674 doc: develop: Fix typos and wording in binman/binman.rst
Fix some typos and duplicate words in binman.rst.

Signed-off-by: Lothar Rubusch <l.rubusch@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-02-25 06:33:57 -07:00
Simon Glass
1b9bc2b2da tools: Fix pylint 3.3.4 errors
This newer pylint produces errors about variables possibly being used
before being set. Adjust the code to pass these checks.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reported-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Tom Rini
54e20a5949 tools/patman: Don't call a non-existent suite
With a newer pylint we get a warning that gitutil.RunTests does not
exist, so remove the line.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Tom Rini
d69cb66ab3 tools: binman: ti_board_cfg: Fix pylint error over 'br'
With a newer pylint, we get a warning that 'br' could be used before
assignment. Fix this by declaring br first as an empty bytearray.

Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Tom Rini
736276478b binman: Switch to setuptools
With the distutils module having been removed with Python 3.12, switch
to using setuptools instead.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Tom Rini
2cc7b4e17b dtoc: Switch to setuptools
With the distutils module having been removed with Python 3.12, switch
to using setuptools instead.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-02-25 06:33:57 -07:00
Simon Glass
6625953401 Merge branch 'ci' into 'master'
test/py: Shorten u_boot_console

See merge request u-boot/u-boot!47
2025-02-17 12:52:58 +00:00
Simon Glass
63baa55106 test: Make net tests depend on CONFIG_CMD_NET
This fails on samus_tpl as there is no 'net' command.

   => net list
   Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Add a blank line to keep pylint happy.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-16 17:30:53 -07:00
Simon Glass
1be4babf14 test/py: Show info about module-loading
It is sometimes tricky to figure out what modules test.py is loading
when it starts up. The result can be a silent failure with no clue as to
what when wrong.

Add a section which lists the modules loaded as well as those not
found.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-16 17:30:53 -07:00
Simon Glass
8cb42bb814 test/py: Drop assigning ubman to cons
Now that we have a shorter name, we don't need this sort of thing. Just
use ubman instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-02-16 17:30:53 -07:00
Simon Glass
2ddab2962a test/py: Drop importing utils as util
Now that we have a shorter name, we don't need this sort of thing.
Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # test_android
2025-02-16 17:30:53 -07:00