153 points · by randomskk · 9y ago · 51 comments
But yeah, more options is even better.
- Oberon, http://www.astrobe.com/default.htm
- Java, http://www.microej.com/resources/supported-platforms/
- Pascal and Basic, https://www.mikroe.com/stm32/
Edit: and the real reason you don't want to do this is because the EEs and manufacturing engineers on your project will try to kill you. Two uCs means two codebases and two devices to program during production, plus extra testing, more complicated design, and more parts to place (uC, crystal, caps, etc)
If you're doing something truly cutting edge your competitors aren't better than you are so you can afford that second uC and more parts.
Most of engineering judgment is finding the point where the goal is ambitious enough to keep up with or pass the competition while conservative enough that it'll likely work, or at least you won't get sued.
Duplicating the microcontroller on a project where people spend all afternoon arguing about 10 cents on the BOM is not a welcome idea. Also, the most eye-opening required course I took as an undergrad was reliability engineering. After you learn to do the reliability math, adding several solder joints to the product purely out of laziness looks profoundly stupid. Neither idea makes you look good to the old grey-beards on the other side of the table at the design review.
Or the word 'never'. There are no absolutes! :)
Rust actually gives me some hope that we might see better low-level code portability between some of these microcontrollers.
In theory I could develop a project on a beefy TI microcontroller using higher-level Rust primitives/libraries and port it over to the cheapest microcontroller I can find that still fits my I/O budget/speed/memory/timer constraints. All that without having to use a RTOS or having to drastically re-write interrupt/timer code to whatever system the new controller uses.
Does Rust support Atmel AVR through LLVM yet?
See http://dylanmckay.io/blog/rust/avr/llvm/2017/02/09/safer-mic... for an overview; 4.0 has been merged, but see https://github.com/rust-lang/rust/issues/37609#issuecomment-...
It's not concurrency, though. It's asynchrony. Two things never happen at at the same time.
Modula I for the PDP-11 did do all this in 1979. In addition, it computed the worst-case stack for each task, so you were sure you couldn't run out of memory if enough preemption occurred. Today this is mostly an issue on very low-end machines, but this code is for machines like very low end ARM processors, where you might run out of stack. Some test fixture to force worst case stack use, with all the priorities stacked up, would be useful.
The embedded industry has proven to be very resistant to innovations and modern code-writing practices. Some platforms I coded for didn't even support/allow C99 standard. C++ is gaining some foothold (mbed, for example). Developers don't feel the urge to catch on with times, like in other industries. And yet, now they are expected to write secure IoT systems.
Hopefully Rust can demonstrate its worth and convert key industry specialists who would blog about it. Personally, I'm still waiting for perfect opportunity to apply it on medium-sized project before I fully commit (secretly I'm still rooting for Nim).
Those are opposing goals.
Is this changing now?
But at no time has UML tooling been the driving factor behind the industry's adoption or lack of adoption of a language.
The problem with C++ and other high-level languages has always been that it's hard to see how much a line of code costs. Incrementing a pointer to an array in C has a transparent, short runtime, compared to moving to the next element in a C++ collection which may accidentally invoke a dizzying indecipherable mess of template objects, overloaded operators, and STL dependencies. Or in other languages, you may need a large operating system and runtime to be loaded.
High level languages do handy magic things for you under the hood. If your engine bay is measured in terabytes of storage, gigabytes of RAM, gigaflops of computational power, hundreds of watts of electrical power, and seconds of acceptable interaction time, those magic things that let programmers build useful features faster are nice.
But when you're trying to get guaranteed responses in microseconds from milliwatts of electrical power in a few kilobytes of RAM, you're likely going to be hand-picking everything under the hood. No magic allowed.
But to answer your question, C++ is gaining a larger foothold in embedded if anything. More and more libraries are written in C++, and it's becoming more supported in the various toolchains.
From a very recent hackaday article - "Modern C++ allows us to write cleaner, more concise code, and make the code we write more reusable. The following are [...] new features of C++ that don’t add memory overhead, reduce speed, or increase size because they’re all handled by the compiler [...] after reading this you’ll be more aware of the newer features as we start to see them roll out in Arduino code."
http://hackaday.com/2017/05/05/using-modern-c-techniques-wit...
And also, because I was poking around their github today, here is Flybrix's source code, a lego-drone startup writing C++ on a Kinetis K-20 microcontroller (100 MHz ARM Cortex-M4). They use the teensy bootloader, which is why you see a mix of Arduino and C++ files
I'm curious how they determined FreeRTOS wasn't appropriate for their use cases?
https://news.ycombinator.com/item?id=14294408
So, the author learned from it, ported it to a safer language, and release the results. Although Ada/SPARK Ravenscar did embedded concurrency, the author certainly builds on modern methods for achieving similar (possibly better) results in Internet of Things. Good work. :)