Toit open-source language claims to be 30x faster than MicroPython on ESP32

Developed by a team of former Google employees, Toit is a complete IoT platform with remote management, firmware updates for fleets of devices with features similar to the one offered by solutions such as balena, Microsoft Azure, or Particle edge-to-cloud platform.

Toit currently works on ESP32 microcontrollers using lightweight containers, and after seeing existing high-level languages MicroPython and Javascript were not fast enough on low-end microcontrollers platforms, the team at Toit started to develop the Toit language in 2018, and has just made it open-source with the release of the compiler, virtual machine, and standard libraries on Github under an LGPL-2.1 license.

Toit language

One of the main reasons to switch from MicroPython to the Toit language is if your application is limited by performance or you operate ESP32 from a battery, as Toit claims up to 30x faster performance with Toit on ESP32:

We went into crunch mode and some months later, we had the first results. We were executing code more than 30x faster than MicroPython on an ESP32 with a high-level language that abstracts away memory allocation and that can be learned in a few hours by a Python developer: the Toit language.

So let’s have a deeper look by trying it out in Ubuntu 20.04. The virtual machine is based on a fork of the ESP-IDF with custom malloc implementation,  allocation fixes for UART, and LWIP fixes. That’s what we’ll need to install first:


Now install ESP32 tools:


and build toit and samples to run on the host machine:


We can now run the hello world sample:


as follows:


That’s all good but what’s about building the sample for ESP32? Easy:


This will create a Toit firmware file (toit.bin) preloaded with the hello world sample and that can be flashed with esptool:


Good, but surely we can check a sample with Wi-Fi, and indeed there’s the http.toit sample:


That neat and simple example simple download Google page and reports the number of bytes downloaded. But wait… Where do we configure Wi-Fi credentials? This can be done at build time:


or you can change the default program and configure the WiFi SSID and password in the Makefile:


I do not have an ESP32 up and running to test it out, but I’d assume you’d be able to modify the hello.toit on the device itself after flashing Toit firmware the first time. OTA firmware update should be enabled too based on the output from the make esp32 command. The complete Toit platform is free to use for up to 10 devices, and besides the Github page, you can also find additional information on the documentation website not only about the firmware and Toit language we’ve used here, but also the Cloud API and Toit platform as a whole.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

Radxa Orion O6 Armv9 mini-ITX motherboard
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
21 Comments
oldest
newest
Boardcon CM3588 Rockchip RK3588 System-on-Module designed for AI and IoT applications