Documentation
Pre-requisites
You’ll need to install Go and TinyGo on your computer, please note that there are different version combinations for Go and TinyGo.
TinyGo should basically be used in combination with the latest or previous version of Go.
TinyGo | Corresponding Go |
---|---|
0.32.0 | 1.19 - 1.22 |
0.33.0 | 1.23 - 1.22 |
You can use it if the PATH is set in each execution body.
The following may be helpful, although the version is a little old.
You can check if it has been installed by doing the following.
$ tinygo version
tinygo version 0.33.0 windows/amd64 (using go version go1.22.5 and LLVM version 18.1.2)
$ tinygo build -o out.uf2 --target waveshare-rp2040-zero --size short examples/serial
code data bss | flash ram
7836 108 3152 | 7944 3260
Windows + WSL2
You can use the Linux version of TinyGo on Ubuntu on WSL2. However, you cannot directly see what is connected to the USB on the Windows host from WSL2, so it is difficult. Even if you use WSL2, it is generally better to install the Windows version of TinyGo to the Windows path. In this case, you also need to install the Windows version of Go.
If you really want to communicate from TinyGo on WSL2, you can use usbipd as follows.
However, it is not very convenient because you need to attach usbipd every time you flash tinygo.
Setting on Linux
To use tinygo flash
, tinygo monitor
, and Vial
on Linux, you need to set udev rules.
Create /etc/udev/rules.d/99-zero-kb02-udev.rules
with the following content and reboot.
# RP2040
# ref: https://docs.platformio.org/en/latest/core/installation/udev-rules.html
ATTRS{idVendor}=="2e8a", ATTRS{idProduct}=="[01]*", MODE:="0666", ENV{ID_MM_DEVICE_IGNORE}="1", ENV{ID_MM_PORT_IGNORE}="1"
# Vial
# ref: https://get.vial.today/manual/linux-udev.html
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{serial}=="*vial:f64c2b3c*", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
The file with the same content as above is below.
The above file was created from the following documents.
Please refer to them as necessary for details.
- https://docs.platformio.org/en/latest/core/installation/udev-rules.html
- https://get.vial.today/manual/linux-udev.html
TinyGo dev branch version
If you want to use the latest version under development, download the Artifact > release-double-zipped built with GitHub Actions.
- windows
- https://github.com/tinygo-org/tinygo/actions/workflows/windows.yml?query=branch%3Adev
- linux
- https://github.com/tinygo-org/tinygo/actions/workflows/linux.yml?query=branch%3Adev
- macos
- https://github.com/tinygo-org/tinygo/actions/workflows/build-macos.yml?query=branch%3Adev
See below for more details.
LSP / gopls support
TinyGo places the machine package and other packages in GOROOT, so until you configure it, an error will be displayed in gopls and you will not be able to jump to the definition of machine.LED. TinyGo uses unfamiliar package structures such as machine packages (even if you are familiar with Go), and there are many branching steps using build-tags, so it is best to set up an LSP for TinyGo.
The official documentation can be found here:
For VSCode, it is a good idea to install the TinyGo extension.
For Vim (+ vim-lsp), try using github.com/sago35/tinygo.vim
.
Information in Japanese is listed below.
- How to link gopls with TinyGo + ‘VSCode or Vim (or other LSP-compatible editor)’
- Settings for gopls with TinyGo + Vim
Development target
For TinyGo Keeb Tour 2024, we use a homemade keyboard/macro pad called zero-kb02.
The microcontroller is RP2040 (Cortex M0+), and the microcontroller board is Waveshare RP2040-Zero.