Assignment 1: Install TinyGo#
You will need Go and TinyGo installed on your computer for this workshop. This assignment will guide you through the installation process.
Install Go#
First, install the Go programming language if you don’t have it already.
Installing Go on Windows
- Download the Go installer from https://go.dev/dl/
- Run the installer (e.g.,
go1.22.5.windows-amd64.msi) - Follow the installation wizard
- Verify installation:
go version
Expected output:
go version go1.26.x windows/amd64
Installing Go on macOS
- Download the Go installer from https://go.dev/dl/
- Open the PKG file (e.g.,
go1.26.x.darwin-amd64.pkg) - Follow the installation wizard
- Verify installation:
go version
Expected output:
go version go1.26.x darwin/amd64
Alternative: Homebrew
brew install go
Installing Go on Linux
- Download the Go archive from https://go.dev/dl/
- Extract the archive:
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.26.x.linux-amd64.tar.gz
- Add Go to PATH by adding this to your
~/.profileor~/.bashrc:
export PATH=$PATH:/usr/local/go/bin
- Reload your profile:
source ~/.profile
- Verify installation:
go version
Expected output:
go version go1.26.x linux/amd64
Install TinyGo#
TinyGo requires additional setup depending on your operating system.
Installing TinyGo on Windows
Install LLVM:
- Download from https://releases.llvm.org/
- Extract to
C:\Program Files\LLVM - Add
C:\Program Files\LLVM\binto your PATH
Install TinyGo:
# Download latest release
# Visit: https://github.com/tinygo-org/tinygo/releases
# Extract to C:\Program Files\tinygo
# Add C:\Program Files\tinygo\bin to your PATH
- Verify installation:
tinygo version
Expected output:
tinygo version 0.41.0 linux/amd64 (using go version go1.22.5)
Installing TinyGo on macOS
- Install LLVM via Homebrew:
brew install llvm
- Install TinyGo via Homebrew:
brew tap tinygo-org/tools
brew install tinygo
Upgrading TinyGo: When upgrading TinyGo, first update Homebrew’s cache:
brew update
brew upgrade tinygo
- Verify installation:
tinygo version
Expected output:
tinygo version 0.41.0 darwin/amd64 (using go version go1.26.x)
Installing TinyGo on Linux
- Install LLVM:
# Ubuntu/Debian
sudo apt-get install llvm clang liblld-dev
# Fedora
sudo dnf install llvm clang lld
# Arch Linux
sudo pacman -S llvm clang lld
- Install TinyGo:
# Download latest release
wget https://github.com/tinygo-org/tinygo/releases/download/v0.41.0/tinygo_0.41.0_amd64.deb
# Install package
sudo dpkg -i tinygo_0.41.0_amd64.deb
- Verify installation:
tinygo version
Expected output:
tinygo version 0.41.0 linux/amd64 (using go version go1.22.5)
Install USB Drivers (Windows Only)#
If you’re on Windows, you may need USB drivers for your board.
M5Stack Core2:
- Uses CP2104 USB-to-serial chip
- Download drivers from SiLabs
M5Stack StampC3 / XIAO-ESP32C3:
- Uses native USB (no drivers needed)
Install IDE (Optional)#
Choose your preferred development environment. JetBrains GoLand offers excellent TinyGo support, or you can use Visual Studio Code with the TinyGo extension.
JetBrains GoLand (Recommended)#
JetBrains GoLand provides comprehensive TinyGo support with intelligent code completion, debugging, and project management.
- Download and install GoLand
- Install the TinyGo plugin:
- Open GoLand
- Go to
File>Settings>Plugins - Search for “TinyGo”
- Install the official TinyGo plugin
- Configure TinyGo SDK in GoLand settings
Visual Studio Code (Alternative)#
Visual Studio Code with the TinyGo extension provides a lightweight development experience.
- Download and install VS Code
- Install the TinyGo extension:
- Open VS Code
- Press
Ctrl+Shift+X(Windows/Linux) orCmd+Shift+X(macOS) - Search for “TinyGo”
- Install the extension
Verify Board Detection#
Connect your board via USB-C cable and verify it’s detected:
List COM ports:
[System.IO.Ports.SerialPort]::GetPortNames()
Or check Device Manager for “COM ports”.
List serial ports:
ls -la /dev/cu.usb*
Expected output:
crw-rw-rw- 1 root wheel 9, 3 Apr 22 10:00 /dev/cu.usbserial-1420
List serial ports:
ls -la /dev/ttyUSB* /dev/ttyACM*
Expected output:
crw-rw---- 1 uucp dialout 188, 0 Apr 22 10:00 /dev/ttyUSB0
Add user to dialout group (if needed):
sudo usermod -a -G dialout $USER
# Log out and log back in for changes to take effect
Get the Source Code#
The complete source code for this assignment is available in the developer-portal-codebase repository:
git clone https://github.com/espressif/developer-portal-codebase.git
cd developer-portal-codebase/content/workshops/tinygo/assignment_1
The codebase contains a simple test program to verify your TinyGo installation.
Test Installation#
Create a test file to verify your installation:
- Create a new directory:
mkdir tinygo-test
cd tinygo-test
go mod init tinygo-test
- Create
main.go:
package main
import (
"fmt"
"time"
)
func main() {
for i := 0; i < 5; i++ {
fmt.Println("Hello from TinyGo!", i)
time.Sleep(time.Millisecond * 500)
}
}
- Build for your host:
tinygo build .
- Run:
./tinygo-test
Expected output:
Hello from TinyGo! 0
Hello from TinyGo! 1
Hello from TinyGo! 2
Hello from TinyGo! 3
Hello from TinyGo! 4
Available Targets#
TinyGo supports many boards. Check available targets:
tinygo targets
Common ESP32 targets:
esp32-generic- ESP32esp32c3-generic- ESP32-C3esp32s3-generic- ESP32-S3xiao-esp32s3- Seeed Studio XIAO ESP32-S3
Troubleshooting#
“tinygo: command not found”#
- Ensure TinyGo is installed and in your PATH
- Try opening a new terminal window
- Check your PATH environment variable
“llvm-config not found”#
- Install LLVM for your operating system
- Ensure LLVM is in your PATH
- Try reinstalling TinyGo after installing LLVM
Board not detected#
- Check USB cable (must support data, not just power)
- Try a different USB port
- Install USB drivers (Windows only)
- Check board is powered (LED should be lit)
Permission denied accessing serial port#
Linux:
sudo usermod -a -G dialout $USER
# Log out and log back in
macOS:
sudo chmod 666 /dev/cu.usbserial-*
Windows:
- Run as Administrator
- Check Device Manager for port conflicts
Summary#
You should now have:
- Go 1.26+ installed
- TinyGo 0.41 installed
- VS Code with TinyGo extension (optional)
- USB drivers installed (Windows)
- Board detected and ready
Let’s verify everything is working with our first embedded program!
