10/27/2014– Kevin Mehall
Our users love Tessel for the ease of getting started. This is especially apparent at hackathons and other meetups we’ve held for people to try Tessel. A first-time user can go from zero to something quite impressive in only a few hours. Many customers have been asking about their next steps once they build a prototype – Tessel can’t just be a device for winning hackathons. A good platform needs to scale as your project turns into a product and help you win in the marketplace too.
Fractal is a system design tool for microcontroller firmware and hardware. For Tessel prototypes, Fractal will improve IO performance and provide better debug tools. Once your prototype works, and you want smaller, cheaper, and lower-power boards in quantity, Fractal will help you optimize your system design. It’ll help you choose the right parts and put together reference schematics and circuit board layouts as a starting point for your own hardware.
Fractal adds Components, bundles of code for a discrete piece of your firmware, like an I2C controller, accelerometer driver, or JS VM containing your domain logic. Components have statically-defined, asynchronous, language-agnostic interfaces, and the Fractal compiler will be able to automatically generate cross-language bindings, so you don’t have to write them manually. This makes it easier to use the right language for each piece and phase of your project, be it prototyping or realtime control.
The right language isn’t always JS or C. I’m enjoying Rust, and think it makes an ideal language for programming microcontrollers. Rust is a new language from Mozilla that combines high-level expressiveness and safety with low-level performance, size, and closeness to hardware. It’s a new entry into the systems programming space that has been dominated by C for decades.
I’m also working on Signalspec, a domain-specific language for modeling IO protocols using regex-like definitions. Signalspec is a dedicated description language to abstractly define and then implement the state machines used to communicate with sensors and other chips. It saves you from writing asynchronous state machines by hand, a messy, error-prone process in existing imperative languages.
Because of the cross-language Component interfaces that abstract the underlying hardware, porting between languages and between hardware platforms isn’t a full-system rewrite. Start by prototyping your domain logic in JS on Tessel, then port it to Rust and fit it on a $2 Cortex M0 part. Fractal will make such a port not only feasible, but easy and elegant.
Tessel brings a few aspects of Node / JS to embedded development that will become a broader part of Fractal and improve the platform for all languages:
Components involve a change in how code gets deployed to your Tessel. Right now, you normally download the firmware from us pre-compiled, and then
tessel run or
The ease of installing Tessel module drivers is important piece of the Tessel user experience, and will guide the design of the Component distribution story.
npm will obviously remain the way to install pure-JS packages from the Node ecosystem within a JS component.
There’s one convention in JS that is actually more like how hardware works than most other languages: events. Hardware interrupts wake up the CPU and run an interrupt handler function on hardware events like button presses, SPI completions, and UART received bytes. Sounds kind of like a JS async callback, right?
An OS kernel can be thought of as an interrupts-to-threads adapter. To achieve asynchronous events within this threaded model, Node uses
libuv, which can be thought of as a threads-to-events adaptor. On Tessel, rather than going from interrupts to threads and back again, hardware interrupts enqueue events directly onto the JS event queue.
Fractal components add more structure to this asynchronous call / callback model, and use it throughout every layer of the system. Explicitly defining the beginning and end of IO actions as events saves power by spending more time in sleep mode, and saves RAM by avoiding the use of multiple stacks for threads.
We’re just getting started developing Fractal. For more details, check out our preliminary documentation and let us know what you think. Sound like something you want to work on? We’ll be developing Fractal in the open on GitHub, and we’re hiring.