1020 Commits

Author SHA1 Message Date
Simon Glass
fccf4f706b test: Rename dm_test_host()
Add a _base suffix to this test so that it is easier to run it by
itself with test.py without also getting dm_test_host_dup()

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2026-01-03 12:39:14 -07:00
Simon Glass
30dd519510 test: nand: Free allocated buffers after test
The run_test_nand() function allocates buf and gold buffers but never
frees them, leaking about 2MB per test run.

Fixes: bc8e8a4bfa ("nand: Add sandbox driver")
Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2026-01-03 12:39:14 -07:00
Simon Glass
0f1d14835b test: Write the SPI image to the persistent-data directory
It is annoying to have disk images in the source directory since it
clutters up the working space.

Move spi.bin (used by the SPI tests) into the persistent-data
directory, update the driver and add a comment.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-29 16:18:51 +00:00
Simon Glass
82be61976f test: dm: Fix delta usage in dm_test_devres_free()
This test passes delta values to ut_check_delta() where it expects
absolute values. ut_check_delta(last) computes (current - last), so
'last' must be an absolute reference point from a previous
ut_check_delta(0) call, not a delta.

The bug causes incorrect memory accounting that happens to work with
smaller allocation overhead but fails when mcheck header size increases.

Use ut_check_delta(0) to capture absolute reference points before each
operation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-09 06:28:04 -07:00
Simon Glass
e0aa4bfae6 test: dm: Fix memory leaks in test drivers
The test_manual_drv driver allocates private data in its probe function
with calloc(), but never frees it in remove(). Add the missing free()
call to test_manual_remove().

Similarly, create_children() allocates platform data with calloc() and
sets it with dev_set_plat(), but doesn't set the DM_FLAG_ALLOC_PDATA
flag. This flag tells the device removal code to free the platform data.
Set this flag so driver model will free the allocated memory on unbind.

These fixes eliminate memory leaks that caused the malloc_dump output
to grow excessively after running DM tests.

Co-developed-by: Claude Opus 4 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-09 05:59:53 -07:00
Simon Glass
b766b80826 video: Add a lock image
Add an image which represents a locked disk.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-07 17:18:57 -07:00
Simon Glass
e4bbfb6d58 tkey: Provide a real tkey device with test.dts
It is sometimes useful to use a real TKey even when running with the
test devicetree. Put it first, so it becomes the default. Update tests
to select the emulator explicitly.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-14 12:00:31 -07:00
Simon Glass
3b61461616 tkey: Use SHA256 to obtain the disk-encryption key
Rather than Blake2b, use SHA256 to obtain the disk-encryption key based
on the key material provided by the TKey. This matches the upcoming
disk-encryption test.

Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-11-14 12:00:31 -07:00
Simon Glass
958e2ecf55 acpi: Add support for Firmware Performance Data Table
Add ACPI FPDT support to report firmware boot timing information to
the OS. The FPDT table contains timing data for firmware phases from
reset through OS handoff.

Add some functions to enable generation of this table.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 10:00:31 +01:00
Simon Glass
c34b52c8a1 tkey: Add emulator and test
Provide a simple emulator which can handle the TKey operations. Add a
test which uses it.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-19 12:27:49 +01:00
Simon Glass
b54d2ae5b9 bootctl: Bring in some additional images
Provide some sample images for use with the 'multi' theme.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:25 +01:00
Simon Glass
915268c0a3 video: Report failure to write a frame to a file
Rather than just printing a message (which is suppressed unless -v is
used) fail the test if it is not possible to write to the provided
directory.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-13 14:20:24 +01:00
Simon Glass
dd4b6ad746 test: video: Fix 16bpp BMP pixel format conversion
The video_write_bmp() function was writing 16bpp framebuffer data
directly to BMP files without proper format conversion. The framebuffer
uses RGB565 format (5 red, 6 green, 5 blue), but standard Windows BMP
16bpp format uses RGB555 (5 red, 5 green, 5 blue).

Convert pixels from RGB565 to RGB555 by:
- Extracting the 5-bit red, 6-bit green, and 5-bit blue components
- Dropping the LSB of the green channel to convert from 6 to 5 bits
- Reconstructing as RGB555 with the same R/B order

This fixes incorrect colors in BMP output files (e.g., orange appearing
as blue).

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-09 17:14:48 +01:00
Simon Glass
03c65c2b94 mouse: Replace press_state with bool pressed
Change the mouse_button structure to use a bool pressed field instead
of an unsigned char press_state. This simplifies the API by using a
natural boolean type for a binary state.

Remove the BUTTON_PRESSED/BUTTON_RELEASED defines as they're no longer
needed.

Update all mouse drivers, tests, and the mouse command to use the new
field name and type.

Series-changes: 2
- Add new patch to replace press_state with bool pressed

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 09:54:43 -06:00
Simon Glass
8751de0715 sandbox: mouse: Add test for pointer visibility
Add a test for the mouse set_ptr_visible() method. This uses a back-door
function to read the visibility state from the sandbox mouse driver.

Also add documentation for struct sandbox_mouse_priv.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-07 10:54:13 +00:00
Simon Glass
00692afa1c mouse: Update mouse_get_click() to use struct vid_pos
Change the API to use struct vid_pos instead of separate x/y pointers.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-03 06:41:11 -06:00
Simon Glass
4a7ccfee27 video: sandbox: Add test for sync() damage rectangle
Add a test that verifies the sandbox SDL driver receives the correct
damage rectangle in its sync() method. The test:

- Clears the display and verifies full-screen damage is passed to sync()
- Writes text at a specific position and verifies smaller damage region
- Draws a box and verifies the damage matches the box dimensions

The damage rectangle is recorded in sandbox_sdl_plat.last_sync_damage
and can be retrieved using sandbox_sdl_get_sync_damage() for testing
purposes.

Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Enhancements to support a pointer
The video subsystem has a video_sync() function which does quite a few
things and is rather hard to predict and control:

- it may or may not actually sync, depending on a timer, etc
- it may be called when U-Boot is idle, so any time delays can cause a
  sync

These two problems make it hard to test.

This series introduces a deterministic video_manual_sync() which does
exactly what it is told, using a set of flags:

   VIDSYNC_FORCE - the force flag was provided (info for the driver)
   VIDSYNC_FLUSH - framebuffer changes should be flushed to hardware
   VIDSYNC_COPY - the copy framebuffer (if any) should be updated

The video_sync() method is renamed to sync() and is passed the flags,
so that drivers can find out what to do. This allows the
sandbox-specific code in video_sync() to move to the driver.

These features will (later) be used by expo to provide a better user
experience, e.g. to sync only part of the display, or to sync quickly
when there is mouse movement.

The pointer also needs to be drawn with transparency which is not well
supported by the BMP code. This series adds support for a simple
transparency colour for now, although an alpha channel may be
appropriate in the future.
END

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Series-links: 1:45
Series-version: 2
2025-10-06 06:29:29 -06:00
Simon Glass
69b02023ad video: Refactor video_sync() to use video_manual_sync()
Extract the core sync logic from video_sync() into a new
video_manual_sync() function that accepts flags directly. This allows
callers to perform sync operations with explicit control over the sync
behavior.

The video_sync() function now:
- Determines the appropriate flags (VIDSYNC_FORCE, VIDSYNC_FLUSH,
  VIDSYNC_COPY) based on the force parameter and timing
- Calls video_manual_sync() with those flags

The video_manual_sync() function:
- Takes explicit flags as a parameter
- Handles VIDSYNC_COPY flag to control copy framebuffer flush
- Performs the actual sync operations

This separation allows manual-sync mode users (and tests) to call
video_manual_sync() directly with custom flags while video_sync()
continues to work as before for normal scenarios.

Add tests for video_manual_sync() to check the behaviour with
different flag combinations.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
f277931d19 video: Provide a way for expo to control video sync
When expo is being used, it should only redraw the display when it has
made changes. Add a new 'manual sync' mode which tells the video
subsystem to ignore video syncs from other sources.

This also disables the idle feature, since it can interfere with tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
01b88f5819 video: Add a struct vid_bbox for damage tracking
Replace the anonymous struct in video_priv with struct vid_bbox for
the damage field.

Update all references from xstart/ystart/xend/yend to x0/y0/x1/y1 to
match the video_bbox field names. Add local video_bbox pointers in
functions that access damage fields repeatedly to improve readability.

Series-changes: 2
- Call it vid_bbox instead as it is shorter and less video-centric

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
55d408d4d9 video: Export a function to draw a BMP with transparency
Provide a new BMP function which can draw a bitmap while regarding a
chosen colour as transparent.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
ac08c90df1 video: Check drawing the mouse pointer
Add some simple tests for drawing the mouse pointer on a white and black
background.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
fe15b7cb6f video: Add a pointer image
When the mouse is being used we need a suitable pointer image to draw on
the display. Add the RISC OS pointer, in honour of the first GUI
available on ARM devices.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
6853b7d8ad sandbox: Add --video_frames option to capture test frames
Add a new --video_frames option to sandbox which accepts a directory path.
When set, every video test assertion writes a BMP file (frame0.bmp,
frame1.bmp, etc.) to the specified directory, allowing visual inspection
of the framebuffer at each test step.

A new video_write_bmp() function writes 16/32bpp framebuffer contents as
Windows BMP files. On startup, any existing frame*.bmp files in the
directory are removed to ensure a clean state.

Usage example:

  ./u-boot --video_frames /tmp/frames -c "ut dm video_text"

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
12572f5a00 sandbox: Add -V flag for video test delay
Add a new -V flag to sandbox which accepts a delay in milliseconds. This
causes video tests to pause after each assertion, allowing the display
output to be visually inspected.

This is useful for debugging video tests and understanding what is being
drawn at each step.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-06 06:29:29 -06:00
Simon Glass
366ae61115 video: Provide a command to list built-in images
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
2025-10-02 13:51:03 -06:00
Simon Glass
85e1dae80c video: Add a write subcommand
This allows writing strings at particular positions on the display,
using either character or pixel positions.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-10-02 13:50:32 -06:00
Simon Glass
8db8f801ae video: Add video command with subcommands
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>
2025-10-02 13:50:32 -06:00
Simon Glass
a85820f86c video: Add tests for the video commands
Add a simple test for the setcurs and lcdputs commands.

Series-changes: 2
- Pull out the docs into a separate patch
- Update test result for hex

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-02 13:50:32 -06:00
Simon Glass
4e38954a41 test: Drop an unwanted blank line in dm_test_video_box()
This test has a blank line which separates one part of the test from
another. Drop it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-24 18:29:40 -06:00
Simon Glass
1fd04ae30a console: Add some cursor tests
Add a few tests of cursor operation.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>

Series-to: concept
Series-cc: heinrich
Cover-letter:
video: Support a cursor more generally
At present U-Boot does not support displaying a cursor on the console,
except with expo.

It is quite useful to have a cursor, particularly when using the
command-line editor.

This series adds tracking of the cursor position for both truetype and
normal consoles. The cursor is shown when U-Boot is idle and is removed
before writing characters to the display. A save-buffer ensures that the
old display contents are provided.

Some related improvements in this series include:
- expo lineedit support with normal console
- arrow keys now render correctly when editing commands with truetype
- truetype console now also supports bitmap fonts

The cursor is not currently supported for rotated consoles.

A README for claude is provided, although so far I have not had too much
success with it.

A fix for an intermittent build is added as well, along with silencing
some build messages noticed from Rust ulib.
END
2025-09-19 13:21:02 -06:00
Simon Glass
81675eff4a video: truetype: Clear after the current char on insert
Within the CLI, inserting a character works by writing out the new char
and then all the ones after it.

With the truetype console this results in gibberish since the new
chars are written on top of the old. To resolve this, clear the rest of
the input when a character is inserted. Consider that the end of the
input, at least until furture characters are written.

As an optimisation, don't clear if the new character is the same as the
old.

This cleans up a dot above the 'g' of greatness which should not be
there, so update the dm_test_video_truetype() test.

It also clean up the part of the 't' of 'not be' which should not be
there, so update dm_test_video_truetype_bs() too.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 12:56:02 -06:00
Simon Glass
cca7523800 video: truetype: Handle rendering of bitmap fonts
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>
2025-09-19 12:56:01 -06:00
Simon Glass
1ecfbbcbad test: video: Split long strings
Some strings in this file are quite long and it is a pain to look at
them within an 80-column editor. Split them.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-19 11:42:51 -06:00
Simon Glass
50596a9986 test: video: Provide an easy way to watch video tests
The video tests run past too quickly to see what is going on. Update
them to introduce a delay after each check of the screen contents, when
LOG_DEBUG is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
9fa8a01d50 video: Support drawing filled boxes
At present only an outline boxes is supported, albeit with a thickness
parameter. Provide a way to draw a filled rectangle.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 13:23:12 -06:00
Simon Glass
5d4d719064 mouse: Provide a way to read clicks
A mouse click is defined as pressing the mouse and then releasing it
over a given spot. Add a function the tracks the mouse state and
returns the most recent mouse click, if any.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 03:26:58 -06:00
Simon Glass
899722153f sandbox: Provide a test for the mouse uclass
Provide a few simple tests for two methods available in the mouse
uclass.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-15 03:26:35 -06:00
Simon Glass
1c0ee7d1b2 sandbox: Move PCI functions to separate header file
Move pci_map_physmem(), pci_unmap_physmem(), and
sandbox_set_enable_pci_map() from u-boot-sandbox.h to a new file
sandbox_pci.h to simplify dependencies.

Fix the header order in the PCI emul file while we are here.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 14:23:55 -06:00
Simon Glass
96adc477be sysreset: Add SYSRESET_TO_FIRMWARE_UI with reset -u support
Add new SYSRESET_TO_FIRMWARE_UI reset type to allow resetting directly
to firmware UI. This is implemented via the reset command's new -u flag.

For the EFI app, this sets the EFI_OS_INDICATIONS_BOOT_TO_FW_UI bit in
the OsIndications variable before performing a warm reset, causing the
firmware to boot to its setup interface.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 08:51:26 -06:00
Simon Glass
9fdab58b86 sysreset: Support a hot reset
In some cases we may wish to return back to the program which started
U-Boot. Add the concept of a 'hot' reset, to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-02 08:51:25 -06:00
Simon Glass
5ef5e6a8cc test: pci: Use the exact mapping size for PCI EA tests
Update the sizes to the expected size of the device's mapping in each
case, to avoid a warning in map_physmem() about a partial map.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-17 14:37:22 -06:00
Simon Glass
71187d2e3a test: Correct acpi test version numbers
Since the version of U-Boot changes all the time, we cannot make the
test check for the exact value. Just check part of it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-04 06:50:38 -06:00
Simon Glass
878f27e552 fs: Use an empty string for the root directory
It is easier to use an empty string when the root directory is intended.
Adjust the code to drop use of "/" and NULL and just use and empty
string.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-12 14:29:06 +02:00
Simon Glass
3be860fe74 acpi: Support a boot logo (BGRT)
Add support for creating a BGRT so that Linux will show a logo on
startup and shutdown.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
3354f95e7e acpi: Provide a way to locate the end of the ACPI tables
For QEMU we want to add new tables to the end of what QEMU provides. Add
a function to find the correct place for a new table.

Add a function to support this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
34203312d0 acpi: Allow finding the RSDT or XSDT
At present acpi_find_table() support locating most of the tables, but
not these two, since they are the pointers to the rest.

When adding new tables, these tables need to be located and updated, so
update acpi_find_table() to allow searching for them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
84dfe7f251 acpi Adjust dm_test_acpi_find_table() to use a fixed buffer
Most sandbox tests use a fixed address in emulated RAM so that it is
easier to debug test failures. Update dm_test_acpi_find_table() to work
this way.
2025-07-11 21:12:11 +02:00
Simon Glass
9d4aa656de acpi: Update acpi_find_table() to verify checksums
The RSP is not valid unless the checksums are corrrect, so add a test
for this.

Add a few blank lines for readability while here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-11 21:12:11 +02:00
Simon Glass
0733605bb1 virtio: Acknowledge devices only when probed
At present virtio devices are acknowleged when bound. This results in a
call to virtio_set_status() which uses device-private data in several
cases, e.g. in virtio_pci_get_status()

This data is only allocated when the device is probed, so the access is
either ignored (on QEMU) or results in a crash (on sandbox).

Acknowledging the device so early does not seem to be necessary. Move it
to the pre-probe function instead. Update the test to match. We now have
no coverage to check that VIRTIO_CONFIG_S_ACKNOWLEDGE was actually set.

If we later find it necessary to acknowledge the device while binding,
we can update the uclass and drivers to use plat data instead of priv.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-30 08:34:03 -06:00