Go for Particle Argon, Boron or Xenon
With the release of TinyGo 0.13, you can now write firmware for Particle Argon, Boron and Xenon in Go:
There are some caveats for now, namely:
- TinyGo can't coexist with the Particle Device OS. Meaning flashing your Go app to the device will erase Particle bootloader and system. It is still possible to restore the device to "stock" but it requires manual flashing of all necessary parts.
- TinyGo doesn't support Argon's WiFi coprocessor nor Boron's cellular modems yet, meaning for now you can only use the devices offline. Ayke is making progress on support for the nRF Soft Device that allows BLE support (and Mesh in the future) but it's still experimental.
- You need to use the Particle Debugger to do all the flashing. It might be possible to use Adafruit nRF52 Bootloader (same as used for CircuitPython) in the future to allow flashing over the USB.
That being said, running TinyGo might be a nice alternative to CircuitPython if you need more speed. How fast is it? Well, it can handle a real-time flight controller for a drone on Arduino Nano33 IoT with SAMD21 Cortex-M0 at 48 MHz:
Or drive six 32x32 RGB LED matrices on Cortex-M4:
Additionally, a strong advantage of TinyGo is that TinyGo is written in Go itself! Meaning, you don't need to know C/C++ to understand/contribute or write low level code.
Got you interested? Lets proceed to the...
Instructions
Prerequisites
- Particle Argon/Boron/Xenon $11-$55
- Particle Debugger $12
Necessary software
- Install OpenOCD. If you have Particle Workbench installed, it should already download it for you to
~/.particle/toolchains/openocd
directory. Make sure theopenocd
binary is in yourPATH
. - Install TinyGo
Blinky
Well, that's it really. Now you're ready to go write Go:
package main
import (
// machine package exposes all hardware available on the microcontroller
"machine"
"time"
)
func main() {
// All the pins are listed here: https://tinygo.org/microcontrollers/machine/particle-xenon/
led := machine.LED
// Make it an output
led.Configure(machine.PinConfig{Mode: machine.PinOutput})
// Repeat forever
for {
// Turn it on (it's active low)
led.Low()
time.Sleep(time.Millisecond * 500)
// And off
led.High()
time.Sleep(time.Millisecond * 500)
}
}
Now you can flash your app with:
$ tinygo flash -target=particle-xenon blink
(assuming you save the Go code above in blink
directory). Also, you should set the -target
flag to the module you're using.
Summary
Even although Argon and Boron can't connect to the internet yet, peripherals like UART, GPIO, SPI, I2C, ADC, and PWM are working, and there are already plenty of drivers for devices like displays, sensors, etc.
I hope you'll have fun with TinyGo and if you like to chat about it or contribute, feel free to join the Slack channel and check out the GitHub repos.