Saturday
Nov102018

Rust on Arduino - When will that boulder get to the top of the hill Sisyphus?

This fall I got a fun little Hallowing from Adafruit and thought I'd try to cross compile something in Rust Lang (https://www.rust-lang.org/) for it.  Wow that board is has 48Mhz speed demon with 32 Kb of RAM and and 256k flash rom program memory plus a !8MB! SPI flash drive loads and saves... and a 8192 color 128x128 dot TFT display with 4bit blues and reds and amazing 5bits for vibrant greens.  Easily twice the computational power of your average 1976 mars lander!   

The sorry state of the Rust programming language on Arduino right now is "I am not smart enuff to make it work".   I blindly hope that's changing... perhaps I am merely not patient enough.     I really thought rust+arduino might be a happy couple soon, not all that long ago, and the last AVR Rust language fork was released almost simultaniously with this post so perhaps they are yet destined to be together. (https://github.com/avr-rust).  

I'm a fan of Arduino C, and a fan of Rust.  Rust would be a strong choice for hack hardened electronics - the language is designed to be resistant to memory attacks and undefined states - weaknesses frequently exploited in compiled C.  Executable rust programs run nearly as speedy as C or faster if you can leverage low bar easier to code multithreading in rust.  Rust's no garbage collection means timing could theoretically be more stable for  two wire sync and communication by bitbanging a cpu pin HI and LO without a clock - a common situation for hobbiests aiming for low cost and working with color LEDS displays.)   If your next router was running rust, a good number of security vulunerabilities might just not exist in the way they do now.  Then again, maybe rust wouldn't help since the WIFI Alliance goals for 802.11 compliance were ease of use over security and rust isn't going to fix a security model that evaportates the instant a local USB cord is plugged into a router.

My present barriers to entry:

(1) RUST executable sizes are larger than ARDUINO C.  With effort not double, but still harrowing for a hallowing 32kb system.   James Munn has a great post https://jamesmunns.com/blog/tinyrocket/  on how to  get rust shrinkage.

(2)  I don't presently have projects that really needs Rust's security or parallelism even if I would prefer to write in Rust.  If I take up programmed robotic painting again, a Raspberry Pi with multiple coresc and configured with 4mb of (slow) virtual memory should work for the build on device.  

(3) No Rustified Arduino cross compile IDE exists so far as I can tell, at least nothing like the sweet sweet https://www.arduino.cc/en/Main/Software.  Long arcane configurations and rustc command lines should not deter me, but do, especially when I follow examples and still get "That probably worked a few versions ago type" errors.

(4). Did I mention the "that probably worked a few versions ago with a specific unstable AVR fork off the main rust nightly branch " type errors?  Good news, there's a better way and I just don't seem to be up to speed yet.  Yea.  And I'm reaching for that single thread slow ass Ardino C IDE to do a library search again (The cross platform Arduino C IDE really is execellent in so many ways... super kudos to the Arduino team of Massimo Banzi, David Cuartielles, Tom Igoe and David A. Mellis.  If only they each loved rust... soft wet weeping sound ensues along with the the unformed thought "if only Claude Monet had painted entwined lovers atop just one of his usual pastoral haystacks in contented shades of iron oxide and colbalt turquoise.")

I do want to see Rust come to Ardino, and since it barely, almost, sort of, sputterlingly, has- maybe I should add "and BE EASY!"   I really think Arduino+Rust would make the world better.    I like C, but how much of the worlds computational security woes come from that code base?  Perfectly tallented C programmers write wonderful things that compile and run and still have hidden hordes of gremlins inside.   I really do hope the state of Rust on the Arduino platform changes soon... I'm not quite ready to jump in and swim yet.

I think I started this post in October 2018, as of December 2018 I found this link in RUST 2018 docs that has lots to offer on the subject.  https://rust-embedded.github.io/book/ - a whole book exists that's progress!    

https://techsparx.com/software-development/rust/rust-for-avr-arm-embedded.html - more links and a sense of progress

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>
« Rust's rand::distributions | Main | Ugh. CNN Reports Spin News. »