7 ms·
Rust on BBC micro:bit
- eyan 10y agoAs a Rust fan and electronics enthusiast, I find these kinds of projects awesome. Thank you for the write up and keep on hacking!
- tdicola 10y agoWould xargo help with the cross compiler setup? https://github.com/japaric/xargo https://github.com/japaric/xargo I've been meaning to look more at rust on ARM Cortex-M chips and recently saw tools like xargo that appear to make it a bit less tedious to setup.
- SimonSapin 10y agoLooks like it would help get libcore for your target more easily, yes. Still, I'd like similar functionality to get in standard Cargo eventually.
- Ericson2314 10y agoThis was quite entertaining! Having worked through many such build systems adventures myself, it's a genre I do appreciate. As always, the story is more captivating than the end result. -- Also, yay! a shout out to my RFC 1133.
- m_eiman 10y agoNB, Rust RFC 1133 "Make Cargo aware of standard library dependencies" isn't the same as IETF RFC 1133 "Routing between the NSFNET and the DDN". I first searched for just "rfc 1133" and the matches didn't really make much sense :] Rust RFC 1133: https://github.com/rust-lang/rfcs/pull/1133 https://github.com/rust-lang/rfcs/pull/1133
- Ericson2314 10y agoHmm, I feel obligated to read up on routing between the NSFNET and the DDN now.
- twic 10y agoThis is by now a familiar sight: #[lang = "eh_personality"] extern fn eh_personality() {} #[lang = "panic_fmt"] extern fn panic_fmt() -> ! { loop {} } But it's a little unsatisfying. What does eh_personality actually do, and how would you write a 'real' implementation? I can guess what panic_fmt is for, but exactly what is it supposed to do, and how would you write a 'real' implementation?
- Ericson2314 10y ago"exceptional handling personality": ask the DWARF people? It should be removable with aborting panic.
- SimonSapin 10y agoI now have a "more real" panic_fmt in the repository: #[lang = "panic_fmt"] extern fn panic_fmt(details: ::core::fmt::Arguments, file: &'static str, line: u32) -> ! { println!("Panic at {}:{}, {}", file, line, details); let row_2 = ::gpio::Pin::output(::pins::ROW_2); let col_3 = ::gpio::Pin::output(::pins::COL_3); row_2.set_high(); loop { col_3.set_low(); ::busy_loop::wait_approx_ms(5); col_3.set_high(); ::busy_loop::wait_approx_ms(200); } } Note that println! is a macro I defined myself, it writes to the serial port. I still don’t know about eh_personality, though.
- jdub 10y agoNow that's a cute panic_fmt. :-)
- jdub 10y agowrt eh_personality, there's a good short answer with a link to a good (very!) long answer here: http://stackoverflow.com/questions/16597350/what-is-an-exception-handling-personality-function http://stackoverflow.com/questions/16597350/what-is-an-excep...
- zokier 10y agoSo basically if I got it right, non-terminating panic_fmt and empty eh_personality means that we don't get stack unwinding at all, which also means that destructors don't get called. That could be fairly important for RAII heavy code.
- SeanDav 10y ago> "Rust on BBC micro:bit" OT: I just did a double-take. For a moment there, when I saw the title, I thought of a rusty computer part.
- lathiat 10y agoglad I wasn't the only one.
- clort 10y agoThese micro:bit look pretty interesting from an embedded controller perspective - does anybody have any useful comparisons between them and others, eg Arduino etc? I've been working on a project where I will end up having to make a simple stepper motor to drive an analogue clock and I think I can use this to control it (advance x% of turn every minute, currently x=50) though I was initially thinking of a small PICAXE circuit as we have some equipment at the school I work at. I like the thought that I could access it over BLE though, and that it could be programmed to handle DST automatically and even drive a few LEDs for good measure Also, what is the power consumption? As my project involves a clock, I'm thinking it needs to last a while on some batteries, though at least its big enough that I can pack a few in.
- TickleSteve 10y agoJust get a bog-standard STM32 board for very-cheap.... don't bother with one of these. e.g. A standard STM32F103 board can be had for around $3.
- clort 10y agoHm, thanks.. I will look closer at this kind of thing over my holidays. That looks like I can program it over RS-232 and operates at battery voltages, which is really what I require.
- petra 10y agoDid he mention he integrated this with the mbed ? i though that was hard, because of c++. But if he did so, that would be really valuable - it's a good solution for the problems of portability and software support , mnajor issues for embedded developers.
- SimonSapin 10y agoYes, I've had Rust code and C++/mbed code in the same program. But C++ is still an issue, I wrote a C wrapper for the one C++ method I was using. Doing so for all of mbed would be very tedious and fragile. Servo's fork of rust-bindgen https://github.com/servo/rust-bindgen https://github.com/servo/rust-bindgen has some C++ support and might be able to generate bindings for all(?) of mbed (at least for a given hardware configuration), but I haven't tried.
- eggy 10y agoVery cool, and very persistent. Good job! I can see myself losing a month on something like this. <rant> Now, I like the tech and hacker side of it, but it made me think again of how complicated modern hardware and software have become compared to staying with plain C, not even C++. This is not wholly due to more complicated hardware, but so many people building stuff without going back to first principles. I think the Rust crowd are doing their homework here though. I understand the benefits of Rust, since I am learning it at the moment, but I guess at my age it is a harder sell for something like this micro. It is so easy to just drop into C for small micros. The BBC micro:bit has a C/C++ interface, of which I bet the C interface is cake. It's small enought that all a good programmer has to do is dot their 'i's and cross their 't's anyway (or they should). </rant>
- StavrosK 10y agoIt's become more complicated because C is much more cumbersome to write than a higher-level language, so everyone prefers the latter. If I'm working on a project for fun on my spare time, I don't want to spend an hour fighting the compiler figuring out why array bounds are being weird, or why the compiler is complaining about the type, or whatever. Python is much more do-what-I-mean, for example, and it's much more appealing to me when I want to write something quickly. I've tried other languages and, with the exception of Rust, I always feel like development shouldn't have to be this yak-shavy.
- yoklov 10y agoI've written a good amount of rust, and a ton of C/C++, and, well, the compiler complaining about the type, or, well, anything really, is far more likely in Rust than C or C++