Commit graph

3395 commits

Author SHA1 Message Date
Simon Glass
b1dcc3355c tools: Drop xway-swap-bytes tool
This is very old and does not appear to be used. The CONFIG option
enabling it is no-longer present. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-07 14:33:50 -05:00
Simon Glass
aeca5194ce Drop ubsha1 tool
This seems to have been used by ppc4xx which was removed a while back.
The Kconfig does not exist so it is never built. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-07 14:33:49 -05:00
Simon Glass
efabbe60d2 imx: Rename CONFIG_MXS to CFG_MXS
This is not a Kconfig option so we should not be setting it in the
Makefile. Rename it to use a CFS_ prefix, since this is still used in
mxsimage.c

In general tools should support all the features without reference to
CONFIG options, but this is left to the maintainer to look at.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-07 14:33:48 -05:00
Simon Glass
65e62037dd moveconfig: Add an option to compare Kconfig against source
Sometimes the Makefile rules or source code refers to Kconfig options
which don't exist. Update the moveconfig tool to check this and produce
a series of reports about inconsistencies.

This can then be used to generate patches to correct the problems.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-02-07 14:33:47 -05:00
Pali Rohár
598e911f23 tools: default_image: Accept images with padding
If image file is stored on flash partition then it contains padding, which
is not part of the image itself. Image data size is stored in the image
header. So use image size from the header instead of expecting that total
image file size is size of the header plus size of the image data. This
allows dumpimage to parse image files with padding (e.g. dumped from flash
partition).

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-02-06 17:10:14 -05:00
Pali Rohár
3f837b06b7 tools: default_image: Verify header size
Before reading image header, verify that image size is at least size of
the image header.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-02-06 14:35:14 -05:00
Pali Rohár
afd82187b5 tools: imagetool: Skip autodetection of gpimage type
gpimage type requires only that two first 32-bit words of data file are
non-zero. So basically every random data file can be guessed and verified
as gpimage. So completely skip gpimage type from image autodetection code
to prevent lot of false positive results. Data file with gpimage type can
be still verified and parsed by explicitly specifying -T gpimage.

Signed-off-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-02-06 14:35:14 -05:00
Pali Rohár
6c58aa1e61 tools: imagetool: Show error message when detecting image type failed
Signed-off-by: Pali Rohár <pali@kernel.org>
2023-02-06 14:35:14 -05:00
Pali Rohár
27e46a991c tools: imagetool: Fix error message when verify_header is undefined
Signed-off-by: Pali Rohár <pali@kernel.org>
2023-02-06 14:35:14 -05:00
Nikhil M Jain
03610ebf35 tools: logos: Add TI logo files
The default splashfile name saved is ti.gz. User can use these
logo files and use it to test splash screen.

Signed-off-by: Nikhil M Jain <n-jain1@ti.com>
2023-02-04 18:19:00 +01:00
Mikhail Ilin
f75e92f7f7 tools: imx8image: Fix handle leak
The handle "fd" was created in imx8image.c:249 by calling the "fopen"
 function and is lost in imx8image.c:282.
 Should close the 'fd' file descriptor before exiting the
 parse_cfg_file(image_t *param_stack, char *name) function.

Fixes: a2b96ece5b ("tools: add i.MX8/8X image support")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-30 23:23:01 +01:00
Mikhail Ilin
9017785acd tools: imx8mimage: Fix handle leak
The handle "fd" was created in imx8mimage.c:178 by calling
 the "fopen" function and is lost in imx8mimage.c:210.
 Should close the 'fd' file descriptor before exiting
 the parse_cfg_file(char *name) function.

Fixes: 6609c2663c ("tools: add i.MX8M image support")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
2023-01-30 23:23:01 +01:00
Mikhail Ilin
507a70b144 tools: imximage: Fix check array index
The struct dcd_v1_t is initialized to MAX_HW_CFG_SIZE_V1 (60)
 structs 'dcd_type_addr_data_t', so the indexes to use on its elements
 are [0,59]. But on line 478, the variable 'length' can take on the value
 60, which applies to array overflow: cd_v1->addr_data[length].type Thus,
 it is necessary to tighten the check on the 'size' variable on line 463.

Fixes: 0b0c6af387 ("Prepare v2020.01")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
2023-01-30 23:23:01 +01:00
Massimo Pegorer
b93a65209c mkimage: fit: Support signed configurations in 'auto' FITs
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 <massimo.pegorer@vimar.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-27 12:51:27 -05:00
Simon Glass
a092f1e906 ifwitool: Fix member access
On a second and third look, a recent patch seems to be writing to the
wrong place - updating offsets from the address of the pointer instead
of what the pointer points to.

Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 2d1b2ac13f ("tool: ifwitool: Fix buffer overflow")
Acked-by: Sean Anderson <seanga2@gmail.com>
2023-01-27 12:51:26 -05:00
Simon Glass
060a65e899 binman: Fix a test-coverage regression
Unfortunately a recent patch snuck through without the require test
coverage. Fix it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 571bc4e67d ("binman: Support positioning an entry by and ELF symbol")
2023-01-26 10:47:45 -07:00
Samuel Holland
b01ae03c0b binman: Add 'min-size' entry property
This property sets the minimum size of an entry, including padding but
not alignment. It can be used to reserve space for growth of an entry,
or to enforce a minimum offset for later entries in the section.

Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-26 10:47:45 -07:00
Jonas Karlman
f584d44c23 binman: Add support for selecting firmware to use with split-elf
In some cases it is desired for SPL to start TF-A instead of U-Boot
proper. Add support for a new property fit,firmware that picks a
valid entry and prepends the remaining valid entries to the
loadables list generated by the split-elf generator.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-26 10:47:45 -07:00
Jonas Karlman
00b3d53f15 binman: Add special subnodes to the nodes generated by split-elf
Special nodes, hash and signature, is not being added to the nodes
generated for each segment in split-elf operation.

Copy the subnode logic used in _gen_fdt_nodes to _gen_split_elf to
ensure special nodes are added to the generated nodes.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-26 10:47:45 -07:00
Jonas Karlman
9b2fd2d228 binman: Add support for align argument to mkimage tool
Add support to indicate what alignment to use for the FIT and its
external data. Pass the alignment to mkimage via the -B flag.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-26 10:47:45 -07:00
Maxim Cournoyer
4c59078895 patman: symlink top level .checkpatch.conf
This makes it possible to run the patman test suite simply by invoking
'pytest' from the patman sub-directory:

  $ cd tools/patman
  $ pytest

Otherwise, the top level .checkpatch.conf would be ignored and
multiple test_checkpatch.py tests would fail.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:41 -07:00
Maxim Cournoyer
da413b5635 Revert "patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'"
This reverts commit 648d8186dd, because
it broke usage of patman on Linux, whose check script doesn't know
about '--strict' or '--u-boot'.

Reported-by: Sjoerd Simons <sjoerd@collabora.com>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Sjoerd Simons <sjoerd@collabora.com>
2023-01-18 14:55:41 -07:00
Simon Glass
571bc4e67d binman: Support positioning an entry by and ELF symbol
In some cases it is useful to position an entry over the top of a symbol
in an ELF file. For example, if the symbol holds a version string then it
allows the string to be accessed from the fdtmap.

Add support for this.

Suggested-by: Pali Rohár <pali@kernel.org>
Suggested-by: Keith Short <keithshort@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:41 -07:00
Simon Glass
8f5afe21ae dtoc: Add a way to read a phandle with params
Add a function to read a phandle and associated name and offset. This is
useful for binman.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:41 -07:00
Simon Glass
c1157860c5 binman: Provide general support for updating ELF symbols
The current support for updating variables in a binary is hard-coded to
work with U-Boot:

- It assumes the image starts at __image_copy_start
- It uses the existing U-Boot-specific entry types

It is useful for other projects to use these feature.

Add properties to enable writing symbols for any blob, a way of specifying
the base symbol and a way of providing the ELF filename to allow symbol
lookup to take place.

With this it is possible to update a Zephyr image, such as zephyr.bin
after it has been built.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:41 -07:00
Simon Glass
9766f69c98 binman: Support overlapping entries
In some cases it is useful to have an entry overlap with another in a
section, either to update the contents within a blob, or to add an entry
to the fdtmap that covers only part of the blob.

Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:41 -07:00
Simon Glass
97fb8081ec binman: Add a function to check for special section nodes
This appears in two places in the code. Use a shared function instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:40 -07:00
Simon Glass
62ef2f7bf3 binman: Add a null entry
It is sometimes useful to define an entry which does not have its own
contents but does appear in the image. The contents are set by the section
which contains it, even though it appears as an entry in the fdtmap.

Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:40 -07:00
Simon Glass
4331d66661 binman: Clarify use of False when obtaining data
This means that the data is not yet available. Update some comments to
make this clearer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:40 -07:00
Simon Glass
0b079fcb09 binman: Add a test for an inner section with a size
This is a slightly different scenario from the existing testSections
tests. Add a new test for it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 14:55:40 -07:00
Simon Glass
67a0501708 binman: Support optional external blobs
Some blobs are actually not necessary for the board to work correctly. Add
a property to allow this to be indicated. Missing optional blobs do not
cause a build failure.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
2f80c5ef13 binman: Support new op-tee binary format
OP-TEE has a format with a binary header that can be used instead of the
ELF file. With newer versions of OP-TEE this may be required on some
platforms.

Add support for this in binman. First, add a method to obtain the ELF
sections from an entry, then use that in the FIT support. We then end up
with the ability to support both types of OP-TEE files, depending on which
one is passed in with the entry argument (TEE=xxx in the U-Boot build).

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
39f4a85bb2 binman: Add a way to check for a valid ELF file
Add a function which checks whether data is in ELF format or not. This
will be used by binman to check this for entries.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
c8c9f3108a binman: Support optional entries
Support entries which can be optional depending on their contents. This
allows special entry types which appear in the image only when needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
23ab4e0054 binman: Use a reference for binman symbols docs
Several etypes have this reference in their documentation. Now that we are
using rST, link to the section directly.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
2023-01-18 11:50:01 -07:00
Simon Glass
237ac96a70 binman: Update entry docs
These have got out of data recently. Regenerate them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
226ce1d24d binman: Tidy up comment in fit _gen_node
Expand this comment to cover both cases that are supported.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
efddab6c36 binman: Allow writing section contents to a file
At present only the image (which is a section) has a filename. Move this
implementation to the entry_Section class so that any section can have a
filename. With this, the section data is written to a file.

This allows parts of an image to be written, along with the entire image.

Make a note that this can be used to include the contents of a section in
one image in another (later) image.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:50:01 -07:00
Simon Glass
ef42e27097 trace: Update trace-format generator for newer version
This now includes flags and the layout has changed slightly in recent
versions of Linux. Update the generator accordingly.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
b87f0818b8 trace: Adjust flags in proftool
The flags in this tool don't match the comments or help. Also the variable
names are quite confusing. Update them for consistency.

Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Simon Glass
90cfae2ade mkimage: Add a few more messages for FIT failures
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 <sjg@chromium.org>
2023-01-18 11:49:13 -07:00
Jagan Teki
6d70d826f5 rockchip: mkimage: Add rv1126 support
Add support for rv1126 package header in mkimage tool.

Signed-off-by: Jagan Teki <jagan@edgeble.ai>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-01-16 18:01:11 +08:00
John Keeping
2c89929101 rockchip: mkimage: make RC4 key const
This is read-only data, so mark it as such.

Signed-off-by: John Keeping <john@metanate.com>
Reviewed-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
2023-01-16 18:01:10 +08:00
Tom Rini
85fd48984e CI/Docker: Update to jammy-20221130 tag
Update to the latest "jammy" tag. This requires us to list libc6-i386 as
a required package to install (for nokia_rx51 tests) that was previously
implicit.

Signed-off-by: Tom Rini <trini@konsulko.com>
2023-01-11 15:02:24 -05:00
Heinrich Schuchardt
5f7a507eb3 Dockerfile: add package texinfo
In preparation of adding the infodocs target to our CI install the
prerequisite texinfo software package.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2023-01-11 15:02:24 -05:00
Maxim Cournoyer
8c042fb7f9 patman: add '--get-maintainer-script' argument
This makes it possible to configure a project to use some other
location or script than the default scripts/get_maintainer.pl one used
in the U-Boot and Linux projects. It can be configured via a .patman
configuration file and accepts arguments, as documented.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
8f8d3f72f2 patman: additionally honor a local .patman config file
This enables versioning a project specific patman configuration file.
It also makes it possible to declare the project name, which is not a
useful thing to do in $HOME/.patman.  A new test is added, along
updated documentation.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
db16edd8ce patman: fail early in Setup when provided config file does not exist
Rationale: if the user explicitly provide this argument, they probably
intend for it to be used.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
2c58a5e275 patman: set the default config_fname argument value to None
This better matches Python conventions, allowing to easily test
whether the optional argument is provided.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
57e3b03fe1 patman: import gitutil module where it is needed
Instead of propagating it from the module entry point (main script).

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
8b73f9bf9e patman: replace deprecated SafeConfigParser with ConfigParser
The SafeConfigParser class has been renamed in Python 3.2 to
ConfigParser, and the old alias has been deprecated since.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
872f3a4ce2 patman: fix pep8 warnings in settings module
Remove extraneous imports, variables and comply to PEP 8 maximum line
width, among other PEP 8 changes suggested by Pyflake.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
3052930714 patman: document default 'send' command
Document that this command is the default and what it's intended for.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
f393f59e5d patman: document how to run test suite via pytest
Pytest offers useful features such as selecting tests by means of a
regular expression, or running the pdb debugger upon encountering a
test failure.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
52c1c333ea patman: hide the 'test' command unless test data is available
Some tests would fail when the test data is not available, so it
doesn't make much sense to expose the action when patman is running
outside of the u-boot git checkout.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
a3997a0a00 patman: add pytest configuration file
With this change, a user can run the patman test suite using Pytest
the same as when using 'patman test':

    $ cd tools/patman && pytest
    [...]
    44 passed, 8 warnings in 8.87s

    $ ./patman test
    Ran 44 tests in 8.460s

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
579916beb1 patman: rename main script to __main__.py
This allows running the package as a Python module, like e.g.:

    $ python -m patman

It also prevents Pytest from attempting to parse main.py, which
would cause errors.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Fix up main.py in __init__.py:
Signed-off-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
648d8186dd patman: invoke the checkpatch.pl script with '--u-boot' and '--strict'
This resolves 10 out of 11 test failures seen when running './patman
test' from the 'tools/patman' subdirectory. This was caused by the
.checkpatch.conf configuration file at the root of the project not
being picked up. Make the test suite of patman independent from it by
always invoking the checkpatch.pl script with the minimally required
arguments for the test suite to pass.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
1c77598402 patman: locate test data files via __file__ and pathlib
Previously it would rely on the executing script location, which could
break for example when running the tests via 'pytest'.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
f9e20e3bff patman: cosmetic: Fix PEP 8 warnings for the gitutil module.
This patch fixes all the PEP 8 warnings reported by Pyflake for the
gitutil module.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
a5197fc9c3 patman: locate README.rst via importlib
Rationale: this is more robust than assumptions about the file
hierarchy layout of the installation of patman, for example on non
file-hierarchy standard (FHS) systems such as Guix System or Nix OS.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:57 -07:00
Maxim Cournoyer
425bbed247 patman: fix installation of README.rst data file
This fixes a regression introduced in commit 74df491051 ("buildman:
Convert documentation to rST").

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:56 -07:00
Maxim Cournoyer
291ab6c74c patman: remove extraneous imports
* tools/patman/main.py: Remove extraneous imports and fix indentation.

Signed-off-by: Maxim Cournoyer <maxim.cournoyer@savoirfairelinux.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:56 -07:00
Sean Anderson
e0ddd895f6 patman: Switch to setuptools
distutils is about to meet its demise [1]. Switch to setuptools.

[1] https://peps.python.org/pep-0632/

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2023-01-05 19:21:56 -07:00
Tom Rini
9ef3ba85bf kbuild: Remove checking for adhoc CONFIG symbols
At this point all listed adhoc CONFIG symbols have been migrated to
Kconfig or removed from the tree or renamed to CFG (or similar). We also
now have CI tests that will error on any new introductions, and
checkpatch.pl also looks. We can now remove these hooks and related
scripts.

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-23 13:01:13 -05:00
Tom Rini
2a06da08e7 checkpatch.pl: Update CONFIG logic in U-Boot section
Now that all CONFIG symbols are in Kconfig, checkpatch.pl should check
for and error on any case of define/undef CONFIG_*.

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-23 10:15:13 -05:00
Tom Rini
fa2fd534b5 global: Migrate CONFIG_X86_MRC_ADDR to CFG
Perform a simple rename of CONFIG_X86_MRC_ADDR to CFG_X86_MRC_ADDR

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-23 10:15:13 -05:00
Tom Rini
6bd2372094 env: Rework ENV_IS_EMBEDDED and related logic slightly
- Drop CONFIG_BUILD_ENVCRC as this is never set directly but instead
  means ENV_IS_EMBEDDED, so reference that in code and rename the Makefile
  usage to BUILD_ENVCRC.
- Remove extra-$(CONFIG_ENV_IS_EMBEDDED) line as it could never be true,
  and likely why there is an extra- line for CONFIG_ENV_IS_IN_FLASH (the
  only use case today of embedded environments).
- With these slight changes we can then see that using the calculated
  symbol of ENV_IS_EMBEDDED is the right thing to use in any code which
  needs to know this situation and can remove CONFIG_ENV_IS_EMBEDDED
  entirely.

Signed-off-by: Tom Rini <trini@konsulko.com>
2022-12-22 10:31:47 -05:00
Max Krummenacher
486aef08de u-boot-initial-env: rework make target
With LTO enabled the U-Boot initial environment is no longer stored
in an easy accessible section in env/common.o. I.e. the section name
changes from build to build, its content maybe compressed and it is
annotated with additional data.

Drop trying to read the initial env with elf tools from the compiler
specific object file in favour of adding and using a host tool with
the only functionality of printing the initial env to stdout.

See also:
https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332c77@foss.st.com/

Signed-off-by: Max Krummenacher <max.krummenacher@toradex.com>
Acked-by: Pali Rohár <pali@kernel.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-08 09:29:02 -05:00
Marc Kleine-Budde
28f924f265 tools: mkimage: add new image type "fdt_legacy"
If the user select the image type "flat_dt" a FIT image will be build.
This breaks the legacy use case of putting a Flat Device Tree into a
legacy u-boot image.

Add a new image type "fdt_legacy" to build a legacy u-boot image
with a "flat_dt" type.

Link: https://lore.kernel.org/all/20221028155205.ojw6tcso2fofgnhm@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Reviewed-by: Sean Anderson <seanga2@gmail.com>
2022-12-08 09:29:02 -05:00
Marc Kleine-Budde
72c3f5dbd9 tools: mkimage: don't print error message "Success" in case of failure
In case there's no struct image_type_params::set_header callback, no
"errno" will be set. Don't fail with an error message, followed by
"Success". Remove the printing of the human readable "errno" value.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-08 09:29:02 -05:00
Mikhail Ilin
4b95e8407e tools: fdtgrep: Fix handle leak
The handle "fd" was created in fdtgrep.c:708 by calling the
 "open" function and is lost in fdtgrep.c:716 and fdtgrep.c:723.
 Close file descriptor 'fd' before exiting with an error from function
 utilfdt_read_err_len(const char *filename, char **buffp, off_t *len).

Fixes: 1043d0a029 ("fdt: Add fdtgrep tool")
Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-08 09:29:02 -05:00
Mikhail Ilin
17f8a74876 tools: mkimage: Fix nullptr at strchr()
The copy_datafile(ifd, params.datafile) function has been
 implemented to copy data by reducing the number of lines in the main
 function.

Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
2022-12-08 09:29:01 -05:00
Mikhail Ilin
2d1b2ac13f tool: ifwitool: Fix buffer overflow
An incorrect 1st parameter is passed to the fix_member()
 function. Should use a pointer to the beginning of the parent structure
 (bpdt or subpart_dir, because are boxed), not to their fields. Otherwise,
 this leads to an overrun of the structure boundary, since in the
 fix_member() function, an 'offset' is made, relative to the 1st argument,
 which itself is an 'offset' from the beginning of the structure.

Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-08 09:25:44 -05:00
Mikhail Ilin
164232943c tool: ifwitool: The function localtime() can return NULL.
This will cause the local_time pointer is passed as the 4th argument
 to function strftime() to also point to NULL. This result in a
 segmentation fault. Thus, it's necessary to add a check of the local_time
 pointer to NULL.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Mikhail Ilin <ilin.mikhail.ol@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-08 09:25:44 -05:00
Jaehoon Chung
c059a22b77 tools: env: fw_env: Fix unused-result warning
Fix unused-result warning about fread.

tools/env/fw_env.c: In function ‘find_nvmem_device’:
tools/env/fw_env.c:1751:3: warning: ignoring return value of ‘fread’, declared with attribute warn_unused_result [-Wunused-result]
 1751 |   fread(buf, sizeof(buf), 1, fp);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
2022-12-08 09:25:44 -05:00
Tom Rini
09ed7e62f3 CI: Update to gcc-12.2
- Update to gcc-12.2, and cherry-pick a fix in grub for risc-v

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-06 15:30:30 -05:00
Tom Rini
83e37a8345 buildman: Fetch 12.2.0 toolchains by default
Update the toolchain list to be first 12.2.0 and second 11.1.0 and
that's it.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-06 15:30:30 -05:00
Tom Rini
65cc0e2a65 global: Move remaining CONFIG_SYS_* to CFG_SYS_*
The rest of the unmigrated CONFIG symbols in the CONFIG_SYS namespace do
not easily transition to Kconfig. In many cases they likely should come
from the device tree instead. Move these out of CONFIG namespace and in
to CFG namespace.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-12-05 16:06:08 -05:00
Marek Vasut
c246d69f31 tools: mkenvimage: Drop duplicate crc header include
This header was already included just above version.h,
do not include it twice.

Fixes: 3db7110857 ("crc32: Use the crc.h header for crc functions")
Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-23 13:06:12 -05:00
Simon Glass
8dd0059f77 binman: Add documentation for the command line args
Add command-line documentation for binman.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:35 -07:00
Tom Rini
d7713ad36f buildman: Add --allow-missing flag to allow missing blobs
Add a new flag to buildman so that we will in turn pass
BINMAN_ALLOW_MISSING=1 to 'make'. Make use of this flag in CI.

Allow the settings file to control this.

Cc: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:35 -07:00
Simon Glass
5f319fa728 buildman: Reinstate removal of temp output dir in tests
This was dropped my mistake. Reinstate it.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: d829f1217c ("bulidman: Add support for a simple build")
2022-11-22 15:13:35 -07:00
Simon Glass
301cd7431a buildman: Ensure config_fname is inited
Init this variable at the top level since it is a global.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:35 -07:00
Simon Glass
85760a690d binman: Add a separate section about environment variables
These are documented in various several sections. Add a new section that
mentions them all in one place so it is easier to see what environment
variables can be used to control U-Boot's use of binman.

Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2022-11-22 15:13:35 -07:00
Simon Glass
35b6e53d0d buildman: Detect binman reporting missing blobs
Buildman should consider a build as a success (with warnings) if missing
blobs have been dealt with by binman, even though buildman itself returns
and error code overall. This is how other warnings are dealt with.

We cannot easily access the 103 exit code, so detect the problem in the
output.

With this change, missing blobs result in an exit code of 101, although
they still indicate failure.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:35 -07:00
Simon Glass
cd6889d896 buildman: Drop mention of old architectures
Support for some architectures has been removed since buildman was first
written. Also all toolchains are now available at kernel.org so we don't
need the links, except for arc where the kernel.org toolchain fails to
build all boards.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Simon Glass
3da04ff1d3 buildman: Update the default settings file
The settings file omits a few lines which are useful for getting every
board building. Add these and update the documentation tool.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Simon Glass
ce59252df5 buildman: Update the arc toolchain
There is one on kernel.org but it does not build the hsdk_4xd board. Add
a link to one which does.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Simon Glass
274d05303d buildman: Drop mention of MAKEALL
This script was removed about 6 years ago so most people should be aware
that it is not needed anymore. Drop mention of it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Simon Glass
74df491051 buildman: Convert documentation to rST
Convert the buildman documentation to rST format and include it in the
'build' section.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Quentin Schulz <foss+uboot@0leil.net>
2022-11-22 15:13:34 -07:00
Simon Glass
b38da15a05 binman: Use an exit code when blobs are missing
At present binman returns success when told to handle missing/faked blobs
or missing bintools. This is confusing since in fact the resulting image
cannot work.

Use exit code 103 to signal this problem, with a -W option to convert
it to a warning.

Rename the flag to --ignore-missing since it controls bintools also.

Add documentation about exit codes while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Quentin Schulz
fb132b3727 Revert "binman: btool: gzip: fix packer name so that binary can be found"
This reverts commit daa2da754a.

This commit is not needed anymore since the btool_ prefix is
automatically stripped by bintool.

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Quentin Schulz
478332a345 binman: bintool: remove btool_ prefix from btool names
The binary is looked on the system by the suffix of the packer class.
This means binman was looking for btool_gzip on the system and not gzip.

Since a btool can have its btool_ prefix missing but its module and
binary presence on the system appropriately found, there's no need to
actually keep this prefix after listing all possible btools, so let's
remove it.

This fixes gzip btool by letting Bintool.find_bintool_class handle the
missing prefix and still return the correct class which is then init
with gzip name instead of btool_gzip.

Additionally, there was an issue with the cached module global variable.
The variable only stores the module and not the associated class name
when calling find_bintool_class.
This means that when caching the module on the first call to
find_bintool_class, class_name would be set to Bintoolbtool_gzip but the
module_name gzip only, adding the module in the gzip key in the module
dictionary. When hitting the cache on next calls, the gzip key would be
found, so its value (the module) is used. However the default class_name
(Bintoolgzip) is used, failing the getattr call.

Instead, let's enforce the same class name: Bintool<packer>, whatever
the filename it is contained in.

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2022-11-22 15:13:34 -07:00
Sughosh Ganu
f65ee99b9d mkeficapsule: Add support for setting OEM flags in capsule header
Add support for setting OEM flags in the capsule header. As per the
UEFI specification, bits 0-15 of the flags member of the capsule
header can be defined per capsule GUID.

The oemflags will be used for the FWU Multi Bank update feature, as
specified by the Dependable Boot specification[1]. Bit
15 of the flags member will be used to determine if the
acceptance/rejection of the updated images is to be done by the
firmware or an external component like the OS.

[1] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
2022-10-31 14:47:33 -04:00
Sughosh Ganu
6da9271af1 mkeficapsule: Add support for generating empty capsules
The Dependable Boot specification[1] describes the structure of the
firmware accept and revert capsules. These are empty capsules which
are used for signalling the acceptance or rejection of the updated
firmware by the OS. Add support for generating these empty capsules.

[1] - https://git.codelinaro.org/linaro/dependable-boot/mbfw/uploads/6f7ddfe3be24e18d4319e108a758d02e/mbfw.pdf

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
2022-10-31 14:47:33 -04:00
Sughosh Ganu
873cf8ac70 test: dm: Add test cases for FWU Metadata uclass
Add test cases for accessing the FWU Metadata on the sandbox
platform. The sandbox platform also uses the metadata access driver
for GPT partitioned block devices.

The FWU feature will be tested on the sandbox64 variant with a raw
capsule. Remove the FIT capsule testing from sandbox64 defconfig --
the FIT capsule test will be run on the sandbox_flattree variant.

Signed-off-by: Sughosh Ganu <sughosh.ganu@linaro.org>
Suggested-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2022-10-31 14:47:33 -04:00
Simon Glass
d2afb9edce binman: Support writing symbols into ELF files
In some cases the ELF version of SPL builds may be packaged, rather
than a binary .bin file. Add support for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31 11:02:44 -04:00
Simon Glass
3fbba5568c binman: Handle writing ELF symbols in the Entry class
This feature is used by several etypes and we plan to add more that use
it. Make symbol writing a feature of the base class to reduce the code
duplication.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31 11:01:31 -04:00
Simon Glass
2b8b27fb8d binman: Split out looking up a symbol into a function
Move this code into its own function so it can be used from tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2022-10-31 11:01:31 -04:00