Skip to content

Instantly share code, notes, and snippets.

@shawalli
Last active April 1, 2020 20:07
Show Gist options
  • Save shawalli/1f173866cff23365c7d5f3788c646f5d to your computer and use it in GitHub Desktop.
Save shawalli/1f173866cff23365c7d5f3788c646f5d to your computer and use it in GitHub Desktop.
Set up a Raspberry Pi W Zero with Go and TinyGo, in order to compile and flash to Arduino Uno
# Performed on a Raspberry Pi W Zero running Raspian/Buster
# $ uname -a
# Linux raspberrypi 4.19.97+ #1294 Thu Jan 30 13:10:54 GMT 2020 armv6l GNU/Linux
export GO_VERSION=1.13.9
export TINYGO_VERSION=0.12.0
# Install Go
wget https://dl.google.com/go/go${GO_VERSION}.linux-armv6l.tar.gz
tar -xvzf go${GO_VERSION}.linux-armv6l.tar.gz -C ${HOME}
cat <<'EOF' >> ${HOME}/.bashrc
# Go
export GOROOT=${HOME}/go
export PATH=${PATH}:${HOME}/go/bin
EOF
# Install TinyGo
wget https://github.com/tinygo-org/tinygo/releases/download/v${TINYGO_VERSION}/tinygo_${TINYGO_VERSION}_armhf.deb
sudo dpkg -i tinygo_${TINYGO_VERSION}_armhf.deb
cat <<'EOF' >> ${HOME}/.bashrc
# TinyGo
export PATH=${PATH}:/usr/local/tinygo/bin
EOF
# Install Arduino tools (AVR)
sudo apt-get install gcc-avr avr-libc avrdude
# Verify Go and TinyGo execution/versions
. ~/.bashrc
go version
tinygo version
# Verify Build
tinygo build -o blinky1.hex -target=arduino examples/blinky1
# Test end-to-end compile and flash to Arduino
tinygo flash -target=arduino -port=/dev/ttyACM0 examples/blinky1
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
network={
ssid="" # plaintext SSID
psk="" # plaintext password
key_mgmt=WPA-PSK
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment