Go Down

Topic: AUniter command line and continuous integration tools, extending Arduino IDE (Read 175 times) previous topic - next topic

bxparks

I want to announce a set of command line tools that I created starting about 4 months ago. The package is called AUniter, and here is the introductory summary from its README.md:

"These are command line tools to easily build and upload multiple Arduino programs for multiple microcontroller boards, validate unit tests written in AUnit, and integrate with a locally hosted Jenkins continuous integration (CI) system. A single command can compile and upload multiple programs for multiple boards. This automation capability is fully utilized when running unit tests across multiple target boards. A configuration file in INI file format allows users to define short board aliases for the fully qualified board names (fqbn) which can be awkwardly long for some boards (e.g. ESP8266 or ESP32). Users can define target Environments in the configuration file corresponding to specific hardware configurations described by its board alias and other parameters such as optional C preprocessor macros."

The core auniter.sh script is a giant shell wrapper around the Arduino IDE built in command line functionality, along with some helper Python and shell scripts. I did not know about the Arduino-CLI tool until recently. After Arduino-CLI is stabilized and released, it might be possible to make AUniter use Arduino-CLI directly instead of the Arduino IDE.

The AUniter tools currently work only under Linux. (MacOS might be possible. Windows probably not, but might be possible using Windows Subsystem for Linux.) It supports all boards and libraries supported by the Arduino IDE itself (except for Teensyduino due to the fact that there does not seem to be a headless mode for Teensy boards.)

Here are some examples of the commands that you can use:

  • $ auniter envs - list the environments configured in the auniter.ini config file
  • $ auniter ports - list the available serial ports and devices
  • $ auniter verify nano Blink.ino - verify (compile) Blink.ino using the env:nano environment
  • $ auniter verify nano,esp8266,esp32 Blink.ino - verify Blink.ino on 3 target environments (env:nano, env:esp8266, env:esp32)
  • $ auniter upload nano:/dev/ttyUSB0 Blink.ino - upload Blink.ino to the env:nano target environment connected to /dev/ttyUSB0
  • $ auniter test nano:USB0 BlinkTest.ino - compile and upload BlinkTest.ino using the env:nano environment, upload it to the board at /dev/ttyUSB0, then validate the output of the AUnit unit test
  • $ auniter test nano:USB0,esp8266:USB1,esp32:USB2 BlinkTest/ ClockTest/ - upload and verify the 2 unit tests (BlinkTest/BlinkTest.ino, ClockTest/ClockTest.ino) on 3 target environments (env:nano, env:esp8266, env:esp32) located at the 3 respective ports (/dev/ttyUSB0, /dev/ttyUSB1, /dev/ttyUSB2)
  • $ auniter upmon nano:USB0 Blink.ino - upload the Blink.ino sketch and monitor the serial port using a user-configurable terminal program (e.g. picocom) on /dev/ttyUSB0


The shell script is configured by an INI file (normally in your home directory $HOME/.auniter.ini) that looks like this:

[auniter]
  monitor = picocom -b $baud --omap crlf --imap lfcrlf --echo $port

[boards]
  uno = arduino:avr:uno
  nano = arduino:avr:nano:cpu=atmega328old
  leonardo = arduino:avr:leonardo
  promicro16 = SparkFun:avr:promicro:cpu=16MHzatmega32U4
  mega = arduino:avr:mega:cpu=atmega2560
  nodemcuv2 = esp8266:esp8266:nodemcuv2:CpuFrequency=80,FlashSize=4M1M,LwIPVariant=v2mss536,Debug=Disabled,DebugLevel=None____,FlashErase=none,UploadSpeed=921600
  esp32 = esp32:esp32:esp32:PartitionScheme=default,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none

[env:uno]
  board = uno
  preprocessor = -DAUNITER_UNO

[env:nano]
  board = nano
  preprocessor = -DAUNITER_NANO -DAUNITER_LEFT_BUTTON=2 -DAUNITER_RIGHT_BUTTON=3

[env:micro]
  board = promicro16
  locking = false
  preprocessor = -DAUNITER_MICRO -DAUNITER_BUTTON=3


There are a number of other command line solutions available in addition to Arduino-CLI, such as the following, but they didn't do what I wanted, and the AUniter/README.md explains why:


The AUniter/jenkins integration with a locally hosted Jenkins instance is a bit complicated (as the jenkins/README.md will illustrate). But once set up, it works extremely well. Every time I check in some code, the continuous build automatically fires up, and verifies that everything compiles properly, and runs and validates the unit tests, giving a summary at the end of the run. A locally hosted Jenkins instance means that you don't have to worry about security.

The AUniter/BadgeService is an experimental feature that allows the status of the local Jenkins server to appear as a badge/shield on GitHub (or anywhere else). It looks pretty, but the utility might be marginal. Unfortunately, it might be even more complicated to set up than the Jenkins service.

Anyway, if this package is useful to you, that's great. It's my contribution back to the community. I've been using AUniter and the Arduino IDE together for about 4 months and they work really well for me. If you have comments or questions, you can contact me through the GitHub project page, or post here.

Brian


Go Up