Skip to content

Commit 01b896d

Browse files
CopilotJohnAmadis
andcommitted
Add explicit stm32f746g-disco Renode CI test with better diagnostics and timeouts
- Rename test-renode → test-renode-stm32f746g-disco in build.yml so the board under test is unambiguous; add artifact upload of Renode logs on failure for post-mortem debugging - Increase CONNECT_TIMEOUT 90→120s and MONITOR_TIMEOUT 30→60s in run_renode_tests.sh to allow enough time for the full driver init sequence (dmdevfs loading dmgpio) to complete - Add trap cleanup EXIT to kill background Renode/monitor-gdb processes - Print connect.log tail on every run for easier CI diagnostics - Add "Heap initialized" as a second required pattern in expected_logs.txt (printed early in main(), before mount_embedded_filesystems()); if the firmware crashes during driver init, neither message will appear and the test fails — this is exactly the crash path from the issue - Update expected_logs.txt comment block to document the test rationale Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
1 parent a188510 commit 01b896d

3 files changed

Lines changed: 58 additions & 14 deletions

File tree

.github/workflows/build.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ jobs:
139139
build/dmboot.map
140140
retention-days: 30
141141

142-
test-renode:
143-
name: Test Renode Simulation
142+
test-renode-stm32f746g-disco:
143+
name: Renode emulation test (stm32f746g-disco)
144144
runs-on: ubuntu-latest
145145
container:
146146
image: chocotechnologies/dmboot:1.0.0
@@ -165,14 +165,24 @@ jobs:
165165
git submodule init
166166
git submodule update --recursive
167167
168-
- name: Run Renode emulation tests
168+
- name: Run Renode emulation tests (stm32f746g-disco board)
169169
run: |
170170
./scripts/run_renode_tests.sh
171+
172+
- name: Upload Renode logs on failure
173+
if: failure()
174+
uses: actions/upload-artifact@v4
175+
with:
176+
name: renode-logs-stm32f746g-disco
177+
path: |
178+
build/connect.log
179+
build/monitor.log
180+
retention-days: 7
171181

172182
build-all:
173183
name: All builds completed
174184
runs-on: ubuntu-latest
175-
needs: [build-cmake, test-renode]
185+
needs: [build-cmake, test-renode-stm32f746g-disco]
176186

177187
permissions:
178188
contents: read

configs/renode/expected_logs.txt

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Expected log messages from DMOD-Boot firmware running in Renode
2-
# Each line is a pattern that must appear in the monitor-gdb output
3-
# Lines starting with # are comments and empty lines are ignored
2+
# on the stm32f746g-disco board configuration.
3+
#
4+
# This test catches the hard-fault that occurred when .dmod.inputs was not
5+
# correctly copied to RAM during startup. A corrupt .dmod.inputs caused
6+
# Dmod_ConnectApi to write garbage function pointers into loaded modules'
7+
# .dmod.outputs sections, leading to an immediate hard-fault whenever a
8+
# loaded driver (e.g. dmgpio via dmdevfs) tried to log a message.
9+
#
10+
# All lines below must appear in the monitor-gdb output. If the firmware
11+
# crashes before completing initialization, none of the later lines will
12+
# appear and the test will fail.
13+
#
14+
# Each line is a literal substring to match in the log (grep -q).
15+
# Lines starting with # and empty lines are ignored.
416

5-
DMOD-Boot started
17+
Heap initialized
18+
DMOD-Boot started

scripts/run_renode_tests.sh

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
#!/bin/bash
22
# run_renode_tests.sh - Run Renode emulation tests for dmod-boot
33
#
4-
# This script reproduces the Renode CI tests locally.
5-
# It builds the firmware with emulation mode, starts Renode, runs monitor-gdb
6-
# to capture firmware logs, and verifies the expected log messages.
4+
# This script builds the stm32f746g-disco firmware with Renode emulation mode,
5+
# starts Renode, runs monitor-gdb to capture firmware logs, and verifies that
6+
# the expected log messages appear. In particular it catches the hard-fault
7+
# that occurs when .dmod.inputs is not correctly copied to RAM at startup
8+
# (which prevents Dmod_EnterCritical and other output function pointers from
9+
# being connected when modules are loaded at runtime).
710
#
811
# Usage:
912
# ./scripts/run_renode_tests.sh [SOURCE_DIR [BUILD_DIR]]
@@ -24,21 +27,33 @@ EXPECTED_LOGS="$SOURCE_DIR/configs/renode/expected_logs.txt"
2427
VERIFY_SCRIPT="$SOURCE_DIR/scripts/verify_renode_logs.sh"
2528

2629
# Timeouts (seconds)
27-
CONNECT_TIMEOUT=90
28-
MONITOR_TIMEOUT=30
30+
CONNECT_TIMEOUT=120
31+
MONITOR_TIMEOUT=60
2932

3033
echo "=============================================="
3134
echo " dmod-boot Renode emulation tests"
35+
echo " Board: $BOARD"
3236
echo "=============================================="
3337
echo "Source dir : $SOURCE_DIR"
3438
echo "Build dir : $BUILD_DIR"
3539
echo "Board : $BOARD"
3640
echo ""
3741

42+
# Cleanup helper – kill any lingering background processes on exit
43+
cleanup() {
44+
if [ -n "$CONNECT_PID" ] && ps -p "$CONNECT_PID" > /dev/null 2>&1; then
45+
kill "$CONNECT_PID" 2>/dev/null || true
46+
fi
47+
if [ -n "$MONITOR_PID" ] && ps -p "$MONITOR_PID" > /dev/null 2>&1; then
48+
kill "$MONITOR_PID" 2>/dev/null || true
49+
fi
50+
}
51+
trap cleanup EXIT
52+
3853
# -------------------------------------------------------
3954
# Step 1 – Build firmware with emulation mode enabled
4055
# -------------------------------------------------------
41-
echo "[1/4] Building firmware with emulation mode enabled..."
56+
echo "[1/4] Building firmware (BOARD=$BOARD, DMBOOT_EMULATION=ON)..."
4257
cmake -DCMAKE_BUILD_TYPE=Debug \
4358
-DBOARD="$BOARD" \
4459
-DDMBOOT_EMULATION=ON \
@@ -89,13 +104,19 @@ MONITOR_LOG="$BUILD_DIR/monitor.log"
89104
timeout "$MONITOR_TIMEOUT" cmake --build "$BUILD_DIR" --target monitor-gdb > "$MONITOR_LOG" 2>&1 &
90105
MONITOR_PID=$!
91106

92-
# Give the firmware time to produce log output
107+
# Give the firmware time to boot and produce log output
108+
echo "Waiting ${MONITOR_TIMEOUT}s for firmware to boot..."
93109
sleep "$MONITOR_TIMEOUT"
94110

95111
echo "Monitor output:"
96112
cat "$MONITOR_LOG"
97113
echo ""
98114

115+
# Also show the Renode connect log for diagnostics
116+
echo "--- connect.log (last 40 lines) ---"
117+
tail -40 "$CONNECT_LOG" || true
118+
echo ""
119+
99120
# Verify expected log messages
100121
bash "$VERIFY_SCRIPT" "$MONITOR_LOG" "$EXPECTED_LOGS"
101122
VERIFY_STATUS=$?

0 commit comments

Comments
 (0)