This guide addresses common issues encountered when using LabWired Core.
Symptom: The simulator halts with StopReason::MemoryViolation(address).
Cause: The firmware attempted to access an address that is not mapped to Flash, RAM, or any registered peripheral.
Solution:
- Check your
chips/<chip>.yamldefinition. Does the address fall within the declared Flash or RAM regions? - Check your
system.yaml. Is there a peripheral missing that should be at that address? - Verify the firmware linker script (
memory.x). It might be placing data in valid hardware regions that the simulator doesn't know about yet.
Symptom: StopReason::DecodeError(address).
Cause: The CPU attempted to execute an instruction that is invalid or undefined for the current architecture (e.g., executing data as code).
Solution:
- Check the Vector Table. Is the Reset Vector pointing to the correct entry point (usually
_startorReset_Handler+ 1 for Thumb mode)? - Verify
load_firmwaresucceeded. Run with--traceto see the first few instructions. If it crashes immediately, the entry point might be wrong. - Cortex-M requires the PC LSB to be 1 (Thumb mode). If your vector table has an even address (e.g.,
0x08000100), the CPU will switch to ARM mode and fault.
Symptom: VS Code displays "Connection refused" or "Timeout" when starting a debug session. Cause: The LabWired instance isn't running, or the port is blocked. Solution:
- Ensure LabWired is started with
--gdbor is in interactive mode. - Check the port (default
3333). Is it in use by another OpenOCD/J-Link instance? - In
launch.json, verifymiDebuggerServerAddressmatcheslocalhost:<port>.
Symptom: uart.log contains random characters.
Cause: Baud rate mismatch between firmware and simulator config.
Solution:
- LabWired's UART model is currently "byte-perfect" (it doesn't simulate physical baud timing errors), but ensure your firmware is actually writing valid ASCII.
- Check if
echo_stdoutis enabled or if you are looking at raw binary data.
Symptom: CI fails with StopReason::MaxSteps.
Cause: The proprietary max_steps limit in your test script is too low for the initialization code to complete.
Solution:
- Increase
max_stepsin your.yamltest script. - Optimize your firmware boot sequence (e.g., reduce PLL validation timeouts).
Symptom: StopReason::NoProgress.
Cause: The PC has stayed in the same range (or exactly the same address) for no_progress_steps. This usually means an infinite loop (e.g., while(1) {} or a HardFault handler).
Solution:
- Use
--traceto identify the loop. - If it's a valid strict polling loop, insert a
asm!("nop")or similar to vary the PC, or increaseno_progress_steps.