"Portduino" a new platform/framework to allow running 'arduino' code on Linux, feedback requested

Hi ya’ll,

So for the last several months we’ve been using a project we call ‘portduino’ to allow us to run a pretty sizable/real ‘arduino’ project on Linux. Though it is still definitely young/alpha I think it is now kinda ready for other users/developers. So if this looks like it might be useful for you we’d love your feedback. We are also happy to eventually donate it to the platformio project if there is interest.

If you have questions or comments we’d love to see them in this thread.

Excerpt from the README:

Portduino

This is an attempt to port the Arduino API so that it can run on top of Linux (and other desktop operating systems). This is to facilitate the following use-cases:

  • You can run code originally intended to arduino like environments (nrf52, esp32, avr etc…) without modification as ‘user-space’ applications. Those applications can talk to real SPI, I2C, GPIO, serial, wifi on your linux device using the ‘standard’ arduino APIs. Many libraries/projects from platformio ‘just work’. Though of course the underlying OS is not an RTOS and hard-real-time constraints may get a bit fuzzy. :wink:

  • You can debug/develop on a desktop OS where often the debugging environment is more forgiving and the compile/load/debug workflow is quite fast.

  • You can run with all devices simulated (for automated integration testing or simulation) or some/all of the ‘devices’ connected to real hardware.

We’ve been using this project successfully on a fairly sizable & popular platformio project (meshtastic) for the last several months. We use it both for our continuous integration tests (where we run our device software through crude simulated tests in github actions) and to support Meshtastic on linux for the Pine64 Lora USB dongle.

Description

Someone wanted Meshtastic for a new linux based tablet, so we made a new new thing (which might be useful for other projects).

We implement the ‘ArduinoCore’ libs/API layer and support the following device level access from user-space regular apps:

  • SPI (via simulation or the linux spidev device)
  • Interrupt handlers (they won’t know they are actually in userspace)
  • GPIO control (via simulation or the linux gpio device)
  • WiFi (via the arduino Wifi API, but via regular linux IPV4 functionality)
  • Serial (but actually being done through any Unix file descriptor - so could be pipes/files/devices)
  • I2C (not yet implemented in alpha, if you want this speak up)
  • Any of the above can be implemented by particular ‘Drivers’ - so either the mainboard kernel-space SPI/I2C controller or via external USB to SPI/I2C/GPIO adapters

How to use

This project is currently very ‘alpha’ mostly to judge community interest. Once it is a bit more mature (if there is interest) I’m happy to send in pull-requests to ‘platform-native’ which add portuino as an optional framework. If you would like to try it now, you should only need to add something like the following three lines

to your platformio.ini in the project you want to build…

Project github:

4 Likes