Commit Graph

99636 Commits

Author SHA1 Message Date
Simon Glass
be5644b176 treewide: Add missing string.h includes
Add string.h to files that use string functions like strdup, strcmp,
strcpy, etc. These are implicitly available through the malloc.h header
but that will soon change.

For bouncebuf, take this opportunity to sort the headers correctly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:57:27 +00:00
Simon Glass
092588090a test: hooks: Add a symlink for tasman
Add a symlink to ellesmere so we can run tests on tasman.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:57:27 +00:00
Simon Glass
05fd95e17d Merge branch 'mal' into 'master'
backtrace: Add runtime support for looking at the backtrace

See merge request u-boot/u-boot!215
2025-12-01 15:56:34 +00:00
Simon Glass
cee822e941 backtrace: Strip the source tree prefix from filenames
Display relative paths instead of absolute paths in backtrace output,
making the output cleaner and more portable across different build
environments.

This works by adding a SRCTREE define to lib/backtrace.c and stripping
it from filenames when printing.

Series-to: concept
Series-cc: heinrich
Cover-letter:
backtrace: Add runtime support for looking at the backtrace
In some cases the backtrace contains useful information, such as whether
a particular function was called earlier in the stack.

This series provides a very simple backtrace library, along with some
sandbox-specific functions to allow it to work. It is designed such that
another arch could implement it.

A new 'backtrace' command provides access to the backtrace.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
eb711c45ce backtrace: doc: Mention the feature
Add a short section about the backtrace feature to the sandbox docs.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
b174084ef9 backtrace: Add a command
Add a new 'backtrace' command which prints the current call stack, which
is useful for debugging. The command is enabled by CONFIG_CMD_BACKTRACE

Add docs and a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
14b0a3e2e0 backtrace: Add a test
Add a simple test for the backtrace library.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
798e8fd233 backtrace: sandbox: Add -rdynamic to export symbols
Add the -rdynamic linker flag so that backtrace_symbols() can resolve
function names. This is needed to show meaningful symbol names instead
of just addresses.

Only enable this CONFIG_BACKTRACE and CONFIG_CMDLINE are enabled, since
it causes build failures with the tools-only build and sandbox_nocmdline

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
2fcd53108e backtrace: sandbox: Link with libbacktraces
Link with libbacktrace when CONFIG_BACKTRACE is enabled. This library is
bundled with GCC and provides DWARF-based symbol resolution for
backtraces.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
d5e3d066c7 backtrace: sandbox: Add support for obtaining symbols
Add backtrace functions for sandbox, including:

- os_backtrace() to collect addresses into a caller-supplied buffer
- os_backtrace_symbols() to convert addresses to symbol strings
- os_backtrace_symbols_free() to free the symbol array

The libbacktrace library (bundled with GCC) reads DWARF debug information
to provide detailed symbol resolution including function names (even for
static functions), source file paths, and line numbers.

The sandbox backtrace implementation wraps these OS functions to implement
the generic backtrace API (backtrace_init, backtrace_get_syms, etc.).

Enable it for just the 'sandbox' board. Add the library for the Rust
example too.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
797feb61d0 CI: Disable backtrace for the trace test
This test expects to only sese a subset of the symbols in the
executable. Disable backtrace to avoid dealing with changes in this
area.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
cdde93a9e3 backtrace: Add a library to access the backtrace
Provide an API to access the backtrace, in an arch-neutral way.

The backtrace can be retrieved, examined and printed.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
e0b8e54f52 claude: Tell it about my crosfw script being silent
Add a note about this. At some point we should create a proper tools for
IDE use in U-Boot.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
GitLab CI
6a30ab6faa docs: Add 2025.12 to release history 2025-12-01 10:46:19 +00:00
GitLab CI
a7a93faecd chore: Bump version for final release 2025.12 c2025.12 2025-12-01 10:46:17 +00:00
Simon Glass
1c287a8681 Merge branch 'ofn' into 'master'
dm: core: Create ofnode stubs when OF_REAL is disabled

See merge request u-boot/u-boot!214
2025-12-01 08:00:15 +00:00
Simon Glass
ccdcd03a6e dm: core: Create ofnode stubs when OF_REAL is disabled
When there is no device tree there is not point in trying to find nodes,
etc. since they will all be null.

Add static inlines to skip the code in that case.

Unfortunately this makes the file a little convoluted and there are
two inlines for ofnode_is_enabled() and ofnode_first/next_subnode(). But
it seems better than the alternative.

We could also consider splitting up the header file.

Also add a rule in drivers/Makefile to compile ofnode.o when OF_REAL is
enabled but DM is not (for kontron-sl-mx6ul) and move the
ofnode_for_each_compatible_node/prop() macros outside the OF_REAL
condition, since they only use functions that have stubs.

Series-to: concept
Series-cc: heinrich

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-28 11:07:17 -07:00
Simon Glass
6d3cb76fe2 Merge branch 'codman' into 'master'
codman: Add a new source-code analysis tool

See merge request u-boot/u-boot!213
2025-11-24 21:34:12 +00:00
Simon Glass
9d6670f89a codman: Add documentation
Provide a description of the purpose of codman and some examples of how
to use it.

Series-to: concept
Cover-letter:
codman: Add a new source-code analysis tool

Add a new tool called 'codman' (code manager) for analysing source code
usage in U-Boot builds. This tool determines which files and lines of
code are actually compiled based on the build configuration.

The tool provides three analysis methods:
- unifdef: Static preprocessor analysis (default)
- DWARF: Debug information from compiled code (-w)
- (experimental) LSP: Language server analysis using clangd (-l)

Codman supports:

- File-level analysis: which files are compiled vs unused
- Line-level analysis: which lines are active vs removed by preprocessor
- Kconfig-impact analysis with -a/--adjust option
- Various output formats: stats, directories, detail, summary

Since there is quite a lot of processing involved, Codman uses parallel
processing where possible.

This tool is admittedly not quite up to my normal code quality, but it
has been an interesting experiment in using Claude to create something
from scratch.

The unifdef part of the tool benefits from some patches I created for
that tool:
- O(1) algorithm for symbol lookup, instead of O(n) - faster!
- support for IS_ENABLED(), CONFIG_IS_ENABLED()

Please get in touch if you would like the patches.

This series also includes a minor improvement to buildman and a tidy-up
of the tout library to reduce code duplication.
END

Signed-off-by: Simon Glass <simon.glass@canonical.com>
Series-links: 1:65
2025-11-24 06:47:19 -07:00
Simon Glass
d2772a2359 codman: Add some basic tests
Add some rudimentary tests of the codman functionality.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
50e9e75d44 codman: Begin an experimental lsp analyser
It is possible to use an LSP to determine which code is used, at least
to some degree.

Make a start on this, in the hope that future work may prove out the
concept.

So far I have not found this to be particularly useful, since it does
not seem to handle IS_ENABLED() and similar macros when working out
inactive regions.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
683d1578ae codman: Provide an dwarf analyser
Add a way to do static preprocessor analysis using debug information
from compiled code. This reads the DWARF tables to determin which lines
produced code.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:47:07 -07:00
Simon Glass
aeae0f5d58 codman: Provide an unifdef analyser
Add a way to do static preprocessor analysis using unifdef, as a way of
figuring out what code is actually used in the build.

I have modified the unifdef tool as follows:
- O(1) algorithm for symbol lookup, instead of O(n)
- support for IS_ENABLED(), CONFIG_IS_ENABLED()

The first patch was sent upstream. The others are U-Boot-specific so I
have not submitted those.

Please get in touch if you would like the patches.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:44:52 -07:00
Simon Glass
1839832ad3 codman: Add a new source-code analysis tool
Add a new tool called 'codman' (code manager) for analysing source code
usage in U-Boot builds. This tool determines which files and lines of
code are actually compiled based on the build configuration.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-24 06:34:31 -07:00
Simon Glass
2006fc3693 buildman: Support comma-separated values in -a flag
Allow users to specify multiple config adjustments in a single -a
argument using commas. This is more convenient than repeating -a
multiple times.

Examples:
  buildman -a FOO,~BAR
  buildman -a FOO,~BAR -a BAZ=123

Add tests to verify comma-separated values work correctly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-23 12:25:30 -07:00
Simon Glass
bde75b138a u_boot_pylib: Use terminal.tprint() for output in tout
Refactor tout.py to use terminal.tprint() instead of direct print()
calls. This provides better control over output formatting and
supports the new stderr parameter. It also reduces code duplication.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-22 14:53:50 -07:00
Simon Glass
c6f2e290f4 u_boot_pylib: Add stderr parameter to tprint()
Add optional stderr parameter to tprint() to allow printing to stderr
instead of stdout.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-22 14:53:23 -07:00
Simon Glass
ac7212f5f9 Merge branch 'fita' into 'master'
fit: Improve and test the code to print FIT info

See merge request u-boot/u-boot!212
2025-11-20 22:11:13 +00:00
Simon Glass
9aa0a53db6 fit: Use the libfdt subnode iterator
Replace fdt_next_node() with depth tracking with fdt_for_each_subnode()
which has been available for some time.

This also fixes a latent bug where the default configuration was being
read from the wrong node offset. It happened to work before because
noffset ended up at the right value after the images loop.

Series-to: concept
Series-cc: heinrich
Cover-letter:
fit: Improve and test the code to print FIT info
The code for printing information about FITs is fairly old and not that
easy to maintain. It also lacks tests.

This series adds some tests, moves the code into its own file and then
adds a series of helpers to deal with the intricacies of printing each
item.

This provides a binary-size reduction of about 320 bytes on aarch64.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
a1429a036a fit: Add a helper to iterate through hash/signature nodes
The pattern for iterating through and processing hash/signature subnodes
is repeated in two places. Add a new process_subnodes() helper to reduce
code duplication.

Drop the now-unused ndepth and noffset local variables.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
b6674168b9 fit: Use a boolean to simplify type checks
Add a boolean variable 'loadable' that combines the common type check
for kernel, standalone, and ramdisk images.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
8f5e311f3b fit: Add a helper for address printing
Add emit_addr() to handle printing load an entry addresses.

The helper takes a 'valid' boolean parameter to determine whether to
print the address value or 'unavailable'.

Combine the two separate if() blocks for the load address.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
47953a00bb fit: Add a helper for printing descriptions
Add emit_desc() which handles getting and printing descriptions from FIT
nodes. Handle the "unavailable" case when a description is missing.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
0d5a23344d fit: Add a helper for stringlist properties
Add a emit_stringlist() helper function to simplify printing stringlist
properties in FIT configurations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
b0a3ebd1fd fit: Add a helper for timestamp printing
Add a new emit_timestamp() helper function to handle printing timestamps
in FITs.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
79388f8fe8 fit: Add a helper to output optional properties
Add a new emit_prop() helper function to simplify printing optional
properties in FIT configurations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
6329055745 fit: Use emit_label_val() where possible
Refactor the printing of multi-line properties to use the
emit_label_val() helper function instead of custom formatting.

Update emit_label() to deal with an empty label and not show a colon in
that case.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
819ef32f87 fit: Move values one column to the right
Line up the values witht the FIT Description and Created items at the
top. This looks a little nicer.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
192c586a5d fit: Change indent from string to int
Change the indent field in fit_print_ctx from a string pointer to an int
number of spaces to indent.

Set the initial indent value to 3 to match IMAGE_INDENT_STRING

Drop indentation from the debug() calls since these are not visible to
users.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
e18f514654 fit: Add a a function to print labels with values
Add a new emit_label_val() helper function that combines emit_label()
and printf() for simple label-value pairs.

Make use of it where appropriate.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
4669924871 fit: Use emit_label() helper in fit_conf_print()
Update fit_conf_print() to use the emit_label() helper function for
printing labels.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:46 -07:00
Simon Glass
9515fa96e6 fit: Use emit_label() helper in fit_image_print()
Update fit_image_print() to use the emit_label() helper function for
printing labels. This avoids various manual printf() calls and spacing
logic.

Set ctx->tab to 19 to align values at the correct column position.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:51:45 -07:00
Simon Glass
9b875f54ef fit: Create some helpers for printing
The current code is quite fiddly with manually spaced labels. Add helper
functions for printing labels (with or without a type prefix) with a
cofigurable tab width for the value that folows.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
62a4c7e10a fit: Put the indent string into print context
Move the indent string into struct fit_print_ctx so it is available to
the printing functions. This avoids having to pass it as a separate
parameter.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
6b6f03c388 fit: Add a context struct for FIT-printing
Create a struct fit_print_ctx to hold the FIT pointer and pass it to all
printing functions instead of passing the FIT pointer directly. This
provides a foundation for adding additional context in the future.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
5cb5809acd fit: Drop showing an unused 'required' property
This is actually not defined by the spec. The 'required' property is for
use by the verifying code. Having it in the FIT does not help size an
attacker could potentially remove it.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:10 -07:00
Simon Glass
0b51f99bf0 fit: Move printing code to its own file
There is enough code here that it makes sense to put it in its own file.
Create a new fit_print.c file, before undertaking future refactoring.

Printing is only included in the main build if CONFIG_FIT_PRINT is
enabled, although it is always included in the tools build.

Add static inlines for existing callers.

Make a few small code-style adjustments, including fixing checkpatch
warnings about over-use of brackets.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:50:09 -07:00
Simon Glass
f2892511ef fit: Refactor fit_print_contents() to use new fit_print()
Create a new fit_print() function containing the logic from
fit_print_contents(), and make fit_print_contents() call it.
This allows future callers to use fit_print() directly as we add more
features.

Tidy up the function comments so that they are in the header.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:41:39 -07:00
Simon Glass
ff60648e0b test: fit: Add pytest for mkimage output
Add a new pytest to check the output of 'mkimage -l' on the test FIT.

Only check the first 80 chars as the signature lines can be very long.

The timestamps are quite annoying, since we need the test to pass on
whatever CI machine is used. Obtain the first timestamp and use that to
check the rest, after some sanity checks.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:40:54 -07:00
Simon Glass
90dc46ddfd test: fit: Add test for missing FIT description
Add a test to verify that fit_print_contents() correctly handles a FIT
image with a missing description property.

To handle this a new FIT created with the description removed after
mkimage has processed it, since mkimage will fail if the description is
missing.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-19 19:39:10 -07:00