Rust on ESP8266

I just published this (pre-alpha, very hacky) script for building ESP8266 firmware written in Rust:

https://github.com/emosenkis/esp-rs

21 Likes

Over the last past few days, the script has been greatly improved. Generating bindings should work for all Arduino/ESP SDK libraries as well as dependencies listed in platformio.ini. Whitelisting is used for bindgen to avoid bloat and unnecessary failures. Documentation has been greatly expanded.

2 Likes

Nice. I have a few of these laying around. Have tried Micro Python and Mongoose OS so far. Will try and find time to have a play with this.

You glorious, glorious individual. I am. So excited. For this.

I've a batch of 10 ESP8285s and a Minix arriving soon, so will hopefully be first attempting this deployment over thanksgiving break (Nov 17 to Nov 28). This would entail starting from a fresh ubuntu install, so I'll document the whole process in line with issue 6.

I'm new to Rust and to the 8285, though I've used my fair share of different microcontrollers- I'm in wearable robotics & biosensors sorts of stuff.

1 Like

I pushed some more updates to the repo which should make it more user-friendly and hopefully more reliable. See the README for update instructions and more details on the changes.

Has anyone built anything interesting for ESP8266 in Rust so far?

4 Likes

I haven't gotten the chance to use this script yet but I'll try to do so soon.

The thing I'm mostly wondering about is what we'll have to do for library support. Like...having more...Rust-y libraries to use in ESP development would be really cool

I've pushed a few changes to use a more recent mrustc and Arduino SDK. Rust dependencies using cargo-vendor are now supported. I'm also working on an implementation of embedded-hal for ESP8266. I'll push it to crates.io once I figure out the proper way to handle libraries that depend on bindings to the Arduino SDK.

1 Like

I've just pushed a major update resulting in much cleaner project directories. Even better, the esp8266-hal crate is now available! See the esp-rs repository for details.

4 Likes

Yay! New update! And integration with the embedded-hal ecosystem :tada:

I just wanted to let you know that I really appreciate you doing this!
Even though I am currently busy with other projects, I have several ESP's lying around that are in strong need of a rust-based firmware :slight_smile:

Thanks so much for blazing the trail! :heart:

1 Like

Hello,
I am right now testing what you did and it sound awesome. I actually never used RUST, but being table o use compiled language else than C and C++ would be very interesting. So maybe, I will start to program in RUST :smiley: So I have seen that you base your work on the Arduino SDK, but would it be much more difficult to use esp-open-rtos? Is it possible for a beginner like to implement such setup or would I spend month?

Thanks :wink:

It's not necessarily difficult but will likely require you to understand the build process pretty well. You can start with the advice I gave to someone wanting to use this for ESP32, but unless PlatformIO supports esp-open-rtos, you'll have to rip out all of the parts of the script that use PlatformIO and replace them with the equivalent steps for the esp-open-rtos build process.

1 Like

Hi :slight_smile:
The build script was running for hours on my laptop, I had some fix to put as well but at the end it didn't succeed :-/ I will have to look more closely again but for the moment I have no time. Anyhow I am really interested about your project so I will do my best to fix it :stuck_out_tongue: Did you consider to use Docker? Cause it would be much easier for the setup...

Ciao :slight_smile:

Sorry to hear that it didn't work... Docker support sounds interesting... if you manage to get something working, I'd love to get a pull request!

Hi, I'm working on some fixes for Dockerfile and build.sh and documenting a bit on the go: https://github.com/korpiq/esp-rs

Following is just for heads-up and FYI; I'll continue digging into it when I have time again (likely after several weeks):

Unfortunately I seem to have hit a memory limit when trying to compile and upload for d1_mini_pro (default nodemcuv2 compiles and uploads fine but does not actually work on my wemos board):

/build/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld:
  .pioenvs/d1_mini_pro/firmware.elf section '.text' will not fit in region 'iram1_0_seg'
.pioenvs/d1_mini_pro/libFrameworkArduino.a(core_esp8266_main.cpp.o):(.text._Z9init_donev+0x8):
  undefined reference to `__eh_frame'

Seemingly related: https://github.com/esp8266/Arduino/issues/4551

Some of my versions:

  • PlatformIO, version 3.6.4
  • gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
  • g++ (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609
  • rustc 1.33.0 (2aa4c46cf 2019-02-28)

Cheers, and thanks for the script, it got us started at least :slight_smile: