micro:bit VS Code Extension
Preview release of VS Code support for the micro:bit codal environment
Getting started
Desktop
With VS Code installed, past this URL in a browser:
vscode://microbit.microbit-pack/clone?url=https://github.com/thegecko/microbit-v2-samples
The following should happen:
- VS Code should open and installe the micro:bit pack if it isn't already installed
- The repository passed should be cloned to a folder the user chooses and opened
- The environment manager downloads and activates any tools specified in the
vcpkg-configuration.json file (e.g. cmake, gcc)
Web with local files
Clone an example repository locally
git clone https://github.com/thegecko/microbit-v2-samples
- In chrome or edge, open vscode.dev and open the folder cloned locally
- Install the
micro:bit VS Code Extension Pack (id: microbit.microbit-pack) from the marketplace
Web with github
Open this URL in chrome or edge:
https://vscode.dev/github/thegecko/microbit-v2-samples
The following should happen
- You are asked to authenticate with github
- The repository passed is opened from github
- You are prompted to install the
micro:bit VS Code Extension Pack if needed
Any changes pushed will be done via a fork if you don't have relevant permission on the repository
Usage
A device manager panel should be visible to select a micro:bit attached to the system.
A micro:bit panel should be visible with buttons to:
- Build: use the builtin codal task provider to hydrate and build the project (Web WIP - see notes)
- Run: use the Arm embedded-debug extension to flash a device via DAPLink
- Debug: use the Arm embedded-debug extension to debug a device
When debugging, an SVD viewer panel should also be visible.
Notes
Build in web
This is a work in progress and not complete.
In order for project hydration to work, tar equivalents of dependant libraries must be served from a host with CORS disabled.
To mimic this locally, the sample above requires these files to be downloaded somewhere:
And then served up on localhost:
npx serve --cors -p 3000
The host and port for this are configurable in the extension settings.
Debug in web
If the binary being debugged was built in a different folder structure, then the debugger needs to be told where to find the source files. This can be done using the pathMapping configuration item in launch.json, e,g,:
{
"configurations": [
...
{
"name": "Debug Device",
"type": "embedded-debug",
"request": "launch",
"serialNumber": "${command:device-manager.getSerialNumber}",
"cmsisPack": "${command:device-manager.getDevicePack}",
"deviceName": "${command:device-manager.getDeviceName}",
"program": "${workspaceFolder}/build/MICROBIT",
"debugFrom": "main",
"pathMapping": {
"/path/to/microbit-v2-samples/": "${workspaceFolder}/"
}
}
...
]
}