@@ -88,12 +88,23 @@ jobs:
8888 # Locate the SDK's qemu-system-riscv64; the minimal tarball may
8989 # ship hosttools only as an installer (or not at all) — run the
9090 # installer if present, fall back to the distro package.
91- QEMU_BIN=$(find "$ZSDK_DIR" -name qemu-system-riscv64 -type f 2>/dev/null | head -1)
91+ # The hosttools carry TWO qemu builds (usr/bin and the Xilinx
92+ # variant under usr/xilinx/bin) — only usr/bin supports the
93+ # generic virt machine, so never pick by blind find order.
94+ find_qemu() {
95+ for p in "$ZSDK_DIR"/sysroots/*/usr/bin/qemu-system-riscv64 \
96+ "$ZSDK_DIR"/hosttools/sysroots/*/usr/bin/qemu-system-riscv64; do
97+ if [ -x "$p" ]; then echo "$p"; return; fi
98+ done
99+ find "$ZSDK_DIR" -name qemu-system-riscv64 -type f \
100+ -not -path "*xilinx*" 2>/dev/null | head -1
101+ }
102+ QEMU_BIN=$(find_qemu)
92103 if [ -z "$QEMU_BIN" ]; then
93104 HT=$(find "$ZSDK_DIR" -name "*hosttools*standalone*.sh" 2>/dev/null | head -1)
94105 if [ -n "$HT" ]; then
95106 sh "$HT" -y -d "$ZSDK_DIR"
96- QEMU_BIN=$(find "$ZSDK_DIR" -name qemu-system-riscv64 -type f 2>/dev/null | head -1 )
107+ QEMU_BIN=$(find_qemu )
97108 fi
98109 fi
99110 # The SDK-built qemu may not run on this host (glibc/library
@@ -127,6 +138,21 @@ jobs:
127138 cat "$f"
128139 done
129140
141+ - name : QEMU smoke test on failure
142+ # Re-runs the twister-built image by hand so QEMU's own stderr
143+ # (bad option, missing lib, wrong binary) lands in the job log —
144+ # twister swallows it.
145+ if : failure()
146+ run : |
147+ "$QEMU_BIN" --version || true
148+ ELF=$(find twister-out -name zephyr.elf | head -1)
149+ echo "ELF: $ELF"
150+ timeout 15 "$QEMU_BIN" -machine virt -bios none -m 256 \
151+ -cpu rv64i,i=on,m=on,a=on,f=on,d=on,c=on,zicsr=on,zifencei=on,zicntr=on,pmp=on,u=on \
152+ -global virtio-mmio.force-legacy=false -nographic \
153+ -netdev user,id=n1 -device virtio-net-device,netdev=n1,bus=virtio-mmio-bus.0 \
154+ -kernel "$ELF" 2>&1 | head -40 || true
155+
130156 - name : Upload twister artifacts
131157 # Skipped under act: no artifact service (ACTIONS_RUNTIME_TOKEN).
132158 if : ${{ always() && !env.ACT }}
0 commit comments