LabWired executes standard ELF binaries compiled for ARM Cortex-M targets. The simulation environment requires two components: a valid firmware image and a declarative system configuration.
The firmware boundary. LabWired does not ship a firmware HAL. Build firmware against the vendor SDK you would use on real silicon — ST CMSIS / STM32CubeMX HAL, Nordic nrfx, Raspberry Pi Pico SDK, ESP-IDF, or hand-rolled register writes. The simulator models the peripheral/register side; firmware sees the same memory-mapped registers it would on hardware. There is no
labwired.hto include and no Labwired-provided abstractions to link against.Per-board coverage tables under
docs/boards/list exactly which peripherals are modeled for each chip. If your firmware touches a register that isn't modeled yet, you'll get aMemoryAccessViolationor a stuck polling loop — see Common Runtime Issues below.
LabWired loads ELF files generated by standard toolchains (Rust rustc, GCC arm-none-eabi-gcc).
- Format: ELF (Executable and Linkable Format).
- Architecture: ARMv7-M (Cortex-M3) or compatible.
- Memory Layout: Sections must be linked to valid addresses defined in the Chip Descriptor.
- Entry Point: The Vector Table must be placed at the Flash base address (typically
0x0800_0000).
Ensure the target is installed and build in release mode for performance:
rustup target add thumbv7m-none-eabi
cargo build --release --target thumbv7m-none-eabiThe simulation hardware is defined via two YAML configuration files:
- Chip Descriptor: Defines the internal memory map and peripheral base addresses.
- System Manifest: Defines the board-level configuration and instantiates the chip.
Defines the MCU's physical memory layout.
name: "STM32F103"
flash:
base: 0x08000000
size: "64KB"
ram:
base: 0x20000000
size: "20KB"
peripherals:
- id: "rcc"
type: "rcc"
base_address: 0x40021000Instantiates the chip and configures external connections.
name: "bluepill-board"
chip: "../chips/stm32f103.yaml"Invoke the labwired-cli with the firmware path and system configuration:
labwired --firmware firmware.elf --system system.yaml- Segment Loading: The loader creates a virtual memory space based on the Chip Descriptor.
PT_LOADsegments from the ELF are copied to their respective addresses (Flash/RAM). - Vector Table Initialization: The initial Stack Pointer (SP) is loaded from
FlashBase + 0x00. The Reset Vector (PC) is loaded fromFlashBase + 0x04. - Execution Loop: The CPU begins fetching and executing instructions from the Reset Vector.
Symptom: Simulation terminates with MemoryAccessViolation.
Cause: The firmware attempted to read/write an address not mapped in chip.yaml.
Resolution: Verify linker script memory regions match the Chip Descriptor.
Symptom: HardFault immediately upon start.
Cause: The Vector Table is not located at the Flash Base Address.
Resolution: inspected the ELF headers (objdump -h) to confirm .vector_table placement.
Symptom: Firmware hangs in a polling loop (e.g., waiting for RCC_CR_HSIRDY).
Cause: The peripheral model does not fully implement the status flag logic required by the HAL.
Resolution: Run with --trace to identify the spinning loop. Use a StubPeripheral to mock the expected status bit if a full model is unavailable.