
Run and debug your SPOS code inside VS Code, without the lab board. The extension builds your project with your own AVR toolchain and runs it on an emulated ATmega644 with the board's LCD, LEDs, buttons and external SRAM.
Requirements
make and the AVR toolchain (avr-gcc, avr-objcopy, avr-objdump) on your PATH
- macOS:
brew tap osx-cross/avr && brew install avr-gcc
- Debian/Ubuntu:
sudo apt install make gcc-avr binutils-avr avr-libc
- A project whose
Makefile builds an .elf with make all, and with make debug for debugging
Getting started
- Open your SPOS project folder in VS Code.
- Run SPOS: Open AVR ATmega644 SPOS Simulator from the Command Palette (
Ctrl+Shift+P, on macOS Cmd+Shift+P).
- Save a C file. The project is built and starts running on the board next to your editor.
Click the board's buttons to press them; 1+4 presses buttons 1 and 4 together. The toolbar has Run, Debug, Pause and Reset, the table icon opens the memory view, and the ··· menu has the pin mapping, the changelog and a link for reporting an issue.
Debugging
Set breakpoints in your C files and press Debug (or run SPOS: Compile & Debug). The program stops at each breakpoint and VS Code shows the line. To start a debug session on every save, set spos.onSave to debug.
Memory view
The table icon (or SPOS: Open Memory View) shows internal SRAM, external SRAM and the CPU registers. The map and use areas of both heaps are highlighted, using the layout in the spos.int.* and spos.ext.* settings.
Pin mapping
The board starts with the standard SPOS wiring. To put an LCD line, LED, button or the external SRAM on another pin, open ··· → Pin mapping. Changes apply when you close the dialog, without restarting your program, and are saved to spos.pinMapping. A signal on two pins is flagged and has to be fixed first. Reset to defaults brings back the standard wiring.
How it works
- Build: in the Makefile's folder, the extension runs
make clean and then make all (or make debug). avr-objcopy turns the ELF into HEX: SPOS.elf if it exists, otherwise the newest .elf there.
- Emulation: the HEX runs on avr8js inside VS Code. It emulates the ATmega644 core, ports A–D, two timers, SPI, the HD44780 LCD, the 23LC1024 external SRAM, LEDs and buttons. The ADC is not emulated yet.
- Breakpoints: for a debug build, a
break instruction is inserted in your source at each breakpoint line. The files are restored right after the build. avr-objdump maps the program counter back to your source lines.
- Errors: a failed build shows the compiler's message in a notification. The full output is in the SPOS Build output channel.
- Local only: nothing is uploaded and nothing is tracked. The only network request is for the panel's fonts (from Google Fonts).
Settings
| Setting |
Default |
|
spos.onSave |
run |
What saving a file does: run, debug or nothing |
spos.makefilePath |
(empty) |
Makefile to build, relative to the workspace folder. Empty: the first Makefile found |
spos.pinMapping |
standard SPOS wiring |
Which signal is on which pin. Easiest to edit in the pin mapping dialog |
spos.int.*, spos.ext.* |
SPOS heap layout |
Start and size of the map and use areas of each heap, in decimal |
spos.cyclesPerBatch |
200000 |
Instructions run before the simulator yields to VS Code |
Troubleshooting
make or avr-objcopy not found: install the toolchain, check that avr-objcopy --version works in a terminal, and restart VS Code.
- Build fails: run
make all in the Makefile's folder to see the same error, or open the SPOS Build output.
- The wrong project is built: set
spos.makefilePath.
Found a bug or missing a feature? Open an issue on GitHub.
License
MIT, see LICENSE.