The place where random ideas get written down and lost in time.

2023-01-28 - ESP32: Rust vs TinyGo are both no-go

Category DEV

TinyGo is not ready, and Rust is a crappy language.

TinyGo

So first let's have a look at TinyGo.

This seems promising: https://tinygo.org/docs/concepts/faq/what-about-esp8266-esp32/

“As of September 2020, we now have support for the ESP32 and ESP8266 in TinyGo!”

OK but below we find they support 2 boards: a “mini32” and an ESP8266 NodeMCU.

They also explain that they get their ESP32 device definitions from the Rust esp-rs project, which recreates them from the ESP-IDF source.

No idea what a “mini32” is but it’s based on an ESP32 so it may work for us?

We can find this: https://github.com/LilyGO/ESP32-MINI-32-V1.3

It’s not clear which ESP32 CPU that covers, so it may work with my modules.

But we have a bigger problem:

https://tinygo.org/docs/reference/microcontrollers/esp32-mini32/

  • SPI        ⇒ TinyGo Support = Yes.
  • I2C        ⇒ TinyGo Support = Not Yet.
  • Wifi        ⇒ TinyGo Support = Not Yet.

That makes it… pointless. At least for now.

https://github.com/tinygo-org/tinygo/blob/release/src/machine/i2c.go is the implementation of the i2c interface for machines. I note the file is prefixed by “//go:build atmega || nrf || sam || stm32 || fe310 || k210 || rp2040”. Clearly esp32 is not in the list.

From what I can see, the doc is up-to-date and that I2C is really not supported on their ESP32 port yet. It’s worth noting that none of their projects support an embedded wifi driver like the ESP32 contains. They have the usual “Arduino Wifi via UART with AT commands” support, which is not at all the same thing as it does not imply a “network stack”, even limited.

So right now TinyGo can be skipped. It’s only useful for projects not requiring wifi and no I2C.

Rust

2 main issues with Rust in this project:

  • The language is insufferable.
    • The ownership rules are inscrutable, and the data types are impossible to understand clearly.
  • The libraries are not helping much.
    • Sure the esp_idf_hal seems to add an “oriented object” layer to the ESP IDF C functions, but overall it’s just the same API with lipstick on it, if and when I can find it.
  • The small project with 2 blinking LEDs builds a 230 kB binary.
    • There are just so many libraries injected in the build… Very similar in nature to a Node.JS build

Obviously the initial part is a problem of familiarity with the Rust language. One could claim it can be fixed by learning the language more to understand the complex ownership rules, the insane trait types, and the box/ref count thing. But that’s also the worry -- generating write-only code that will be inscrutable when I pick up a side project years later.

So that’s going to be the end of this doc: TinyGo is a no-go, and Rust ESP-RS is a no-go.

For the SDB project, there are 2 possible options:

  • Regular C/C++.
  • MicroPython was fairly reasonable and worth looking at again.

There are projects that rebuild OpenCV as static *.a for ESP32: https://github.com/joachimBurket/esp32-opencv


 Generated on 2025-01-18 by Rig4j 0.1-Exp-f2c0035