216 Commits

Author SHA1 Message Date
Simon Glass
7856369dc2 cmd: malloc: Add a command to show the malloc log
Add a command interface for the malloc-traffic log:
- malloc log start: Start recording allocations
- malloc log stop: Stop recording
- malloc log: Dump the recorded entries

Example output:

  => malloc log
  Malloc log: 29 entries (max 524288, total 29)
   Seq  Type                   Ptr      Size  Caller
  ----  --------  ----------------  --------  ------
     0  free              16a016e0         0  free_pipe_list:2001
                <-parse_stream_outer:3208 <-parse_file_outer:3300
     1  alloc             16a01b90        20  hush_file_init:3277
                <-parse_file_outer:3295 <-run_pipe_real:1986

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2026-01-03 12:41:32 -07:00
Ilias Apalodimas
8692e10965 lmb: Rename free_mem to available_mem
free_mem is a misnomer. We never update it with the free memory for
LMB. Instead, it describes all available memory and is checked against
used_mem to decide whether an area is free or not.

So let's rename this field to better match its usage.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 400c34db89)
2025-12-24 05:17:04 -07:00
Ilias Apalodimas
65a9881993 lmb: Move enum lmb_flags to a u32
LMB flags is not an enum anymore. It's currently used as a bitmask
in various places of our code. So make it a u32 which is more
appropriate when dealing with masks.

Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Tested-by: Sam Protsenko <semen.protsenko@linaro.org>
Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
(cherry picked from commit 3d56c06551)
2025-12-24 05:17:04 -07:00
Jerome Forissier
8647480ac9 test/cmd/wget.c: move net_test_wget() to the cmd test suite
Since net_test_wget() is testing a command and is in test/cmd it should
be in the 'cmd' test suite, not 'lib'.

Saving and restoring the values of the environment variables that the
test manipulates is necessary to avoid a regression when running the
whole ut test suite. A minimal reproducer is:

 $ ./u-boot -T -c "ut cmd net_test_wget; ut dm dm_test_eth_act" | \
     grep -E "(Test:|Failures:)"

Reported-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
(cherry picked from commit 20f641987f)
2025-12-16 11:12:15 -07:00
Simon Glass
ee8e9bf104 malloc: Add malloc dump command to walk the heap
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>
2025-12-10 05:53:03 -07:00
Simon Glass
d8b19014d7 malloc: Add call counters for malloc, free, realloc
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>
2025-12-10 05:53:03 -07:00
Simon Glass
cfbee94582 malloc: Add 'malloc' command with 'info' subcommand
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>
2025-12-10 05:53:03 -07:00
Simon Glass
69d2f4ab58 video: truetype: Use pre-allocated buffer for glyph rendering
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>
2025-12-10 05:53:00 -07:00
Simon Glass
cee822e941 backtrace: Strip the source tree prefix from filenames
Display relative paths instead of absolute paths in backtrace output,
making the output cleaner and more portable across different build
environments.

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

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

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

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

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

Add docs and a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
2025-12-01 15:42:04 +00:00
Simon Glass
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
71cea84cc3 sandbox: Add devon and devoff subcommands to sb command
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>
2025-10-24 08:47:38 +01:00
Simon Glass
5094bffc50 bootstage: Add some more tests
There is already a Python test. Add a few C tests as well, for bootstage
itself and for the 'bootstage' command.

Add helpers to access the internal state. Be careful to zero records
when removing them, since if the record is later reused, bootstage
expects the time to be zero.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-23 10:00:06 +01:00
Simon Glass
b7d758612a tkey: Add a command
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>
2025-10-19 12:27:49 +01:00
Simon Glass
b77155a47b sandbox: Enable Ubuntu fonts
Bring the Ubuntu fonts into the build.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-10-18 09:38:25 +01:00
Simon Glass
6d58e9f8b6 doc: test: Add docs and test for addr_find
Add documentation and a test for this command.

Drop the use of config.h while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:47:09 -06:00
Simon Glass
6e79f1f503 doc: test: Add docs and test for part_find
Add some documentation and a test for this new command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-25 09:47:09 -06:00
Simon Glass
d7c51083a6 bdinfo: Show the flags
The flags contain lots of little pieces of information. Print them out
with the bdinfo command, so the user can look them up if needed.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-24 18:29:38 -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
1fe8824fb9 video: Allow selection of bitmap fonts in truetype
It is sometimes useful to use a bitmap font for the console even when
truetype fonts are available. As a starting point, pull in the
font table and provide information about font sizes. Allow selection of
a bitmap font by name, as well as listing available bitmap fonts.

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
817fd8201f cmd: chid: Add 'compat' subcommand to find compatible string
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
2025-09-04 07:08:25 -06:00
Simon Glass
7737e3c1d5 chid: Add subcommand for dealing with variants
Add a 'chid list' command to display the values for all CHID variants.
Also add 'chid detail' to see all details about a variant.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:25 -06:00
Simon Glass
93f35ef78a chid: Provide a command to access chid features
Provide a simple command which supports showing the information which
goes into calculating a CHID. The information is obtained entirely from
SMBIOS tables at present.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
8ee598e20c test: Add more SMBIOS data to sandbox
Some common smbios settings are not included with sandbox. Add these to
test.dts so the data is more meaningful.

Update smbios tests to match the new devicetree values.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
b6d164bceb smbios: Provide a sandbox test
Create a sandbox test for the smbios command. This checks that the
expected output is produced.

Drop the unnecessary 0x before each address, since U-Boot uses hex by
default.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
0dc72120b7 fdt: Add a command to show reserved-memory regions
Add a new 'fdt reserved' subcommand that displays all reserved memory
regions defined in the device tree's /reserved-memory node. This command
provides a formatted table showing the ID, name, start address, and size
of each reserved memory region.

Avoid a conflict with the existing 'fdt resize' command. Update the docs
and add a test.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-28 06:55:49 -06:00
Simon Glass
dd6f8cfbcb lib: Split fdt_print() into separate library file
Move fdt_print() function from cmd/fdt.c to a new lib/fdt_print.c file
to make it available as a library function for other code to use.

Move and rename is_printable_string(), making it available as well.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-27 12:44:42 -06:00
Simon Glass
4412d9c3cf bdinfo: Show the pager page_len value
Show the actual value being used by the pager, if enabled.

Series-changes: 2
- Add new patch to show the pager page_len value

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-26 14:36:07 -06:00
Simon Glass
82732edd5a bdinfo: Show the serial device
Show the name of the serial device with the 'bdinfo' command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-25 06:54:00 -06:00
Simon Glass
f6acb6e003 meminfo: Allow for up to 10 hex digits
On platforms where most of the memory is above 4GB, the EFI app may find
itself using addresses with 9 or even 10 digits. Expand the width of the
columns to cope with this.

Add some double bars across digits 9 and 8 so that it is easier to make
the value.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-19 17:36:44 -06:00
Simon Glass
2fdacb4753 qfw: Add a subcommand to decode the QEMU E820 data
Provide a simple command to display the memory map described by this
table.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
d75533b613 qfw: Add a subcommand to read a QEMU file into memory
Provide a simple command to read a named file into memory.

Skip this test on sandbox for now, as it doesn't support this feature in
its emulation of QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
1541ec049b qfw: Add a subcommand to show QEMU arch-specific details
There are a few selectors in a different region which contain what seems
to be arch-specific information. Add a way to display this. So far it
only works on x86.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
6d80f5476b qfw: Add a subcommand to show ACPI-loader details
QEMU provides a table containing the ACPI tables and information on how
to relocate them to any suitable memory address. Add a command to show
this information.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:25 +02:00
Simon Glass
af7eb623d0 qfw: Add a subcommand to show the main QEMU details
There are quite a few values provided by QEMU and used by U-Boot, for
which it isn't possible to see the values. Add a new 'qfw dump' command
to support this.

Skip this test on sandbox for now, as it doesn't support this feature in
its emulation of QEMU.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:33:24 +02:00
Simon Glass
9d9f440c7a qfw: Add more fields and a heading to qfw list
Update the command to show the size and selected file, since this is
useful information at times. Add a heading so it is clear what each
field refers to.

Add a simple test as well.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:26:02 +02:00
Simon Glass
32863b34a4 x86: Update msr test to run on qemu-x86_64
This test is not currently enabled. Update it so that it can be enabled
on the qemu-x86_64 target.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:25:25 +02:00
Simon Glass
2d2057f4d5 test: fdt: Make fdt-overlay test depend on overlays
This test requires FDT-overlay support so skip it if this is not
present.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
7363d1517d test: Disable truetype and meminfo tests on QEMU
These tests are designed to work on sandbox only. The truetype font
changes the current font, which QEMU targets may not support. The
meminfo test assumes a particular memory size.

Mark them as sandbox-only.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
Simon Glass
8170ab591f x86: bdinfo: Update test for output of tsc
The bdinfo command on x86 now outputs the TSC value, do update the tests
to account for this.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-07-09 23:11:33 +02:00
George Chan
139bca49c5 fdt: fdt chosen cmd had off-by-one issue
The kernel searching bootconfig will be off-by-1 and never match
thus always not found in this case.

Signed-off-by: George Chan <gchan9527@gmail.com>
Use 'fdt' as the tag and update fdt_test_chosen:
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-06-10 14:08:51 -06:00
Jerome Forissier
2f15386574 test: run some test commands only if HUSH_PARSER is enabled
Some test commands (such as "false", or the empty string) need
CONFIG_HUSH_PARSER=y. Fix test/cmd/command.c.

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-05-29 16:07:51 +01:00
Mikhail Kshevetskiy
0ecac9c9fb test/cmd/wget: replace bogus response with an actual response from the HTTP server
According to HTTP/1.0 standard the HTTP reply consist of
 * Status Line + CRLF
 * Zero or more Response Header Fields (each ended with CRLF)
 * CRLF on new line (Response Header Fields end marker)
 * Optional Entity Body.

Thus in response headers we state:
  Content-Length = 30
but actual transferred file data is:
  "\r\n<html><body>Hi</body></html>\r\n".
This is 32 bytes of data.

So we get and check for correctness 32 bytes of data, but
 * The response we are used is incorrect, real server will
   set Content-Length to 32.
 * default_wget_info->hdr_cont_len will be set to wrong
   value 30 (used for efi http booting).

Fix an issue by:
 * replace bogus response with an actual response from the HTTP server
 * format response to show HTTP response structure
 * recalculate md5sum as transferred file data has been changed.

The server response was captured with the commands

  echo -ne "<html><body>Hi</body></html>\n" > ~/public_html/test.html
  echo -ne "GET /~${USER}/test.html HTTP/1.0\r\n\r\n" | netcat localhost 80 >reply.txt

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
2025-05-16 17:58:51 +02:00
Mikhail Kshevetskiy
6c785ecae5 test/cmd/wget: fix the test
Changes:
 * update to new tcp stack
 * fix zero values for ISS and IRS issue (see RFC 9293)

Signed-off-by: Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>
Reviewed-by: Simon Glass <sjg@chromium.org>
2025-05-16 17:58:51 +02:00
Heinrich Schuchardt
0748f66cad cmd/setexpr: support concatenation of direct strings
The setexpr.s command allows to concatenate two strings.

According to the description in doc/usage/cmd/setexpr.rst the parameters
value1 and value2 can be either direct values or pointers to a
memory location holding the values.

Unfortunately `setexpr.s <value1> + <value2>` fails if any of the values
is a direct value. $? is set to false.

* Add support for direct values in setexpr.s.
* Correct the unit test for "setexpr.s fred 0".
* Add a new unit test for "setexpr.s fred '1' + '3'" giving '13'.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16 14:45:25 +02:00
Heinrich Schuchardt
d01eb288cb test: remove available memory check in setexpr_test_str_oper()
env_set() frees the previous value after allocating the new value.
As the free() may merge memory chunks the available memory is not
expected to stay constant.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16 14:45:25 +02:00
Heinrich Schuchardt
5c40dffe12 test: remove available memory check in setexpr_test_str()
env_set() frees the previous value after allocating the new value.
As the free() may merge memory chunks the available memory is not
expected to stay constant.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16 14:45:25 +02:00
Heinrich Schuchardt
8f4f9e11dc test: clean up setexpr_test_str()
Assign variable buf in the sub-test where it is used.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2025-05-16 14:45:25 +02:00
Tom Rini
2825b387b0 Kbuild: Always use $(PHASE_)
It is confusing to have both "$(PHASE_)" and "$(XPL_)" be used in our
Makefiles as part of the macros to determine when to do something in our
Makefiles based on what phase of the build we are in. For consistency,
bring this down to a single macro and use "$(PHASE_)" only.

Signed-off-by: Tom Rini <trini@konsulko.com>
2025-05-01 05:56:48 -06:00