japaric-archived / cu

Testing ground for the Copper book (http://japaric.github.io/copper/).
Apache License 2.0
58 stars 1 forks source link

Arduino and mbed / mbed OS usage? #30

Open polarathene opened 8 years ago

polarathene commented 8 years ago

I understand that cu is focused around freestanding / bare-metal development being very low level. Similar in the approach Zinc.rs is using? I really appreciate the project as a learning resource and the value that provides.

I was curious if you might consider including content for higher level embedded use with Rust. I've read about Rust being able to interface with C code, although Arduino is not quite C from what I've read and Rust presently lacks C++ FFI support, I have seen projects that are using the header files and calling some Arduino methods(I'm not aware of what limitations exist). I haven't come across the same with mbed or if mbed OS(ARMs RTOS?) makes Rust anymore possible to use with their platform.

Until Rust on embedded builds more of an ecosystem, it would be great to utilize the Arduino or mbed community libraries. If you have a good understanding of how to go about this and any advantage/limitations that you could share on the topic, that'd be fantastic :) I think a section at least on this would be helpful if this becomes a go to resource for embedded dev.

japaric commented 8 years ago

Similar in the approach Zinc.rs is using?

Yes.

I was curious if you might consider including content for higher level embedded use with Rust.

Yeah, I have planned a chapter about embedding Rust in a C framework. I'll use the Particle Photon framework as a example. The Photon framework is built on top of FreeRTOS.

Arduino is not quite C from what I've read and Rust presently lacks C++ FFI support

In principle, you can create a C API on top of the C++ API and use that. I'm not familiar with Arduino framework/API so I can't give more specific details. However, there is a problem with Arduino devices: Most devices have an AVR processor (the exception being the Arduino Due) and you can't compile Rust code for the AVR architecture (cf. http://japaric.github.io/copper/why-arm.html)

polarathene commented 8 years ago

@japaric thanks for the feedback :)

Particle Photon framework appears to already be working on Rust support? I could see more value from those larger platforms Arduino and mbed(of which I've found less information on with using Rust).

You're right about the AVR issue(I also have a Due), work is being done on an llvm backend and using Rust with it. I've read that progress is going well with just a few problems left. I've shared what I've come across while looking into embedded Rust and my quesions on this reddit r/rust/ thread. I'm not having too much luck finding Rust devs with the experience to answer questions there however..

japaric commented 8 years ago

Particle Photon framework appears to already be working on Rust support?

I forgot to link this repository https://github.com/japaric/photon -- that's part of the Rust support particle is working on.

I could see more value from those larger platforms Arduino and mbed

In principle, you can do the same thing I did with the photon (embedding Rust in the photon framework) with the Arduino and mbed. I don't have an Arduino to try the same thing, but I have been meaning to try zephyr for a while.

I also have a Due

This blog may be of interest then.