Remix.run Logo
Running Bare-Metal Rust Alongside ESP-IDF on the ESP32-S3's Second Core(tingouw.com)
46 points by MrBuddyCasino 3 days ago | 9 comments
the__alchemist 4 hours ago | parent | next [-]

Very good article!

Anecdote about this summary at the bottom: > This setup gives you the best of both worlds: ESP-IDF and FreeRTOS manage Wi-Fi, BLE, and system tasks on Core 0, while Core 1 runs your bare-metal Rust code at full speed with zero scheduler interference.

I am doing something somewhat like this, but with separate MCUs instead of separate cores. I flashed Esp-Hosted-MCU onto an ESP-32 (C3, but any including S3 will work). This is official firmware which turns the ESP into a "radio co-processor", so you can treat it like a SPI or UART Wi-Fi/BLE chip.

On another MCU (STM32), I run bare-metal firmware in rust which talks to the radio over SPI. Wi-Fi uses the ESP IDF, and BLE uses standard HCI commands.

embeng4096 21 minutes ago | parent | next [-]

I didn’t know about hosted-MCU! I just started using the ESP-AT firmware for an ESP acting as a radio co-processor on a project at work - do you know how hosted-MCU differs?

I did glance at the readme and get the impression that hosted-MCU works for all compatible ESPs and seems more flexible and powerful, where ESP-AT is for select ESP chips and is more limited.

sottol 4 hours ago | parent | prev [-]

Interestingly, Espressif nowadays does something similar on the ESP32-P4 which is RiscV but doesn't have builtin Wifi/BT. So they tend to pair it with an ESP32-C6 which runs the WiFi stack and firmware that communicates with the P4 using SDIO. Not bare metal though, but similar dual-mcu setup for wifi/bt.

fjfaase 5 hours ago | parent | prev | next [-]

I think you can run a single task on core 1 without interference if you give it the right priority (and disable some things).

barbegal 4 hours ago | parent [-]

Yes you can pin it to core 1 whilst pinning all other tasks to core 0. Then will never be interrupted or preempted (except by interrupts created on core 1)

dakolli 2 hours ago | parent | prev | next [-]

This is a great blog, I love the I Built a WebAssembly Runtime in 5 Days Because I Was Tired of Paying for Cloud Run [1], . You do a great job at showcasing your creativity for solving problems. I can tell that you genuinely got a lot of satisfaction from escaping big cloud FaaS, for literally fun and profit. I need more blogs like this.

[1]: https://tingouw.com/blog/cloud_notes/badwater_intro#day-5-8m...

ufocia 3 hours ago | parent | prev [-]

Interesting, but giving up an entire core to Wi-Fi and Bluetooth seems wasteful.

nerdsniper an hour ago | parent | next [-]

On basic microcontrollers, mixing message/command I/O with application threads on the same core often lead to missing incoming commands. So it's relatively normal to separate them to their own core free of application logic.

the__alchemist 2 hours ago | parent | prev [-]

This is reasonably common - Nordic and ST do this as well on the nrf-53 and STm32WB/L respectively. It's convenient for concurrency, and separation of concerns.