|The BBC Micro:bit Is An Mbed Device In C/C++|
|Written by Harry Fairhead|
|Thursday, 14 April 2016|
The Micro:bit is unique as an educational platform - easy to use and supported by easy languages, but what you might not have noticed is that it is built on top of the ARM mbed IoT software and now its supporting C/C++ libraries have been open sourced.
ARM announce mbed, an attempt to capture the IoT market, last year and made the software available recently. The idea is that you can install mbed on any of a large range of single board computers (SBC) running ARM Cortex-M chips. The usual way of using mbed is to connect the SBC to a PC via USB. This installs as a standard USB drive and any code that you drag and drop into the drive is loaded and run by the SBC.
The core development language is C/C++ and ARM provides a free-to-use web-based compiler. You sign up and start writing code. To compile it you just select the compile button. The compiler gives compile time errors and, while there is syntax highlighting, it is all a bit primitive if you are used to NetBeans or Visual Studio. If your program compiles then it is downloaded and you simply drag-and-drop the download to the SBC drive.
Of course the big problem is that this is slow and there are no real debugging facilities. You can set up a serial console on the PC and send degugging messages, but that's about it. There is no single step, no variable inspector and no breakpoints, conditional or otherwise. This makes debugging, traditionally a difficult thing to do on real time systems, even more difficult and time consuming.
You can see the basic online compiler in action in this video:
There is an option to compile the program using a local offline IDE, but the instructions on how to do so are off-puttingly complicated when all you want to do is get on with programming. The main reason is that mbed uses a new build system called Yotta and a module description system based on json files. This is completely non-standard and means you have to work very hard to get a good offline system that doesn't put you to additional work.
At the moment you can afford to ignore mbed and carry on using GCC or Arduino or whatever development system you have been using. However, this might be about to change.
The MicroPython online compiler is particularly bad as it will let you make syntax errors and you don't get to know about them until they run on the Micro:bit. What is worse, the runtime errors appear on the scrolling LED display and are difficult to read unless you install a serial console - something the documentation is not good at explaining.
To be thrown back to debugging by print statement is not good and for an educational tool you could say it is unforgivable.
However, Lancaster University has now open sourced the DAL and provided quite a lot of documentation, which makes it possible to program the Micro:bit as a generic mbed device in C/C++. This opens up new possibilities for both the Micro:bit and mbed.
As one million Micro:bits are now in the hands of 11 year olds, and perhaps more importantly all of the grown ups aiming to teach them programming, suddenly mbed has a huge potential user base. Add to this the fact that when the Micro:bit goes on sale to the IoT community mbed will almost certainly have a hit on its hands. Suddenly mbed no longer looks like a late starter but a big player.
The Micro:bit is a very capable IoT device - it has sufficient GPIO pins, AtoD, DtoA, I2C, SPI, PWM and so on to be interfaced to almost anything. Programming it in C/C++ means it can be fast and the operating system doesn't get in the way. There is no Linux lurking on the Micro:bit so realtime programming should be possible.
In short the Micro:bit looks like the first successful mbed device and with its availability suddenly Arduino and Raspberry Pi have competition. As an IoT device, the Micro:bit goes up against the Arduino directly. The Raspberry Pi isn't just an IoT device and there are times when having a full OS like Linux is a good thing. What is interesting is that in cases where the Pi would be used as an IoT device the Micro:bit has a lot going for it.
There are problems, however. The biggest problem is the way that mbed is only partly open source. Some important parts of it are kept under wraps by ARM. There is also the problem of the online nature of the development system. The support for the Micro:bit is also very patchy at the moment - it seems no one at ARM mbed has worked out that this is the most important device to pass their way and so lots of links don't work and the documentation is very poor.
Let's hope they wake up in time. In fact, let's hope they wake up to the fact that online compilation is silly when your users are about to number potential millions, not to mention the need for good debugging facilities. The Micro:bit needs an offline IDE that is easy to use.
or email your comment to: firstname.lastname@example.org
|Last Updated ( Thursday, 21 April 2016 )|