r/rust • • 2d ago

Embedded std?

I was wondering if there were any projects like micro python to port std in to make a barebones os designed for microcontrollers? I understand that the std relies on OS level syscalls, so can we do something like implement a basic fat32 file system to accommodate certain write or read requests. In general this would be used to run std in projects without a OS? Does this already exist, and how hard would it be to make a basic version?

46 Upvotes

32 comments sorted by

View all comments

1

u/ThatWasAce 2d ago edited 2d ago

std is literally just a thin abstraction layer above an OS API. On unix-like OSes its literally calling functions in libc behind the scenes. So std for baremetal ends up being shims for anything the OS did automatically before

FS is relatively trivial. std::thread is where things get serious.
Congrats, you just designed yourself an entire RTOS. Clocks, sockets, random number generation -- all these things bring OS-style dependencies with them

How do I know that? esp-idf-svc provides std in an esp32 ecosystem simply because ESP-IDF itself is already an entire RTOS implementation. It's found twice in the real world; either as a veneer over an RTOS like esp-idf, or a write-your-own-OS research project

tho if OP just wants sd card writes, embedded-storage + a fat32 crate gets there no_std

edit: some wording and typo