Troubleshooting
QEMU shows no output
- Confirm you used
-nographicand-bios none. - Ensure the program writes to UART at
0x10000000. - Verify the ELF is RV32 (
readelf -hshowsELF32+RISC-V).
GDB connects but breakpoints do not hit
- Start QEMU with
-Sso the CPU is halted. - Make sure your ELF has symbols (
-g). - Set
set arch riscv:rv32in GDB.
Linker errors: missing _start
- Confirm
src/start.sis included on the command line. - Check
src/link.ldusesENTRY(_start).
QEMU exits immediately
- If
mainreturns,_startshould loop or executewfi. - Check that your
_startfunction is present and not optimized away.
Exercises
- Intentionally remove
-T src/link.ldand observe the error. - Remove
src/start.sand identify the missing symbol. - Change
-marchtorv32iand see if any examples break.
Summary
Most issues are caused by missing the startup file, using the wrong ELF, or forgetting QEMU flags. The fixes are deterministic and easy to confirm with readelf and GDB.