SPIKE Prime C for VS Code
Beginner-friendly VS Code commands for creating, building, uploading, and running SPIKE Prime C projects.
Commands
SPIKE Prime: New Project
SPIKE Prime: Build
SPIKE Prime: Upload
SPIKE Prime: Build and Run
SPIKE Prime: Select Hub
SPIKE Prime: Configure SPIKE-RT Tools
SPIKE Prime: Open SPIKE-RT Build Folder
First milestone
This scaffold creates a JavaScript VS Code extension and a starter C project template. The generated project can build directly against a local SPIKE-RT checkout with make.
Second milestone
The next milestone is a SPIKE-RT-native project flow:
Run SPIKE Prime: New/Open SPIKE-RT App.
Choose an app name, for example line_follower.
The extension creates or registers the app inside the local SPIKE-RT checkout.
The extension configures the real SPIKE-RT build folder:
/Users/jax/spike-rt/build/obj-primehub_line_follower
VS Code opens that generated build folder.
Edit, build, upload, and run from the SPIKE-RT build folder.
This flow is less tidy than a standalone project folder, but it is closer to SPIKE-RT's documented build model. It should also reuse shared SPIKE-RT build artifacts more naturally:
/Users/jax/spike-rt/build/obj-primehub_kernel
/Users/jax/spike-rt/build/obj-primehub_pybricks
The first build may still take several minutes because SPIKE-RT has to compile Pybricks, the kernel, TECS-generated sources, and the app firmware. Later builds, and additional apps that reuse the same SPIKE-RT build cache, should usually be faster.
Local development
- Open this folder in VS Code.
- Press
F5 to launch an Extension Development Host.
- In the new VS Code window, run
SPIKE Prime: New Project.
- Open the generated project folder.
- Run
SPIKE Prime: Build or run make in the project folder.
Real SPIKE-RT setup
SPIKE-RT's documented Mac workflow builds inside Docker and flashes the hub from the host machine with PyUSB/libusb. New projects generated by this extension wrap that workflow so the project folder itself can be built with make.
Before real upload on macOS:
Install Docker Desktop.
Install the SPIKE-RT source tree and submodules.
Pull the SPIKE-RT Docker image:
docker pull ghcr.io/spike-rt/spike-rt:rich
Install libusb:
brew install libusb
In the SPIKE-RT repo, create the Python environment expected by SPIKE-RT:
python3 -m venv ./tools/python
./tools/python/bin/pip install pyusb
Open a generated SPIKE Prime C project folder.
Run SPIKE Prime: Build.
For upload, put the hub in DFU mode first: turn the hub off, hold the Bluetooth button, plug in USB, and keep holding until the light flashes.
On this machine, the detected SPIKE-RT checkout is:
/Users/jax/spike-rt
Known build folders include:
/Users/jax/spike-rt/build/obj-primehub_motor
/Users/jax/spike-rt/build/obj-primehub_led
/Users/jax/spike-rt/build/obj-primehub_button
/Users/jax/spike-rt/build/obj-primehub_pybricks
To test a real upload path, open a generated project folder, build it, put the hub in DFU mode, then run SPIKE Prime: Upload.
For Docker builds, the generated project mounts both the project folder and the full SPIKE-RT checkout into the container. This is required because generated build folders reference files such as /Users/jax/spike-rt/asp3/kernel/Makefile.kernel.
Settings
spikePrimeC.makeCommand: build command, default make
spikePrimeC.uploadCommand: upload command, default make deploy-dfu
spikePrimeC.outputFile: firmware file used by upload commands, default .spike-rt/build/obj-primehub_main/asp.bin
spikePrimeC.uploadRunsInTerminal: run upload in a terminal, default true
spikePrimeC.showDfuInstructions: show DFU reminder before upload, default true
spikePrimeC.spikeRtRoot: local SPIKE-RT checkout, default /Users/jax/spike-rt
References