In order to deliver a high quality low cost board that works with Arduino, we're using a modern chip called an ARM processor to run Flutter's code. Most of the Arduino boards in existence use an 8-bit processor, called an AVR, which is akin to the 8-bit processor in a Sega Genesis or original Nintendo game console. Updated versions of these processors are still in use every day, appreciated for their low cost and ease of programming. An alarm clock or toaster will have a processor in it to handle the button presses and timing, but it doesn't need to be fancy. As technology has progressed however, a more advanced 32-bit processor called ARM has gained widespread use as the core of every modern cell phone. These 32-bit ARM processors offer many performance advantages over 8-bit architechtures, and they are being used in such volumes now that their prices have been pushed lower than those of older 8-bit processors. As a response to this changing landscape, Arduino llc announced the ARM-powered "Arduino Due" in 2012. The Due is similar to the older Arduino Mega, but provides 5x the program memory, 8x the RAM, and over 5x-20x the processing power, all thanks to it's capable 32-bit ARM processor. That power comes at a cost however - all new code needed to be written to support the new processor architechure. Since before the release of the Due, Arduino and a team of open source developers have been working on integrating this processor into the Arduino programming environment, with their code shared publicly on GitHub. Aside from some problems with 3rd party libraries that were only written for 8-bit processors, the Arduino Due codebase is now largely complete, supporting all normal Arduino functions as well as many new functions provided by this much more capable new chip architecture.
When we first made the Flutter prototypes, we were thrilled with our new capability to run Arduino code on a compact wireless board. Being able to talk directly to a remote project over a kilometer away gives you incredible freedom! But with the chips we were using, we didn't have much memory, and the applications we could write were very limited.
To get prototypes built quickly, we based our prototypes on the Sparkfun Pro Micro, one of the few Arduino-compatible boards that has USB built into the main chip. Unfortunately, the Pro Micro uses a traditional 8-bit processor with just 2.5kb of RAM. Our Flutter library and test code was using 1kb-2kb of RAM, leaving just 500 bytes for user code. That's not a lot of memory, and since it can be hard to know exactly how much you're using, it was easy to run out. Running out is bad - at best crashing your program, or else causing bizzare behavior. What's worse, the radio chip needs to operate at 3.3 volts, and the processor in the Pro Micro can only run at 8 MHz at that voltage - half the speed of most Arduino boards. It was clear that this processor was not going to be great at running a radio stack and your user applications with specs like that.
We needed to see if there was anything better. Luckily we have experience with ARM processors, having built many projects in the past with them. We knew Arduino had been ported to run on the 32-bit Due board but its massive processor costs $13 apiece! You can't sell a low cost board with a $13 processor, as evidenced by the $50 price tag of the Arduino Due. Fortunately the chip in the Arduino Due has some low cost cousins. Atmel, who makes these processors, sells several related lines of chips based on the Cortex M3 Architecture in the Due. Looking at their offerings, we found a processor in that family that still features USB, but costs less than three dollars. This is actually cheaper than the 8-bit processor on our prototypes, but features over 6x the RAM, 2x the program space, and 8x-24x the processing power!
There was just one small issue: no one had ever ported Arduino to this processor. In fact, no one seems to have ported Arduino to any ARM processor other than the one in the Due. We spent a few weeks before the campaign checking this out, and eventually discovered that we could do it. The chip we chose, the Atmel Sam3s1, has essentially the same core as that of the Sam3x8 in the Due, and the Arduino code actually already contains the basic definitions for most chips in the Sam3 family. It was just a matter of defining our board in code and then fixing any issues caused by the slightly different definitions for this chip. We put the work away while we finished the campaign and designed new hardware, but were finally able to pick this work back up in February. There's zero documentation on how the porting would need to happen, as the developers working on this have been busy enough just getting the code working over the past two years. We spent a lot of time looking through the code, following it line by line to see how it all worked, and asking questions in the Arduino Developers google group.
These processors are much more complex than their older 8-bit predecessors. The manual for the chip on our original prototypes is 433 pages. That may seem like a lot but it's nothing compared to the manuals for ARM chips. The manual for Flutter's small ARM processor is over 1000 pages, and the manual for the processor in the Due, which we needed to consult when decoding the existing Arduino code, is over 1400 pages. It was slow to start but eventually we started to get an understanding for how these new processors integrate into the Arduino code base. After a few weeks of hacking we got to the point where we could compile Arduino code and blink the main LED from a standard Arduino sketch. More recently we've gotten other parts of the chip working with Arduino, including the onboard serial port and the SPI port, which talks to the radio. At this point, we only have a few more pieces of code to port or write until we have full Arduino functionality on the boards. The biggest piece not yet finished is USB, which needs all new code written as far as we can tell. Getting this code running will wrap up one of the biggest hurdles of the project, and moving past it means we will soon be able to bring up our pre-campaign libraries on our new hardware. Our dream of an Arduino-compatible wireless board you can actually use will soon become a reality!
We're going to finish the last leg of porting with the help of whatever friendly devs want to give us a hand, so the next step is to get a bigger batch of hardware going with a few minor changes made. We'll have that back in a few weeks, and then it will be all about finishing the code, getting this board certified, and shipping out hardware!
To get a look at actual code involved in the Arduino porting and to get more information on how to port code to a new ARM processor, check out the code and porting readme on Taylor's personal github here:
https://github.com/tlalexander/Arduino_Sam3s/tree/master/hardware
The code will live there until we integrate Flutter's original libraries, and then we'll host it on Flutter's Github.
To see what needs to be done and if you can help, join the discussion on our subreddit here:
http://www.reddit.com/r/Flutter/comments/219bwc/flutter_developers_unite/