Greetings all,
I'm pleased to report success installing and testing tinyGo (https://tinygo.org/) on an Itsy Bitsy M0. Just blinking the red LED, but I find golang on bare silicon pretty promising!
A few key details:
The #tinygo channel of gophers.slack.com is *invaluable*. I got help from the compiler developer and another helpful expert; can't beat that!
FYI, the key help was the (unintuitive-to-me-at-least) need to unset both GOROOT and GOPATH to get tinygo to work:
====
Gory details follow:
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ pwd
/home/larry/GoProjects/tinygo/blinky1/blinky1
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ unset GOROOT
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ unset GOPATH
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ which tinygo
/usr/local/tinygo/bin/tinygo
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ tinygo build -o blinky.hex -target itsybitsy-m0 examples/blinky1
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ ls -l
total 48
-rw-r--r-- 1 larry larry 328 Jun 5 15:16 blinky1.go
-rw-r--r-- 1 larry larry 43704 Jun 5 15:54 blinky.hex
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ ls -l *.hex
-rw-r--r-- 1 larry larry 43704 Jun 5 15:54 blinky.hex
#The command below builds an executable compatible with the itsyBitsyM0 bootloader, namely in .uf2 format:
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ tinygo build -o blinky.uf2 -target itsybitsy-m0 examples/blinky1
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ ls -l
total 80
-rw-r--r-- 1 larry larry 328 Jun 5 15:16 blinky1.go
-rw-r--r-- 1 larry larry 43704 Jun 5 15:54 blinky.hex
-rw-r--r-- 1 larry larry 32256 Jun 5 16:13 blinky.uf2
#I plugged in a new itsyBitsyM0; dragged blinky.uf2 into the dir with the other .uf2 files and voila!
# The go code is short, sweet and generic; I like it!
larry@larryLaptopDell:~/GoProjects/tinygo/blinky1/blinky1$ more blinky1.go
package main
// This is the most minimal blinky example and should run almost everywhere.
import (
"machine"
"time"
)
func main() {
led := machine.LED
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
for {
led.Low()
time.Sleep(time.Millisecond * 500)
led.High()
time.Sleep(time.Millisecond * 500)
}
}