PlatformIO notes
Contents
PlatformIO notes¶
Notes for using the PlatformIO CLI.
Table of Contents¶
Configuring PlatformIO ¶
I will probably end up making another document on using PlatformIO, but for the sake of getting started, PlatformIO may be installed with
OSX:
brew install platformio
Linux:
sudo python -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/develop/scripts/get-platformio.py)"
Getting started¶
All of the supported micro-controller boards can be listed using
platformio boards
Narrowing the search options, to find, e.g. the Atmel AVR MCUs, can be achieved with
platform boards atmelavr
I’m using the Elegoo Uno MC, so will use the appropriate configuration
uno ATMEGA328P 16MHz 31.50KB 2KB Arduino Uno
The appropriate development environment is then created using
mkdir dev-env
cd dev-env
platformio init --board uno
Note that more than one board can be specified, by using additional --board
flags. The output of the init
command initializes the environment
The current working directory /Users/minerva/Developer/MCU/uno-test will be used for the project.
The next files/directories have been created in /Users/minerva/Developer/MCU/uno-test
include - Put project header files here
lib - Put here project specific (private) libraries
src - Put project source files here
platformio.ini - Project Configuration File
Next we create src/main.cpp
, and include our MCU source code to be flashed to the unit.
platformio run -t upload
PlatformIO comes with multiple different target and environment flags
platformio run
: Process all environments specified inplatformio.ini
platformio run -t upload
: Build project and upload firmware to the devicesplatformio run -t clean
: Clean project (delete compiled objects)platformio run -e uno
: Process only theuno
environment
Serial communication¶
Serial communication with the MCU device is packaged into PlatformIO. We can monitor the MCU with
platformio device monitor -b [baudrate]
USB device debugging on OSX¶
It can be a little bit tentative sometimes to discover the right USB port on OSX. The command
system_profiler SPUSBDataType
will help indicate whether your device is discoverable or not. From experience, unplugging and pluggin the device back in can help a lot. Another useful thing to monitor are the
ls /dev/tty*
ls /dev/cu.*
outputs.
Distribution¶
PlatformIO can also act as a distribution tool if the environments are correctly defined.
Specifying dependencies¶
We can specify the dependencies for a specific environment, e.g. [env:uno]
with
lib_deps =
arduino
SomePackageName
or for all environments under the [common_env_data]
section. Dependencies are automatically installed when the environment is run.
More information can be seen here in the PlatformIO Docs.
Unit testing¶
TODO
Build flags¶
TODO