

Rust on the Arduino Due - kaeso
https://github.com/jensnockert/dueboot

======
exDM69
The 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
This 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
I'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/)

------
jnbiche
This 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
LLVM 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
I 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
Texas 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.

~~~
mindslight
The TI offerings look geared towards low power and are kind of anemic on the
high end with up to only 32kB ram and 256kB flash. ST/NXP/Atmel have parts
with over four times that (and the ST eval board is also only $15). I know you
can do a lot with a little (I used to design with pic16), but for higher level
languages without runtimes optimized for embedded (eg rust), I'd want all the
room I could get.

------
smilekzs
Quite 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
This 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
[http://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...

------
tcdowney
I'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
The 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)

------
cdcarter
So 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
I'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-.

------
kqr2
Since 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
Does anybody knows, would it be possible to use reference counting(and thus
build hard real time systems), maybe by splitting the library?

~~~
pcwalton
You can use the `Rc` or `RcMut` types in the standard library. They're just
smart pointers, like C++ `shared_ptr`.

~~~
hershel
Is it possible to use them in zero ? because ksr2's comments tells otherwise.

~~~
pcwalton
Nowadays you can just use libstd in no-runtime apps; you can choose whether to
start the runtime and if you're running on bare metal, just don't start it.

------
fzzzy
I was able to build and flash my Due with this, very cool. The possibilities
are really exciting!

------
zokier
I'd assume the libarm thingy is at least partially generated instead of being
handwritten?

