Because the idea for porting the Moddable SDK to the Pico arose in our community, we are committed to working with the community on the port. Moddable has taken the first steps to get a basic port working. The work to finish the port and make it easy for developers to work is being done in the Pico branch of our repository on GitHub. Once the port is stable and complete, we'll merge it to the main brach.
In terms of memory, storage space, and CPU power, the Pico falls somewhere between the ESP8266 and ESP32 MCUs already supported in the Moddable SDK. It uses an ARM instruction set, instead of Xtensa. The Pico has no radio, so Wi-Fi and Bluetooth are not directly supported. In addition to an extensive suite of standard IO capabilities, the Pico has a custom IO subsystem called PIO that offers unique capabilities that will be interesting to explore.
For our porting work, we are using the Raspberry Pi Pico development board.
The Pico SDK is the foundation for the Moddable SDK port to the RP2040 MCU. It provides a bare bones embedded API. It is focused on efficient access to hardware capabilities. The APIs appear to be unique to the Pico, with a few exceptions like the use of TinyUSB. Using these APIs has generally been straightforward, though applying them to more complex problems like multi-threading web workers is yet to be explored.
The initial port
The initial port of the Moddable SDK for the Pico is just enough to run the hello world and blink examples. That represents a great deal of work, as it also includes integration with the Moddable SDK build system. Here are some of the capabilities in the port:
- Builds on macOS and Linux
- Timer class
- Cryptographic classes
- Digital write (to blink an LED)
- Documentation on setting up build environment on macOS and Linux
The to-do list
Turning the initial port into a truly useful, complete port is a big project. Each individual developer has their own ideas and priorities to the port.
Here's a quick list of items to do to help start conversations.
- Digital input
- Digital monitor (interrupt notification on GPIO input change)
- Analog input
- PWM output
- SPI output (needed for displays)
- Audio (no example in Pico SDK?)
- Look at how to integrate PIO (RMT on ESP32 might be realistic starting point)
- Atomics in XS (not currently linking)
- Web Workers (to make use of the second CPU core)
- Flash read/write (to enable preferences and mods)
- Support for building on Windows
- Bulletproofing build / install on macOS, Windows, and Linux
- Improving set-up documentation
- Implementing TC53 IO -- ECMAScript Modules for Embedded Systems
- Eliminate need to always unplug Pico and push button to enter programming mode
- Serial interrupt support for debugger connection (lower latency debugging)
Some of these are straightforward projects that can be done by taking a look at how other ports work. Others, like PIO support, are open-ended explorations.
Earlier this month, Moddable shipped support for the ESP-IDF 4.2 after a month-long developer preview. During that time, the community provided bug reports, feedback, and improvements that helped make the final release better. We're excited to see how the Pico porting effort will benefit from community involvement from this early start.
Porting is a great way to learn. You'll learn about the Moddable SDK -- how it works and how it is organized -- and about the RP2040 MCU. We've set up a Porting Discussion on GitHub. Feel free to contribute to an existing discussion topic or start a new one.
The Pico branch is available now as part of the Moddable SDK. The instructions for getting started are in the repository.