HowTo: Rust on the photon


#1

TL;DR

Hello Particle community,

I’m here to present some of the recent work I’ve been doing to add Rust support to the photon.

(Full disclaimer: I’m under contract to improve Rust’s embedded development story and one of the tasks involves adding Rust support to well known development boards and I picked the photon. Yay!)

My focus is making sure that the tooling and development experience for this board is as good as possible on the three major OSes. To that goal I have created a template Cargo project to get you writing code for your photon as quickly as possible. Give it a try! I have successfully tested it on Linux and on Windows and expect that it should also work well on macOS.

I have also been creating a safe API on top of the Firmware API, and already have working part of the Cloud API, the USB Serial API, the delay API and the digital output API. Furthermore, I have created memory safe abstractions for sharing data between the application thread and the cloud functions so all the examples in the project template are written in 100% safe Rust! :tada:

Do let me know if anything doesn’t work for you by opening an issue in this issue tracker. Also let me know if I should prioritize work on some particular API that’s currently missing. And, by the way, you can help me with that: Adding more low level bindings is easy as adding the function signature to this block as explained here; building safe APIs on top of that require some discussion about the invariants we want to preserve and how we want to do error handling so chime in the discussion.

Happy Rusting!

cc @dbrgn @zach


Rust on Particle: development discussion
#2

@zachary


#3

Can’t wait to try it!


#4

Wow! Great work! :smiley:


#5

This is awesome, can’t wait to try it out!

If there’s anything you need in our firmware stack to facilitate your work, feel free to make pull requests, or raise opportunities for improvement with @mdma, who I’m sure would love to help.

Once this is fleshed out, I’d love to start a conversation about how we can support it in our cloud compiler so people can build Rust firmware applications without needing to set up a local toolchain.


#6

Thanks for sharing this!!


#7

If there’s anything you need in our firmware stack to facilitate your work, feel free to make pull requests, or raise opportunities for improvement with @mdma, who I’m sure would love to help.

Will do!

Once this is fleshed out, I’d love to start a conversation about how we can support it in our cloud compiler so people can build Rust firmware applications without needing to set up a local toolchain.

Sure. Sounds like a great idea to me.