Example microzig project with zero dependencies outside of zig (there are dependencies in zig.zon but that's the point)
Example project which attempts to make a one click build/test flow for vscode. The main goal is to reduce outside of zig build dependencies where possible. It has several features:
- vscode based build calls
- Leverage picotool to load uf2 files to the RP2040
- Uses serial communication to the RP2040 device to request a reboot to boot-loader
- Enables serial communication monitoring of the device.
- Also shows disassembly step as a bonus
This works for me but may not work for you. While I'd love any feedback, I'm not committed to support or develop this in any way.
This has a dependency on the currently latest released version of microzig but very likely the main branch or a more recent release is going to be better - more bug fixes etc.
The build & load flow is setup for a pico-probe based UART communication path. So the VID PID search routine is looking for that specific device. Other setups (including direct USB communication to the RP2040 under development) will need different configurations.
This project leverages the node-terminal built in vscode launch type (no extra extensions) to call different zig build commands. I'm not clear on what, if any side effects there are from this. Example from launch.json:
{
"command": "clear; zig build load",
"name": "build load",
"request": "launch",
"type": "node-terminal"
},
picotool is a tool for working with RP2040/RP2350 binaries, and interacting with RP2040/RP2350 devices when they are in BOOTSEL mode.
https://github.com/raspberrypi/picotoolkk
The build flow is setup to pull picotool (for Linux only right now) from the raspberrypi release and install it as pre-built binaries (could not get the build working with just zig)
If picotool is already available it will not pull the package.
The flow then calls picotool load and picotool reboot to get the new version running.
https://github.com/raspberrypi/pico-sdk-tools/releases
Serial communication is done using the available serial package from the microzig group. A very basic program finds the appropriate serial device, and opens the connection. Currently it can only print out send data but it could be expanded for more interaction. It also optionally can open the serial link and send a reboot command - assuming the device is setup to receive that command.
https://github.com/ZigEmbeddedGroup/serial
Disassembly is a bonus here which relies on an existing system tool (not in the spirit of this example). Maybe in the future this will be improved.