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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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
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>
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>
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>
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>
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>
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>
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 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>
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
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>