From 008b9b6d0a3d6c30a8067be07e90bb63f28d1b82 Mon Sep 17 00:00:00 2001 From: Dev10-sys Date: Fri, 20 Nov 2026 14:43:34 +0530 Subject: [PATCH 1/2] Added a workflow that runs the RISC-V64 Erbium example in CI The Erbium board example added in #787 was not referenced by any workflow in .github/workflows, so changes to the shared RISC-V64 port files or the example could break unnoticed. Add .github/workflows/erbium_simulator.yml following the simulator model in r52_fvp.yml. The workflow builds demo_threadx.elf and executes it on the et-platform functional simulator (erbium_emu) at revision 836a4ab, asserting UART initialization and thread scheduling, and runs the regression tests in ports/risc-v64/gnu/example_build/erbium/test/run_simulator_tests.sh. Both the RISC-V64 GNU toolchain and erbium_emu are cached across runs. Verified locally: built erbium_emu, compiled demo_threadx.elf with GCC 15.2.0, executed the demo on the simulator, and confirmed that both test_uart_ticks and test_plic_race pass. Fixes: #788 Signed-off-by: Dev10-sys --- .github/workflows/erbium_simulator.yml | 176 +++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 .github/workflows/erbium_simulator.yml diff --git a/.github/workflows/erbium_simulator.yml b/.github/workflows/erbium_simulator.yml new file mode 100644 index 000000000..7826fe666 --- /dev/null +++ b/.github/workflows/erbium_simulator.yml @@ -0,0 +1,176 @@ +name: erbium_simulator + +# Builds the RISC-V64 Erbium board example and regression tests, and EXECUTES +# them on the et-platform functional simulator (erbium_emu). +# +# Why this exists: until this workflow was added, nothing in CI compiled the +# Erbium port example or executed its tests. The example was added in #787 +# with two simulator regression tests covering bring-up interrupt races, but +# without a workflow referencing it, any changes to the shared RISC-V64 port +# files or the example itself could break silently. +# +# What it covers: +# - demo_threadx: the standard eight-thread ThreadX demo built for the +# Erbium board (RV64IMC, soft-float lp64 ABI, no C library) and run on +# erbium_emu, verifying UART initialization and thread execution; +# - test_uart_ticks: verifies that polling console writes do not lose +# ThreadX hardware timer ticks; +# - test_plic_race: verifies that concurrent PLIC enable-word updates +# between thread and timer ISR context do not lose updates. + +on: + push: + branches: [ master, dev ] + paths: + - ".github/workflows/erbium_simulator.yml" + - "CMakeLists.txt" + - "cmake/riscv64-unknown-elf.cmake" + - "common/**" + - "ports/risc-v64/**" + - "scripts/install_riscv.sh" + - "scripts/tx_ci_common.sh" + pull_request: + branches: [ master, dev ] + paths: + - ".github/workflows/erbium_simulator.yml" + - "CMakeLists.txt" + - "cmake/riscv64-unknown-elf.cmake" + - "common/**" + - "ports/risc-v64/**" + - "scripts/install_riscv.sh" + - "scripts/tx_ci_common.sh" + +permissions: + contents: read + +jobs: + erbium_simulator: + runs-on: ubuntu-24.04 + timeout-minutes: 30 + + env: + # Pinned toolchain release matching scripts/install_riscv.sh. + RISCV_GCC_VERSION: 2026.04.26 + RV64_SHA256: 4a66a329653c9cfb869b826cae6d70c603bedcc1e13d419d3e3e92b99e0816b1 + + # Pinned et-platform simulator revision tested with the Erbium port. + ET_PLATFORM_REV: 836a4ab600e93c3059bb58c898edbc37744cd8d0 + + steps: + - name: Check out the repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + + - name: Cache the RISC-V64 GNU toolchain + id: cache-riscv64 + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: toolchain + key: riscv64-elf-${{ env.RISCV_GCC_VERSION }}-${{ env.RV64_SHA256 }} + + - name: Install the RISC-V64 GNU toolchain + if: steps.cache-riscv64.outputs.cache-hit != 'true' + run: | + set -eu + base="https://github.com/riscv-collab/riscv-gnu-toolchain/releases/download/${RISCV_GCC_VERSION}" + archive="riscv64-elf-ubuntu-24.04-gcc.tar.xz" + mkdir -p toolchain + curl -fsSL --retry 3 -o "toolchain/$archive" "$base/$archive" + echo "${RV64_SHA256} toolchain/$archive" | sha256sum -c - + tar xf "toolchain/$archive" -C toolchain + rm -f "toolchain/$archive" + + - name: Ensure build dependencies are available + run: | + set -eu + . scripts/tx_ci_common.sh + packages="libgoogle-glog-dev liblz4-dev lz4" + command -v ninja >/dev/null 2>&1 || packages="$packages ninja-build" + retry sudo "${TIMEOUT[@]}" apt-get "${APT_OPTIONS[@]}" update || true + # shellcheck disable=SC2086 + retry sudo "${TIMEOUT[@]}" apt-get "${APT_OPTIONS[@]}" install -y --no-install-recommends $packages + + - name: Cache the Erbium simulator + id: cache-simulator + uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 + with: + path: simulator + key: erbium-emu-${{ env.ET_PLATFORM_REV }} + + - name: Build and install the Erbium simulator + if: steps.cache-simulator.outputs.cache-hit != 'true' + run: | + set -eu + mkdir -p et-platform-src + curl -fsSL --retry 3 "https://github.com/aifoundry-org/et-platform/archive/${ET_PLATFORM_REV}.tar.gz" | tar xz -C et-platform-src --strip-components=1 + cd et-platform-src + cmake -S erbium-hal -B build-hal -DCMAKE_INSTALL_PREFIX="$PWD/install" + cmake --build build-hal --target install + cmake -S sw-sysemu -B build-emu -GNinja -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_CXX_FLAGS="-Wno-error=unused-result" \ + -DCMAKE_PREFIX_PATH="$PWD/install" + cmake --build build-emu --target erbium_emu + mkdir -p "$GITHUB_WORKSPACE/simulator/bin" + if [ -f build-emu/bin/erbium_emu ]; then + cp build-emu/bin/erbium_emu "$GITHUB_WORKSPACE/simulator/bin/erbium_emu" + elif [ -f build-emu/erbium_emu ]; then + cp build-emu/erbium_emu "$GITHUB_WORKSPACE/simulator/bin/erbium_emu" + fi + chmod +x "$GITHUB_WORKSPACE/simulator/bin/erbium_emu" + cd "$GITHUB_WORKSPACE" + rm -rf et-platform-src + + - name: Locate the Erbium simulator + id: simulator + run: | + set -eu + binary="$(find simulator -type f -name erbium_emu -perm -u+x | head -1)" + if [ -z "$binary" ]; then + echo "::error::The Erbium simulator build produced no erbium_emu binary." + exit 1 + fi + binary="$(cd "$(dirname "$binary")" && pwd)/$(basename "$binary")" + echo "binary=$binary" >>"$GITHUB_OUTPUT" + "$binary" -help 2>&1 | head -5 || true + + - name: Build and run the Erbium example + run: | + set -eu + export PATH="$GITHUB_WORKSPACE/toolchain/riscv/bin:$GITHUB_WORKSPACE/simulator/bin:$PATH" + riscv64-unknown-elf-gcc --version | head -1 + + emu='${{ steps.simulator.outputs.binary }}' + example_dir="ports/risc-v64/gnu/example_build/erbium" + + echo "Building demo_threadx.elf..." + "$example_dir/build.sh" + + echo "Executing demo_threadx.elf on erbium_emu..." + run_dir="$(mktemp -d)" + trap 'rm -rf "$run_dir"' EXIT + + "$emu" -elf_load "$example_dir/build/demo_threadx.elf" \ + -reset_pc 0x40000200 -minions 1 -single_thread -max_cycles 20000000 \ + -uart_rx_file /dev/null -uart_tx_file "$run_dir/uart.log" > "$run_dir/run.log" 2>&1 || true + + if ! grep -q -F "[UART0] : Erbium UART initialized" "$run_dir/uart.log"; then + echo "::error::demo_threadx did not initialize UART" + cat "$run_dir/uart.log" + exit 1 + fi + + if ! grep -q -F "thread_0_entry is here!" "$run_dir/uart.log"; then + echo "::error::demo_threadx did not schedule threads" + cat "$run_dir/uart.log" + exit 1 + fi + + echo "demo_threadx: PASS" + + - name: Run simulator regression tests + run: | + set -eu + export PATH="$GITHUB_WORKSPACE/toolchain/riscv/bin:$GITHUB_WORKSPACE/simulator/bin:$PATH" + emu='${{ steps.simulator.outputs.binary }}' + example_dir="ports/risc-v64/gnu/example_build/erbium" + + ERBIUM_EMU="$emu" "$example_dir/test/run_simulator_tests.sh" From ae02fc0af8a1c64d4725b32f5370f2ddfbc83392 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Desbiens?= Date: Tue, 1 Dec 2026 13:38:02 -0500 Subject: [PATCH 2/2] Fixed false passes in the Erbium simulator demo check The demo check accepted two startup messages even when the simulator failed after printing them or the guest halted before completing the demo. Require the expected cycle-limit exit and all six thread entry messages. Reject guest traps and print the simulator and UART logs on failure. The demo and both regression tests passed on the pinned Erbium simulator. The check rejected six controlled failure cases. Actionlint passed. Assisted-by: Codex (GPT-6.2-Sol) --- .github/workflows/erbium_simulator.yml | 42 ++++++++++++++++++++------ 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/.github/workflows/erbium_simulator.yml b/.github/workflows/erbium_simulator.yml index 7826fe666..5f4cbf2d5 100644 --- a/.github/workflows/erbium_simulator.yml +++ b/.github/workflows/erbium_simulator.yml @@ -148,22 +148,44 @@ jobs: run_dir="$(mktemp -d)" trap 'rm -rf "$run_dir"' EXIT + fail_demo() { + echo "::error::$1" + echo "Simulator output" + cat "$run_dir/run.log" + if [ -f "$run_dir/uart.log" ]; then + echo "UART output" + cat "$run_dir/uart.log" + else + echo "UART log is missing" + fi + exit 1 + } + + max_cycles=20000000 + status=0 "$emu" -elf_load "$example_dir/build/demo_threadx.elf" \ - -reset_pc 0x40000200 -minions 1 -single_thread -max_cycles 20000000 \ - -uart_rx_file /dev/null -uart_tx_file "$run_dir/uart.log" > "$run_dir/run.log" 2>&1 || true + -reset_pc 0x40000200 -minions 1 -single_thread -max_cycles "$max_cycles" \ + -uart_rx_file /dev/null -uart_tx_file "$run_dir/uart.log" > "$run_dir/run.log" 2>&1 || status=$? - if ! grep -q -F "[UART0] : Erbium UART initialized" "$run_dir/uart.log"; then - echo "::error::demo_threadx did not initialize UART" - cat "$run_dir/uart.log" - exit 1 + # The simulator exits with status 1 when it reaches the cycle limit. + if [ "$status" -ne 1 ] || ! grep -q -F "max cycles reached ($max_cycles)" "$run_dir/run.log"; then + fail_demo "demo_threadx did not report the expected cycle-limit result (simulator status $status)" fi - if ! grep -q -F "thread_0_entry is here!" "$run_dir/uart.log"; then - echo "::error::demo_threadx did not schedule threads" - cat "$run_dir/uart.log" - exit 1 + if [ ! -f "$run_dir/uart.log" ] || ! grep -q -F "[UART0] : Erbium UART initialized" "$run_dir/uart.log"; then + fail_demo "demo_threadx did not initialize UART" fi + if grep -q -E '\[(EXCEPTION|INTERRUPT)\]:.*halting' "$run_dir/uart.log"; then + fail_demo "demo_threadx halted in the guest trap handler" + fi + + for entry in 0 1 2 3_and_4 5 6_and_7; do + if ! grep -q -F "thread_${entry}_entry is here!" "$run_dir/uart.log"; then + fail_demo "demo_threadx did not reach thread_${entry}_entry" + fi + done + echo "demo_threadx: PASS" - name: Run simulator regression tests