8 ms·
Rust on the Arduino Due
- exDM69 13y agoThe ability to run with a small runtime system on bare metal, microcontrollers and such makes Rust, in my opinion, one of the most interesting new languages out there right now. Native code with a lean and mean runtime system has a lot of advantages over bytecode based virtual machines and slow interpreters.
- namespace 13y agoThis is an amazing feat with Rust being a modern open alternative to C! So far many have tried and failed. Rust developers have learned well and Rust seems to be on right track.
- titzer 13y agoI've been working on this problem a while ago, but Virgil II didn't get much traction outside of a couple academic projects. It's here though: http://compilers.cs.ucla.edu/virgil/ http://compilers.cs.ucla.edu/virgil/
- aray 13y agoJavascript is in a similar situation with node.js ported to a Cortex-M3 ARM microcontroller (similar to the Due) http://technical.io/ http://technical.io/ I've been working off and on porting the go runtime to a microcontroller, but still finicking with segmented stack support.
- exDM69 13y ago> Javascript is in a similar situation with node.js ported to a Cortex-M3 ARM microcontroller Well, yes and no. Yes, there are JavaScript environments ported to different platforms, including microcontrollers. But no, JavaScript is not compiled to native code ahead of time nor does it run without a big runtime system. While there is some technical trickery involved in getting JavaScript running on different platforms, I find the new LLVM-based languages that run on bare metal much more interesting. Due to its nature, even the best of JavaScript implementations waste quite a lot of resources compared to native code. While computers are fast enough and have enough memory not to notice the difference, it's still consuming more battery power and producing more heat than executing native code. And it's power and thermals that have been the limiting factor of computational power for the past decade.
- smilekzs 13y agoQuite surprised. Exactly a year ago I was in hope that someone do something similar for Golang, but soon realized that it's impossible because Golang relies heavily on GC. Now this seems quite interesting.
- pjmlp 13y agoThis is not true. There are companies selling development kits with GC enabled system programming languages, like Oberon, for embedded development. http://www.astrobe.com/default.htm http://www.astrobe.com/default.htm Granted, ARM Cortex-M3 and NXP LPC2000 microcontrollers are more powerful than typical Arduino hardware, but one does not need to target all possible hardware out there.
- smilekzs 13y agohttp://technical.io/ http://technical.io/ even managed to run Node.JS on a Cortex-M3, but in the deeply-embedded world where performance/$ and real-time constraints matters, having a always-GC system like Golang (especially considering it's designed for cached cores) doesn't sound very promising. However I did look Golang because it makes concurrency (quite important in embedded programming) easy. Now with Rust...
- jnbiche 13y agoThis is great -- I'm very pleased to see a challenger to C/++ step up in this space. And I'm starting to get really interested in Rust. It would be great to have a safer language to use in the place of C/++, particularly since the world seems to have decided to disregard Ada. That said, it's important to note that this is not Rust on an AVR Arduino -- it's the Due, which sports an Arm Cortex M3. Targeting AVR which probably be much more difficult (at least that's what I've read). So you won't be able to get this running on your Uno.
- jensnockert 13y agoLLVM doesn't target the AVR processors, and while there is a avr-llvm backend, I think it is still very early in the development cycle. It is quite possible that you could get it to work with some effort, but it is a lot more complex than targeting an ARM microcontroller. With awesome boards like the Teensy 3.0 (Cortex M4, http://www.pjrc.com/store/teensy3.html http://www.pjrc.com/store/teensy3.html) available on the cheap, not being on AVR isn't the huge disadvantage it once was. At least if you don't count the hardware people already have.
- jnbiche 13y agoI agree, there's are some awesome Arm Cortex chips out on the market now, for not much money at all. And I agree it's not a huge disadvantage not being on AVR, I just wanted to make the point that Rust doesn't run on traditional Arduinos, since that's what most people would assume reading the headline.
- nileshtrivedi 13y agoTexas Instruments practically gives away their development boards. Here is their Stellaris Launchpad board with ARM Cortex-M4F-based MCU for just 8$! Much cheaper than even AVR arduinos! https://estore.ti.com/Stellaris-LaunchPad.aspx https://estore.ti.com/Stellaris-LaunchPad.aspx What's more, these days you can even use the Arduino IDE for development on these boards. The Energia project has ported Wiring and Arduino IDE for TI boards. If I wasn't such a minimalist, I would get one (or two) in a heartbeat! Edited: Forgot to paste the link.
- tcdowney 13y agoI'm more excited to see that the project is based off one for the STM32F4. I've got one of those lying around and I'm looking forward to trying this out. :)
- diydsp 13y agoThe stm32f4 RULES. If you haven't got enough info on it, i'd just like to plug the subreddit I created specifically for the stm32f4: http://reddit.com/r/stm32f4 http://reddit.com/r/stm32f4
- zokier 13y agoI'd assume the libarm thingy is at least partially generated instead of being handwritten?
- cdcarter 13y agoSo far you're still stuck calling Wiring methods <digitalWrite, pinMode, etc...> from directly extern'd C. But a quick wrapper around the basic functions shouldn't be too hard and allows for a more rust-y (rust-ful?) experience.
- hcal 13y agoI'm going to go with rustic. I think the phrase -a more rustic experience- has a much better sound and connotation than -a more rusty experience-.
- deleted 13y ago[deleted]
- jensnockert 13y agoYeah, throwing out the Wiring methods and implementing more idiomatic ones in Rust shouldn't be hard. I wrote it during an after work hackathon, so I didn't really have time to make it both working and nice unfortunately.
- kqr2 13y agoSince this builds on zero.rs, there are some limitations. https://github.com/pcwalton/zero.rs https://github.com/pcwalton/zero.rs Garbage collection, tasks, and failure will not work. All the other language features, including unique pointers, references, and closures do work, so programs such as sprocketnes that do not use garbage collection should be fine. The Rust standard library cannot be used in this mode, but splitting out the Rust standard library into a portion that can be used in freestanding mode would be an interesting and valuable project (IMO).
- hershel 13y agoDoes anybody knows, would it be possible to use reference counting(and thus build hard real time systems), maybe by splitting the library?
- pcwalton 13y agoYou can use the `Rc` or `RcMut` types in the standard library. They're just smart pointers, like C++ `shared_ptr`.
- cmrx64 13y agoBut one can implement those, they are language items.
- fzzzy 13y agoI was able to build and flash my Due with this, very cool. The possibilities are really exciting!