0

tinyGo working on an Itsy Bitsy M0 (long) but with IMHO key
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

tinyGo working on an Itsy Bitsy M0 (long) but with IMHO key

by LarryP on Wed Jun 05, 2019 6:20 pm

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)
}
}
LarryP
 
Posts: 9
Joined: Sat Jul 21, 2012 2:38 pm

Re: tinyGo working on an Itsy Bitsy M0 (long) but with IMHO

by adafruit_support_mike on Thu Jun 06, 2019 1:05 am

Nice info.. thanks for letting us know!

adafruit_support_mike
 
Posts: 61107
Joined: Thu Feb 11, 2010 2:51 pm

Re: tinyGo working on an Itsy Bitsy M0 (long) but with IMHO

by LarryP on Thu Jun 06, 2019 2:29 pm

FYI, the size of my executable (in uf2 fmt) was much larger than when one of the two gurus (guri?) did this demo. Link here for his fosdem 2019 talk on tinygo: https://www.youtube.com/watch?v=KY8u9yZ97Tc
I don't yet know why; this is my first spin w/tinygo; YMMV. That said, I think this is worth a look. Only at ver 0.6.0 as of this writing, but making rapid progress. Porting to more boards, adding more sensors. Good stuff!
LarryP
 
Posts: 9
Joined: Sat Jul 21, 2012 2:38 pm

Please be positive and constructive with your questions and comments.