The stb_truetype library performs around 5 allocations per character
rendered, totalling approximately 26KB of temporary memory. This creates
significant malloc/free overhead and heap fragmentation.
Add a scratch buffer mechanism that pre-allocates memory once during
probe and reuses it for each character. The buffer is reset at the start
of each putc_xy() call, and allocations come from this buffer using a
simple bump allocator with 8-byte alignment.
If the scratch buffer is exhausted (e.g. for very complex glyphs), the
allocator falls back to malloc transparently.
The scratch buffer is controlled by two new Kconfig options:
- CONSOLE_TRUETYPE_SCRATCH: Enable/disable the feature (default y)
- CONSOLE_TRUETYPE_SCRATCH_SIZE: Buffer size in bytes (default 32KB)
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add documentation for the ext4l_msgs environment variable which
controls whether the ext4l filesystem driver prints mount messages
when probing an ext4 filesystem.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Running the full test suite takes a long time. It would be useful to
distribute tests across multiple sandbox instances to speed up testing.
Add support for running tests in parallel across multiple sandbox
instances. Each worker runs a subset of tests based on its worker ID.
Add -P<n>:<w> option to the ut command where n is the total number of
workers and w is this worker's ID (0 to n-1). Tests are distributed
by index modulo number of workers.
Series-to: u-boot
Series-cc: heinrich
Cover-letter:
test: Various improvements to unit-test infrastructure
This series adds several improvements to the unit-test infrastructure:
- Move disk images to the persistent-data directory so they don't
pollute the source tree
- Add a way to keep pytest-created artefacts for faster iteration on
C tests
- Add a helper to simplify running manual unit tests from Python
- Allow combined flags with the ut command (e.g. -Efm)
- Add a -E flag to emit machine-readable result lines
- Add a -P flag to distribute tests across parallel workers
- Add -m as an alias for -f (force manual tests)
These changes make it easier to run and debug tests, especially when
iterating on C test code.
END
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add documentation for the return value of the ut command:
- Returns 0 on success if all tests pass
- Returns 1 on failure if any test fails
- Skipped tests do not cause a failure
Also explain when tests may be skipped and how to detect skipped tests
programmatically using the -E flag.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The ut command shows test output but does not provide a machine-readable
indication of whether each individual test passed or failed. External
tools must rely on heuristics like scanning for failure patterns in the
output.
Add a -E flag that emits an explicit result line after each test:
Result: PASS: test_name: file.c
Result: FAIL: test_name: file.c
This allows tools to reliably determine per-test pass/fail status
without fragile pattern matching. The flag is optional to maintain
backward compatibility with existing scripts.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add -m as an alias for the -f flag which forces manual tests to run.
This provides consistency with external test runners that will use -m
for "manual" tests.
Also update the documentation to explain what manual tests are, and fix
a typo ("types" -> "times") in the -r description.
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add the fsinfo command to display filesystem statistics including block
size, total blocks, used blocks, and free blocks. Both raw byte counts
and human-readable sizes are shown.
Example output:
=> fsinfo mmc 0:1
Block size: 4096 bytes
Total blocks: 16384 (67108864 bytes, 64 MiB)
Used blocks: 2065 (8458240 bytes, 8.1 MiB)
Free blocks: 14319 (58650624 bytes, 55.9 MiB)
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The command name was "sbi" instead of "sb" in "doc/usage/cmd/sb.rst",
the file documenting the "sb" command. It is annoying, because the
index in the left panel on the
<https://docs.u-boot.org/en/latest/usage/cmd/sb.html> page shows no
"sb" command, which makes difficult to navigate to the "sb"
documentation.
Fixed the command name: "sbi" -> "sb".
Fixes: ec6d30649c (doc: sandbox: Add docs for the sb command, 2024-10-28)
Signed-off-by: Olivier L'Heureux <olivier.lheureux@mind.be>
Reviewed-by: Simon Glass <sjg@chromium.org>
(cherry picked from commit ea958a0c7d)
The bootmenu command can display
* menu entries defined by environment variables
* menu entries defined by UEFI boot options
Not in all cases showing the UEFI boot options is desired.
Provide a new parameter '-e' to select the display of UEFI boot options.
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
(cherry picked from commit 5a4ac8a35a)
The example in kernel_fdt.rst is inconsistently indented, making it
difficult to read.
Indent the example with the same standard as the other examples:
Four spaces for the ReST code block and for every nesting level.
Signed-off-by: J. Neuschäfer <j.ne@posteo.net>
(cherry picked from commit 12876f8cd8)
The number of bytes may only be specified if a device number id provided.
Correct the formatting.
Acked-by: Marek Behún <kabel@kernel.org>
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
(cherry picked from commit 528b6b817e)
Document environment variables set by the dhcp command when the network
stack is lwIP.
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
(cherry picked from commit d8b0020dde)
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>
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>
When CONFIG_MCHECK_HEAP_PROTECTION is enabled, use backtrace_str() to
capture the caller information for each malloc/calloc/realloc/memalign
call. This information is stored in the mcheck header and can be viewed
with 'malloc dump'.
Add a flag to disable the backtrace when the stack is corrupted, since
the backtrace code tries to walks the invalid stack frames and will
crash.
Note: A few allocations made during libbacktrace initialisation may
not have caller info since they occur during the first backtrace call.
Example output showing caller info:
18a1d010 90 used log_init:453 <-board_init_r:774
18a1d0a0 6060 used membuf_new:420 <-console_record
18a3b840 90 used of_alias_scan:911 <-board_init_
Fix up the backtrace test to avoid recursion.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a new 'malloc dump' command that walks the dlmalloc heap from start
to end, printing each chunk's address, size (in hex), and status
(used/free/top). This is useful for debugging memory allocation issues.
When CONFIG_MCHECK_HEAP_PROTECTION is enabled, the caller string is
also shown if available.
Example output:
Heap dump: 18a1d000 - 1ea1f000
Address Size Status
----------------------------------
18a1d000 10 (chunk header)
18a1d010 90 used
18adfc30 60 <free>
18adff90 5f3f030 top
1ea1f000 end
----------------------------------
Used: c2ef0 bytes in 931 chunks
Free: 5f3f0c0 bytes in 2 chunks + top
Expand the console-record size to handle this command.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add counters to track the number of calls to malloc(), free(), and
realloc(). These are displayed by the 'malloc info' command and
accessible via malloc_get_info().
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a command to display malloc heap statistics, showing total heap
size and memory currently in use.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
The TrueType console driver calls malloc/free for every character
rendered, which causes significant memory fragmentation and allocation
traffic.
Add CONFIG_CONSOLE_TRUETYPE_GLYPH_BUF to enable a pre-allocated buffer
in the driver's private data. The buffer starts at 4KB and grows via
realloc() as needed. When rendering a glyph, use this buffer to avoid
malloc/free for normal characters.
The buffer is allocated lazily after relocation to avoid consuming
early malloc space before the full heap is available.
Add CONFIG_VIDEO_GLYPH_STATS (default y on sandbox) to track the number
of glyphs rendered. Use 'font info' to view the count.
Series-changes: 2
- Rename the Kconfig to just enable the feature: always allocate
Co-developed-by: Claude Opus 4 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add comprehensive documentation for TKey-based full disk encryption:
- doc/usage/tkey-fde.rst: Main documentation covering the TKey FDE
workflow, key derivation process, U-Boot integration, the
tkey-fde-key.py script usage, creating test images, troubleshooting,
and security considerations
- Add cross-references from related documentation pages including
blkmap, bootflow, luks, and tkey command references
- Update luks.rst with a section on hardware-backed key derivation
Series-to: concept
Cover-letter:
luks: Complete TKey implementation
This series finishes off the TKey implementation, including an expo
menu (bootctl), a Python script to automate common operations and some
documentation to pull it all together.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add a -p flag to the luks unlock command that allows passing a
hex-encoded pre-derived master key, skipping the KDF step. This is
useful when the master key has been derived externally, such as from a
hardware security module.
Adjust the normal flow (without -p) to use a key derived on the TKey
output. While that works OK with LUKS1, the 32-byte value is not long
enough to work with LUKS2.
Update the documentation to describe the new flag.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
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>
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>
Add a -t option to the 'luks unlock' command to allow a TKey to be used
to unlock a disk. The password is used as the user-supplied secret (USS)
in this case.
Series-to: concept
Cover-letter:
luks: Integrate support for a TKey
This series illustrates how to use a Tillitis TKey to unlock an
encrypted disk. This has the advantage that the key depends on a
physical key in the user's posession as well as the usual passphrase.
The TKey handles the key derivation, so this series includes logic to
skip that step when a TKey is used.
The 'luks unlock' command provides a -t flag to use a TKey.
It also provides a small pytest fix to ease conflicts with Labgrid
integration.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Series-links: 1:63
Enhance the 'tkey connect' command to allow the device name to be
specified. This will be useful in tests.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Add documentation for the new LUKSv2 feature and update LUKSv1 to
mention the more common algorithm.
Update the tests to use LUKSv2 for mmc12
Series-to: concept
Series-cc: heinrich
Cover-letter:
luks: Provide support for LUKSv2
Modern systems mostly use LUKSv2 as it is more secure that v1. This
series provides an implementation of this feature, making use of the
existing 'luks unlock' command.
One interesting part of this series is a converter from JSON to FDT, so
that U-Boot's existing ofnode interface can be used to access the
hierarchical data in JSON text. This obviously results in quite a bit
of new code, but it is more robust than trying to parse the text
directly using strstr(), etc. The choice of JSON for LUKS was presumably
made with larger code bases in mind, rather than a firmware
implementation.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Series-links: 1:58
This is very long and the 'encrypt' part is implied by the passphrase.
Shorten it to just 'passphrase'.
Signed-off-by: Simon Glass <simon.glass@canonical.com>
Provide a function which can detect a LUKS partition. Add a test, using
mmc11
Series-to: concept
Cover-letter:
luks: Provide basic support for unlocking a LUKS1 partition
With full-disk encryption (FDE) it is traditional to unlock a LUKS
partition within userspace as part of the initial ramdisk passed to
Linux. The user is prompted for a passphrase and then the disk is
unlocked.
This works well but does have some drawbacks:
- firmware has no way of knowing whether the boot will success
- the 'passphrase' prompt comes quite late in the boot, which can be
confusing for the user
- specifically it is not possible to provide an integrated 'boot' UI in
firmware where the user can enter the passphrase
- in a VM environment, the key may be known in advance, but there is no
way to take advantage of this
- it is not possible to use an encryted disk unless also using a ramdisk
This series makes a small step towards improving U-Boot in this area. It
allows a passphrase to be checked against a LUKS1-encrypted partition.
It also provides read-only access to the unencrypted data, so that files
can be read.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Provide a new 'luks unlock' command which can unlock a LUKS1 partition,
given a passphrase.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Extract the full information for version 2, which is JSON format. Show
this with the 'luks info' command.
Use the mmc12 disk to check this.
Require the JSON for LUKS.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a 'luks' command which allows querying a partition to see if it is
encrypted using LUKS, as well as showing information about a LUKS
partition.
Provide some documentation and a test.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
There are quite a few media devices in test.dts which are not enabled by
default, so are not bound on startup. Sometimes it is useful to be able
to use these from the command line.
Add 'sb devon' and 'sb devoff' subcommands to enable and disable devices
from the device tree. For example, running sandbox with -T, then
'sb devon mmc11' enables the mmc11 device mentioned in test.dts
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This command lacks documentation in the normal place. Add it.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new 'tkey' command that provides an interface to interact with
Tillitis TKey security tokens. Subcommands include:
- info: Display device information (UDI, name, version, mode)
- load: Load and run applications on the TKey
- pubkey: Get the public key from a signer app
- getkey: Derive disk encryption keys with password and USS
This command enables U-Boot to use TKey devices for secure key
derivation for full-disk encryption.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new 'cedit dump' command which dumps the contents of an expo for
debugging.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new 'video images' command which lists the graphical images that
are compiled into U-Boot. Generally the only one is the logo.
Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Tidy up embedded graphical images
U-Boot includes a few graphical images which are compiled in, such as
the logo and the BGRT logo used for EFI.
At present these are handled by a Makefile rule which looks for files
ending with '_logo.bmp'.
This series moves these into a new drivers/video/images directory and
puts them in a linker list, so it is possible to see what images are
available.
Adding a new image is simpler, just requiring the addition of the normal
'obj-y += file.bmp' rule.
This series also adds a new 'video' command which provides the existing
'setcurs' and 'lcdputs' as subcommands, along with documentation and
tests.
It also adds a more convenient 'write' subcommand.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 2:44 1:43
Series-version: 3
Add a new 'video' command with 'setcursor' and 'puts' subcommands that
provide an alternative interface to the existing setcurs and lcdputs
commands.
Update the test is updated to test both the legacy commands and the new
'video' command.
Series-changes: 2
- Correct confusing output text which should be 16 instead of 10
- Improve docs for row and col
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add documentation and a simple test for the setcurs and lcdputs
commands.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-changes: 2
- Split out docs into its own patch; use video: tag
Signed-off-by: Simon Glass <sjg@chromium.org>
The command has been updated but the docs was left behind. Fix it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: 7f9e630a9e ("boot: Drop hex prefix from the booti image-mov..")
Rather than always going through this state, require callers to
explicitly request it. This will allow the option to be enabled without
affecting the boot, unless the user expressly requests it.
Signed-off-by: Simon Glass <sjg@chromium.org>
Add support for pressing 'Q' to put the pager into bypass mode,disabling
further paging for the current session.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Complete the support for this feature by dealing with rendering, the
moving to a particular row/column and scrolling.
Provide a simple test to check that things look right.
Allow omitting the font name to request the default font.
Fix an errant tab nearby.
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Add a new 'chid compat' subcommand that finds the compatible string
matching the current hardware's CHID and sets the fdtcompat environment
variable. This examines the devicetree under /chid for nodes with
hardware-id child nodes containing CHID data that matches the system's
generated CHIDs.
The command prints the found compatible string to the console and
automatically sets the fdtcompat environment variable for use by
other U-Boot commands.
Series-to: concept
Cover-letter:
Selection of devicetree using CHIDs
This series implements support for Microsoft's Computer Hardware
Identifier (CHID) specification in U-Boot. CHIDs provide a standardised
way to identify hardware configurations using SMBIOS data, enabling
automatic selection of appropriate device tree overlays and drivers when
the firmware itself lacks support for devicetree.
The CHID system generates UUIDs from various combinations of hardware
information (manufacturer, product name, BIOS version, etc.) creating a
hierarchy from most to least specific. This allows U-Boot to
automatically select the correct devicetree compatible-string for the
hardware on which it running.
This series includes:
* Core CHID Infrastructure:
- UUID v5 generation with Microsoft's CHID namespace
- Support for all 15 CHID variants (HardwareID-00 through HardwareID-14)
- SMBIOS data extraction and processing
* Devicetree Integration:
- hwids_to_dtsi.py script to convert CHID files to devicetree .dtsi
- Automatic inclusion of the .dtsi into the board'' devicetree
- Runtime compatible-string-selection based on hardware CHIDs
* chid command:
- chid show - show current hardware information and generated CHIDs
- chid list - list all supported CHID variants and generated UUIDs
- chid variants - show information about CHID variant restrictions
- chid compat - select the compatible string for current hardware
* ARM/EFI Support:
- CHID mappings for a selection of ARM-based Windows devices
- Support for Qualcomm Snapdragon platforms (MSM8998, SC7180, SC8180X,
SC8280XP, SDM850, X1E series)
* Testing:
- Sandbox tests using mock SMBIOS data
- CI integration for hwids_to_dtsi validation
- Validation against Microsoft's ComputerHardwareIds.exe output
Documentation is provided for this new subsystem and associated
commands.
END
Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:22