TinyGo GO Compiler for Microcontrollers Now Works on Arduino Boards

Powerful, yet simple to use, TinyGo is making a significant mark in the open-hardware sector. This was well stated in the Arduino blog interview of Ron Evans, Technologist for Hire, as  Arduino is now working with TinyGo on an ongoing basis.

What is TinyGo?

The whole purpose of TinyGo is to bring Go to the microcontroller and the latest web browsers, to have that powerful language able to function in tiny processor formats, such as the Arduino Uno and Arm-based processors such as the Cortex-M type processors and also the BBC Micro: bit, STM32 Bluepill, and some other MCU boards, from any web browser.

How It Functions

It does this through LLVM toolchain and that format allows TinyGo to compile Go programs to a fraction of their original size, then flash the reduced Go program directly onto the microcontroller.

Web Browser Applications With WebAssembly

TinyGo can be used with WebAssembly (WASM) for applications that are browser-based, high-performance code. The use of TinyGo, through a JavaScript function, and then going to call a GO function from WebAssembly is straight forward. From there it is as simple as providing a target if TinyGo is already installed. GitHub is providing a number of files for multiple languages using TinyGo, including WASM (see link below)

How to run TinyGo

The compiler is very handy for developers, as the reduction in the overall size of the code, necessary to run Go, helps in those small places and processors where developers of commercial IoT are working. TinyGo can be installed on Linux, macOS, Windows, and Docker, as well as from the source code, found on GitHub.

Arduino and TinyGo

TinyGo can be paired with Arduino Nano 33 IoT, a board that hosts the Microchip SAMD21 Cortex-M0+ microcontroller, as well as a WiFi and Bluetooth module. There is a sample on GitHub of how TinyGo programs can be flashed to the board directly, where program execution is directly on the microcontroller.

Excellent Security Approaches

Security in development, deployment, and operations using TinyGo can be a boon in edge computing applications, which need a higher order of security. The code for TinyGo is compiled directly to binary, so code signing and many of the most utilized security methods and approaches can be performed.

Extra Security Ability

Also, device encryption is made between any device and any cloud storage or analytics. TinyGo and The Arduino Nano 33 IoT can use standard APIs for SSL communication to cloud services. The idea is to use an API like Eclipse Foundation’s Paho MQTT client for Go. That takes the guesswork out of when and where to make the system secure, it happens right upfront.

Information about programing using TinyGo can be found on the “Tiny Gopher” website where you can buy the book. Or read the Getting Started on the TinyGo website. TinyGo on GitHub has a lot of code for many different types of situations when using TinyGo.

Support CNX Software - Donate via PayPal or become a Patron on Patreon

3
Leave a Reply

avatar
1 Comment threads
2 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
3 Comment authors
Bumsik KimJean-Luc Aufranc (CNXSoft)Drone Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
Drone
Guest
Drone

Nice post Stephen, but what about one of the biggest ‘things’ about Golang: Concurrency?

https://en.wikipedia.org/wiki/Go_(programming_language)#Concurrency

Will I be able to run concurrent functions on say, an Arduino Uno? That would be cool!

See this example of concurrency in Go:

https://en.wikipedia.org/wiki/Go_(programming_language)#Examples

Jean-Luc Aufranc (CNXSoft)
Admin

Concurrency looks to be experimental in TinyGo:

Concurrency

At the time of writing (2019-07-05), support for goroutines and channels has not been fully realized but simple programs usually work. There may be problems with function pointers or starting more than two goroutines. Also, some things may unexpectedly allocate heap memory like calling a function that blocks. This situation should certainly improve in the future: at the moment, you should treat goroutines as an experimental feature.

Bumsik Kim
Guest
Bumsik Kim

I would say natively compiled language with Garbage Collection is the big point.