Commit Graph

99814 Commits

Author SHA1 Message Date
Simon Glass
999a36a675 pickman: Add argument parsing with compare and test commands
Add subcommand support:
- compare: Compare branches (existing functionality)
- test: Run the functional tests

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
840c1a6855 pickman: Add tool to compare branch differences
Add a tool to check the number of commits in a source branch
(us/next) that are not in the master branch (ci/master), and find
the last common commit between them.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-16 13:15:19 +00:00
Simon Glass
ac3e0a2da4 Merge branch 'cherry-a8c07ac4970' into 'master'
[pickman] Merge https://source.denx.de/u-boot/custodians/u-boot-riscv

See merge request u-boot/u-boot!232
2025-12-16 13:14:49 +00:00
Simon Glass
2a205595ac pickman: Record cherry-pick of 17 commits from us/next
- a8c07ac497 alist: Mention the error condition in alist_add_placeholder()
- 13bd298499 alist: Add a comment for alist_init_struct()
- 6668d860f7 alist: Expand the comment for alist_get()
- 2ce146a3de alist: Add a way to get the next element
- 83bc5989fc alist: Add for-loop helpers
- 70f5f17415 alist: Add a function to empty the list
- d01c58acb7 alist: Add a way to efficiently filter an alist
- b84c13f37d alist: Add maintainer
- cedf9ccaa2 dm: core: Add a function to see if a device exists
- 6e625484f5 test: boot: Use a consistent name for the script bootmeth
- 57e77dc80e arm: dts: e850-96: Remove TRNG node from appended dts
- 33ddfc059e driver: sifive ccache: enable TRUNKCLOCKGATE and REGIONCLOCKGATE
- e83a99cb67 configs: visionfive2: re-enable SPL_SYS_MMCSD_RAW_MODE
- d86ff34285 xilinx: mbv: Place DTB by default to DDR location
- e4b8d8be4e xilinx: mbv: Align smode_defconfig with upstream QEMU
- d5f5e77818 riscv: Introduce configuration for 64bit version Microblaze V
- a7a96a37cb Merge https://source.denx.de/u-boot/custodians/u-boot-riscv
2025-12-15 17:36:18 -07:00
Andreas Schwab
ce6c8cd376 configs: visionfive2: re-enable SPL_SYS_MMCSD_RAW_MODE
To restore MMC boot, enable SPL_SYS_MMCSD_RAW_MODE and recover
SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION and
SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION.

Fixes: 2a00d73d08 ("spl: mmc: Try to clean up raw-mode options")
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
(cherry picked from commit e83a99cb67)
2025-12-15 17:34:46 -07:00
Simon Glass
ccba4fac93 Merge branch 'cherry-e5565c24bb4' into 'master'
[pickman] Merge tag 'u-boot-amlogic-next-20241113' of https://source.denx.de/u-boot/custodians/u-boot-amlogic into next

See merge request u-boot/u-boot!230
2025-12-15 23:57:34 +00:00
Simon Glass
ce07e78917 pickman: Record cherry-pick of 8 commits from us/next
- e5565c24bb pinctrl: exynos: fix type of count integer
- 57e77dc80e arm: dts: e850-96: Remove TRNG node from appended dts
- 895b54998e configs: khadas-vim3{l}: fix userdata size
- ea2273911d arm: dts: meson: remove meson-a1.dtsi
- a5ed242ba6 dt-bindings: remove a1 bindings from include/
- 827edb6c00 dt-bindings: remove axg bindings from include/
- 1cdb4e03e6 dt-bindings: interrupt-controller: remove arm-gic.h from include/
- 030ec147af Merge tag 'u-boot-amlogic-next-20241113' of https://source.denx.de/u-boot/custodians/u-boot-amlogic into next
2025-12-15 16:20:22 -07:00
Simon Glass
7764e43798 Merge branch 'cherry-e5565c24bb4' into 'master'
[pickman] Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-marvell

See merge request u-boot/u-boot!229
2025-12-15 17:28:00 +00:00
Simon Glass
8c915b40e6 pickman: Record cherry-pick of 15 commits from us/next
- e5565c24bb pinctrl: exynos: fix type of count integer
- 57e77dc80e arm: dts: e850-96: Remove TRNG node from appended dts
- 06b8aafd68 fastboot: properly handle unknown partition type
- 35d967f5a8 usb: ci_udc: don't use "advance" feature when setting address
- 325ac6c1e7 arm: mvebu: Disable JFFS2 support for Kirkwood and Armada XP boards
- 96ca314798 arm: kirkwood: Enable bootstd for Sheevaplug board
- 3eef899b57 arm: mvebu: x240: Use default baudrate table
- 27b2488735 arm: mvebu: x240: Switch to standard boot
- cbbfa8d778 arm: mvebu: x240: Don't build mkeficapsule
- b25b2d4f67 arm: mvebu: x240: Enable IPV6 support
- 1b46176532 arm: mvebu: x530: Remove dead comments
- c6b17af142 arm: mvebu: x530: Don't build mkeficapsule
- f337b5aaad arm: mvebu: x530: Enable IPV6 support
- 7446e29db5 arm: mvebu: Add Allied Telesis x250 board
- 6b96e01d70 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-marvell
2025-12-15 17:22:49 +00:00
Tom Rini
32c3528553 Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-marvell
CI: https://dev.azure.com/sr0718/u-boot/_build/results?buildId=379&view=results

- mvebu: Disable JFFS2 support for Kirkwood and Armada XP boards (Tony)
- kirkwood: Enable bootstd for Sheevaplug board (Tony)
- mvebu: Add Allied Telesis x250 board (Chris)
- mvebu: Updates for Allied Telesis boards (Chris)

(cherry picked from commit 6b96e01d70)
2025-12-15 17:22:49 +00:00
Chris Packham
eacc233618 arm: mvebu: Add Allied Telesis x250 board
The x250 and SE250 are series of 10G L2+ switches from Allied Telesis.
There are a number of them in the range but as far as U-Boot is
concerned all the CPU block components are the same so there's only one
board defined.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 7446e29db5)
2025-12-15 17:22:49 +00:00
Chris Packham
60736a48d0 arm: mvebu: x530: Enable IPV6 support
Enable IPV6 support for the x530 board.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit f337b5aaad)
2025-12-15 17:22:49 +00:00
Chris Packham
5854e1862f arm: mvebu: x530: Don't build mkeficapsule
The x530 board doesn't use EFI and our toolchains don't include gnutls
so disable the tool in the defconfig.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit c6b17af142)
2025-12-15 17:22:49 +00:00
Chris Packham
efafd5c5f7 arm: mvebu: x530: Remove dead comments
As things have been moved to Kconfig there are a number of dead comments
left over in x530.h. Remove them.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 1b46176532)
2025-12-15 17:22:49 +00:00
Chris Packham
0cba095cd8 arm: mvebu: x240: Enable IPV6 support
Enable IPV6 support for the x240 board.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit b25b2d4f67)
2025-12-15 17:22:49 +00:00
Chris Packham
56c7233984 arm: mvebu: x240: Don't build mkeficapsule
The x240 board doesn't use EFI and our toolchains don't include gnutls
so disable the tool in the defconfig.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit cbbfa8d778)
2025-12-15 17:22:49 +00:00
Chris Packham
5fc2a23fef arm: mvebu: x240: Switch to standard boot
Use standard boot instead of the distro boot scripts. Regenerate the
board defconfig now that some options are selected automatically.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 27b2488735)
2025-12-15 17:22:49 +00:00
Chris Packham
a544abd882 arm: mvebu: x240: Use default baudrate table
Remove CFG_SYS_BAUDRATE_TABLE as there's no reason not to use the
defaults defined via config_fallbacks.h.

Signed-off-by: Chris Packham <judge.packham@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 3eef899b57)
2025-12-15 17:22:49 +00:00
Tony Dinh
25865bec72 arm: kirkwood: Enable bootstd for Sheevaplug board
Enable bootstd for Sheevaplug board.
Remove JFFS2 support. See JFFS2 Vulnerability[1].
Enable LTO to keep board size within limit.
Move default envs to text-base environment

[1] https://lore.kernel.org/u-boot/20241114233005.GN3600562@bill-the-cat/T/#m2fc25da1d2c019bc3cd8676991fdd64b8a21aa9b

Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 96ca314798)
2025-12-15 17:22:49 +00:00
Tony Dinh
fbc10dc64b arm: mvebu: Disable JFFS2 support for Kirkwood and Armada XP boards
These boards don't use JFFS2 file system for booting so remove it.

Ref: https://lore.kernel.org/u-boot/20241114233005.GN3600562@bill-the-cat/T/#t
Signed-off-by: Tony Dinh <mibodhi@gmail.com>
Acked-by: Phil Sutter <phil@nwl.cc>
Reviewed-by: Stefan Roese <sr@denx.de>
(cherry picked from commit 325ac6c1e7)
2025-12-15 17:22:49 +00:00
Ion Agorria
8cbd6d29d5 usb: ci_udc: don't use "advance" feature when setting address
In the older USB controllers like for example in ChipIdea controller
used by the Tegra 2 the "USBADRA: Device Address Advance" bitflag
does not exist, so the new device address set during SET_ADDRESS
can't be deferred by hardware, which causes the host to not recognize
the device and give an error.

Instead store it until ep completes to apply the change into the hw
register as Linux kernel does. This should fix regression on old and
and be compatible with newer controllers.

Inspired by: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ef15e5490edc7edf808d3477ab32e0e320792f65

Signed-off-by: Ion Agorria <ion@agorria.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20241126072956.64778-2-clamor95@gmail.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
(cherry picked from commit 35d967f5a8)
2025-12-15 17:22:49 +00:00
Caleb Connolly
8bc8a47f18 fastboot: properly handle unknown partition type
In getvar_partition_type() we attempt to find a filesystem driver for
the partition (of the list of driver enabled in U-Boot), on failure we
return the error to fastboot and completely bail out of the operation.

However, this should not be a failure, instead we should just default to
"raw". This allows commands like "fastboot format:ext4 userdata" to work
if userdata didn't already have an ext4 partition table (or if FS_EXT4
is disabled in U-Boot), as failing to determine the current partition
type is not an error in this case.

Signed-off-by: Caleb Connolly <caleb.connolly@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Link: https://lore.kernel.org/r/20241113050607.1850472-1-caleb.connolly@linaro.org
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
(cherry picked from commit 06b8aafd68)
2025-12-15 17:22:49 +00:00
Sam Protsenko
58bb626f09 arm: dts: e850-96: Remove TRNG node from appended dts
Commit 136b7b6d2e ("Subtree merge tag 'v6.11-dts' of dts repo [1] into
dts/upstream") updates the upstream dts for E850-96 board, bringing
upstream TRNG node. There is no need to keep TRNG node in appended dts
anymore, so remove it.

Tested on E850-96 board by running 'rng' command in U-Boot shell.

Signed-off-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
(cherry picked from commit 57e77dc80e)
2025-12-15 17:22:49 +00:00
Henrik Grimler
c2851e54a1 pinctrl: exynos: fix type of count integer
unsigned int count is used to capture return of dev_read_string_count.
When an error occurs dev_read_string_count returns -ve, which can
hence not be handled correctly. Use int instead of unsigned int so
that errors are detected.

Fixes: 16ca80adc5 ("pinctrl: Add pinctrl driver support for Exynos7420 SoC")

Signed-off-by: Henrik Grimler <henrik@grimler.se>
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
(cherry picked from commit e5565c24bb)
2025-12-15 17:22:49 +00:00
Simon Glass
27e70d6f56 Merge branch 'tesf' into 'master'
test: Add support for passing arguments to C unit tests

See merge request u-boot/u-boot!223
2025-12-15 17:21:37 +00:00
Simon Glass
2b6e3394fb test: Add documentation for test parameters
Add a description of how test parameters work. This helps to make it
easier to write C tests which need setup to be done in Python.

Series-to: concept
Series-cc: heinrich
Cover-letter:
test: Add support for passing arguments to C unit tests
This series adds infrastructure for passing runtime arguments from Python
tests to C unit tests. This makes it easier to support a hybrid testing
approach where Python handles complex setup (filesystem images,
environment configuration) while C handles the actual test logic with
better debuggability.

A few other things are included to make this work:

- A fix for linker list alignment that was causing garbage values like
  "Running -858993444 bloblist tests" due to GCC's magic-number division
  optimization failing when padding breaks exact multiples

- A fix fix for serial output with sandbox, since it sometimes misses
  output at the end when running tests with gnome terminal

- Improvements to the linker-list script to detect padding and
  pointer-arithmetic bugs

- A new UNIT_TEST_ARGS() macro for declaring tests with typed arguments,
  along with argument parsing in the ut command (name=value format)

- Argument-accessor macros ut_str(), ut_int(), and ut_bool() with
  type-checking and bounds validation

- A private buffer (uts->priv) for test-local temporary data, which
  makes it a little easier to write shorter tests

- Tests for the argument feature (test_args) covering type checking,
  bounds checking, and argument-parsing failures

As an example, the basic filesystem tests are converted from pure Python
to C with Python wrappers.

Some improved printf documentation and support for Linux's %pV format
are provided.

The slight increase in size causes qemu-riscv64_spl to fail, so this
series also includes a patch to increase the SPL-malloc() space.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:52:56 -07:00
Simon Glass
32c67c43fb test: fs: Update Python tests to call C implementations
Update test_basic.py to call the new C-based filesystem tests via the
'ut' command. This allows tests to run more directly, calling the actual
FS layer, without having to go through the command interface and
worrying about which filesystem command to use.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:52:56 -07:00
Simon Glass
72aeb4a2e2 test: fs: add C-based filesystem tests
Add C implementations of filesystem tests that can be called via
the 'ut fs' command. These tests use UTF_MANUAL flag since they require
external setup, i.e. creation of filesystem images.

This covers the existing TestFsBasic tests.

The tests use typed arguments (fs_type, fs_image, md5 values) passed
via the command line.

Add a few helpers to make the code easier to read.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:52:56 -07:00
Simon Glass
2ac3226758 test: Add tests for unit-test arguments
Add a set of tests to check the behaviour of test arguments and the ut
command. This includes failure cases, where the wrong type or a
non-existent argument is requested.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:17:31 -07:00
Simon Glass
688e830a22 test: Allow preserving console recording on failure
Update the 'ut' command to have a -R command option to prevent ut_fail()
and ut_failf() from clearing GD_FLG_RECORD. This is useful when testing
the test framework itself, where error messages need to be captured.

Refactor ut_fail() and ut_failf() to call ut_unsilence_console() instead
of duplicating the flag-clearing logic.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:17:14 -07:00
Simon Glass
f4e11a4052 test: Add a private buffer for tests
Add a priv[] buffer to struct unit_test_state that tests can use for
their own data. This avoids the need to allocate memory or use global
variables for test-specific state.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:16:04 -07:00
Simon Glass
a9d6c0322e test: Add type-checked argument accessor functions
Add ut_get_str(), ut_get_int(), and ut_get_bool() functions with
corresponding ut_str(), ut_int(), and ut_bool() macros for accessing
test arguments with type checking.

These functions check that the argument index is within bounds and the
type matches what was requested.

The first failure for a test is reported via ut_failf() which should
make it fairly easy to debug the test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:52 -07:00
Simon Glass
64850634f0 test: Enhance the ut command to pass test arguments
Update the ut command to permit passing arguments to tests.

Usage: ut -f fs test_name key1=value1 key2=value2

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:41 -07:00
Simon Glass
a3b60a2094 test: Add support for passing arguments to C tests
Add support for passing key=value arguments to unit tests. The test
framework parses arguments based on definitions provided by each test
and makes them available via uts->args[]

For now the 'ut' command does not support this new feature.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:14:34 -07:00
Simon Glass
1e4f459e48 test: Add a macro to declare unit tests with arguments
Add a UNIT_TEST_ARGS() macro to declare and register a test with inline
argument definitions. The variadic arguments use struct ut_arg_def and
a NULL terminator is added automatically to the list.

Example usage:
  static int my_test(struct unit_test_state *uts) { ... }
  UNIT_TEST_ARGS(my_test, UTF_CONSOLE, my_suite,
      { "path", UT_ARG_STR },
      { "count", UT_ARG_INT, UT_ARGF_OPTIONAL, { .vint = 10 } });

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:13:26 -07:00
Simon Glass
0b18ce5f83 test: Add argument-type definitions
Add types for declaring and storing unit test arguments:
- enum ut_arg_type: INT, BOOL, STR types
- enum ut_arg_flags: OPTIONAL flag for non-required args
- struct ut_arg_def: declares expected args with defaults
- struct ut_arg: holds parsed argument values

This prepares for passing key=value arguments to tests via the 'ut'
command instead of needing to use environment variables.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:12:56 -07:00
Simon Glass
1fbf894923 test: Add a helper to check the next line against a regex
Add a new ut_assert_nextline_regex() macro and ut_check_console_line_regex()
helper to check console output against a regex pattern. This is useful when
the exact output varies (e.g., file paths or line numbers in error messages).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 09:12:44 -07:00
Simon Glass
6e5c5a0993 test: vbe: Fix the ut-flag order in vbe_test_fixup_norun()
Move the -f flag before the suite name since ut parses flags
before the suite argument.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-14 07:15:34 -07:00
Simon Glass
9ab3308d64 linker_lists: Fix end-marker alignment to prevent padding
Change the alignment of end markers in ll_entry_end() and ll_end_decl()
from __aligned(4) and __aligned(CONFIG_LINKER_LIST_ALIGN) respectively
to __aligned(1).

The linker places zero-size end markers at aligned boundaries based on
what follows them. When the next list's start marker has a high alignment
requirement (e.g., 32 bytes), padding gets inserted before the end marker.
This causes the byte span (end - start) to not be an exact multiple of
the struct size.

The compiler optimizes pointer subtraction (end - start) using magic-number
multiplication for division. This optimization only produces correct results
when the byte span is an exact multiple of the struct size. With padding,
the result is garbage (e.g., -858993444 instead of 15).

By using __aligned(1), the end marker is placed immediately after the last
entry with no padding, ensuring (end - start) equals exactly n * sizeof
where n is the number of entries. This makes ll_entry_count() and direct
pointer arithmetic work correctly.

Fixes: 0b2fa98aa5 ("linker_lists: Fix alignment issue")
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
2812864362 check_linker_lists: Enhance detection of alignment problems
When linker-inserted padding breaks list integrity, pointer arithmetic
like (end - start) / sizeof(struct) produces garbage. GCC optimizes
division by constants using multiplicative inverses, which only works
when the dividend is an exact multiple. With padding, outputs like
"Running -858993444 bloblist tests" appear instead of the correct count.

Enhance the linker list checking script to detect these problems by
adding symbol size tracking using nm -S. This enables:

1. Padding detection: Compare symbol sizes to gaps. If gap > size,
   padding was inserted, breaking contiguous array assumptions.

2. Pointer arithmetic bugs: Check if (end - start) marker span is a
   multiple of struct size.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
2ddc96ae88 vsprintf: Add support for the %pV format-specifier
Add support for the %pV format-specifier which allows printing a
struct va_format. This is used by the Linux kernel for recursive
printf() formatting and is needed by the ext4l filesystem driver.

Add the struct to include/linux/printk.h to match the kernel location.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
d843258d52 doc: Document tiny printf for SPL
Add documentation for the tiny printf implementation used in SPL, TPL,
and VPL when CONFIG_SPL_USE_TINY_PRINTF (or equivalent) is enabled.

Document the supported format specifiers, limitations, and the warning
about snprintf() not performing bounds checking in this implementation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
5c422b5866 doc: Expand printf documentation
Expand the printf format documentation to include information on all
printf-style functions. Mention CONFIG depencies as well.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
dcdee8e656 sandbox: serial: Report output failurs
When characters cannot be sent to the serial port, return an error code
so that the uclass can try again.

This fixes a problem with gnome-terminal which seems to get behind and
then drop output when a large amount of output is produced quickly (e.g.
100K in under a second). Since sandbox often writes to the device one
character at a time it does place a substantial load on the other end of
the PTY. Quite possibly it does not empty the pipe quickly enough and so
writing to the PTY fails.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Simon Glass
11c24c8bba serial: Retry output if it fails
If something goes wrong when writing to the serial device, take notice
of the error code and try again, if needed.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:53 -07:00
Heinrich Schuchardt
5b9d59d3eb configs: raise SPL_SYS_MALLOC_SIZE to 8 MiB on RISC-V
On several RISC-V boards we have seen that 1 MiB is a insufficient value
for CONFIG_SPL_SYS_MALLOC_SIZE.

For instance qemu-riscv32_spl_defconfig fails booting because u-boot.itb
exceeds 1 MiB.

8 MiB is a reasonable value that allows adding FPGA blobs or splash images
to main U-boot.

Reported-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Leo Yu-Chi Liang <ycliang@andestech.com>
(cherry picked from commit 8b410cab51)
Dropped modifications to all files except common/spl/Kconfig:
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-13 16:28:36 -07:00
Simon Glass
fc71a84bb4 Merge branch 'malb2' into 'master'
malloc: Add heap debugging commands and mcheck caller tracking

See merge request u-boot/u-boot!222
2025-12-10 13:55:05 +00:00
Simon Glass
48e4d58cc0 doc: malloc: Document debugging features
Update the malloc() with more info about the debugging features:

- CONFIG_MALLOC_DEBUG and CONFIG_MCHECK_HEAP_PROTECTION Kconfig options
- The malloc command with info and dump subcommands
- Caller backtrace display when mcheck is enabled

Series-to: concept
Series-cc: heinrich
Series-version: 2
Cover-letter:
malloc: Add heap debugging commands and mcheck caller tracking
This series adds improved heap-debugging capabilities.

As part of this, the recently added backtrace feature is reworked to
avoid itself using malloc(), which makes it difficult for malloc() to
use.

A new 'malloc' command with 'info' and 'dump' subcommands allows
inspecting the heap state at runtime.

The mcheck heap-protection feature is integrated into Kconfig and can be
used to to track caller information for each allocation, showing the
function name and line number.

The caller info can be seen with 'malloc dump', including for freed
chunks where possible.

The 'malloc info' command shows a few more heap statistics:

    => malloc info
    total bytes   = 96 MiB
    in use bytes  = 700.9 KiB
    malloc count  = 1234
    free count    = 567
    realloc count = 89

The 'malloc dump' command walks the heap showing each chunk:

    => malloc dump
    Heap dump: 19a0e000 - 1fa10000
         Address        Size  Status
    ----------------------------------
        19a0e000          10  (chunk header)
        19a0e010          a0        log_init:453 <-board_init_r:774 <-sandbox_flow:
        19a0e0b0       20070        membuf_new:420 <-console_record_init:880 <-boar
        19a2e120         170        membuf_new:420 <-console_record_init:886 <-boar
        19a2e290         150        unflatten_device_tree:299 <-of_live_build:328 <
        19a2e3e0          a0        uclass_get:157 <-device_bind_common:59 <-device
        ...
        19a4b080          70  free  done_word:2489 <-parse_stream_outer:3190 <-pars
        ...

This is useful for debugging memory leaks, understanding allocation
patterns, and tracking down heap corruption issues.

Some additional patches are included to make all this work:
- format_size() for human-readable size formatting
- ut_asserteq_regex() for flexible test assertions
- backtrace_str() for condensed backtrace output

Finally, this series includes a few patches for some of the more obvious
memory leaks (scmi and some test drivers), plus a reduction in truetype
memory allocations and a fix for a watchdog crash with 'ut dm'.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:56:16 -07:00
Simon Glass
4739e7a89a malloc: Print mcheck registry-overflow message only once
Use a static bool flag to ensure the overflow warning is printed only
once, avoiding repeated messages when the registry is full.

Make sure to set the flag before calling printf(), which can itself do
allocations with sandbox / Truetype.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00
Simon Glass
9998ff5c87 malloc: Show caller info for freed chunks in malloc_dump
When CONFIG_MCHECK_HEAP_PROTECTION is enabled, show the original
caller info for freed chunks. This helps identify what code allocated
memory that is now free.

The mcheck header's canary and caller fields survive after free since
dlmalloc only overwrites the first 16 bytes (size, aln_skip) with its
free list pointers (fd, bk). We detect freed headers by looking for
the MAGICFREE canary pattern.

For small chunks or coalesced chunks where the header is not preserved,
the caller info is simply omitted.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-10 05:53:03 -07:00