UART to replace semihosting#223
Merged
Merged
Conversation
|
|
wmaroneAMD
reviewed
May 12, 2026
Collaborator
wmaroneAMD
left a comment
There was a problem hiding this comment.
Overall looks good, but keeping the stand-alone uart-test-exec.py would be good as it's handy for manual test and debug.
26caccc to
2c37f27
Compare
2c37f27 to
615eef0
Compare
CourtneyDrant
approved these changes
May 12, 2026
Contributor
CourtneyDrant
left a comment
There was a problem hiding this comment.
Satisfies original mission, which was to converge ast1060_evb and qemu targets into a single target. Tests execute on HW targets. Code is well documented and structured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This file is present under target/ast10x0/tests/README.md
AST10x0 Test Infrastructure
Overview
Tests for the AST10x0 target are firmware images that run identically under
QEMU or on a physical board. Pass/fail is signalled by writing a sentinel
string to UART:
The same
system_image_testtarget is used for both execution environments -no separate hardware-only test targets exist.
Running Tests
QEMU (no hardware required)
Physical AST1060 EVB via Raspberry Pi SSH fixture
or inline without modifying the shell environment:
Key-based SSH auth is required (
ssh-copy-id <user>@<pi-host>). The Pi runspi_test_runner.py, which handles GPIO reset sequencing, firmware upload overthe UART bootloader, and sentinel detection. UART output is streamed back to
the host for detokenization and display. Tests no longer use cortex_m_semihosting.
Physical AST1060 EVB wired (not yet implemented)
A wired mode where the host connects to the Pi fixture over a local serial
port rather than SSH - is not yet implemented. The physical connection type
between the host and the Pi has not been defined (e.g. Pi serial console over
UART, USB serial gadget, or USB networking), so the host-side protocol cannot
be specified. Omitting
AST1060_EVB_PI_HOSTshould default to using a wiredconnection, but currently logs an unimplemented error.
Test Results (2026-05-12)
interrupts/kernel:interrupts_testinterrupts/user:interrupts_testipc/user:ipc_testobject_set_peer_user_signal)threads/kernel:threads_testunittest_runner:unittest_runnerusart:usart_test*/no_panics_test(×5)interrupts/kernel:interrupts_test- times out on physical boardThe firmware produces no UART output after upload, indicating a crash before
UART initialisation. The same binary passes in QEMU. The
interrupts/uservariant (which manages IRQ 42 through the kernel IPC abstraction rather than
raw NVIC manipulation) passes on both. Root cause is likely in the
codegen-generated startup code for the
interrupt_tableentry insystem.json5; thesystem.json5itself carries a TODO to verify addressesagainst the AST10x0 hardware datasheet.
unittest_runner:unittest_runnerΓÇö fails on physical boardunittest_runneris arust_test, not asystem_image_test. Therun_undermechanism expects a
system_imageoutput (co-located.elfand.binunderthe same stem). A raw
rust_testbinary staged in a Bazel temp directory hasno
.bincounterpart, sotest_runner.pyexits immediately with an error.This test is only meaningful under QEMU, where
qemu_runner.pycan executethe ELF directly.
How Pass/Fail Signalling Works
Firmware writes the sentinel via
console_backend_write_all, which callsUsart::write_alldirectly, bypassingpw_logand the tokenizer. This meansthe sentinel is always plain ASCII regardless of whether the rest of the log
output is tokenized, and it can be detected without an ELF for detokenization.
QEMU
qemu_runner.pystarts QEMU with a PTY for serial I/O and a named pipe forthe raw byte stream. A sentinel watcher thread scans the raw stream; when a
sentinel is found QEMU is killed and the runner exits 0 or 1. A 30-second
watchdog kills QEMU if no sentinel arrives.
Physical board
pi_test_runner.py(running on the Raspberry Pi) sequences the GPIO resetlines to enter UART bootloader mode, uploads the firmware binary, then streams
raw UART bytes to stdout while scanning for the sentinel. It exits 0 (PASS) or
1 (FAIL/timeout).
test_runner.pyon the host SCP's the script to the Pi,streams the output back for detokenization and display, and reports the Pi's
exit code to Bazel.
Because the Pi is a shared fixture,
test_runner.pyholds an atomic noclobberlock file at
/tmp/ast1060_evb.lockon the Pi for the duration of each test,preventing multiple users from driving the board over SSH simultaneously. The
lock is touched every 10 seconds by a background thread and considered stale
after 60 seconds of inactivity (e.g. after a crash). If the lock cannot be
acquired within 120 seconds the run is aborted.
Semihosting Migration
This infrastructure previously used ARM semihosting to signal pass/fail. On
real hardware with no attached debugger, a semihosting trap causes a HardFault,
so hardware testing was impossible. Replacing semihosting with UART sentinels
removed that constraint and enabled the Pi SSH test fixture.
uart_upload_testTargets (removed)The five
*_uart_upload_testtargets that previously existed in these BUILDfiles have been removed. They used an earlier harness (
uart_upload_test.bzl)that predated the
run_underapproach. Thesystem_image_testtargets coverboth QEMU and hardware execution; no separate hardware-only test rule is needed.
The
uart_upload_test.bzlrule file is retained intarget/ast10x0/harness/for reference.