Introducing po-util: A handy script for installing and using the Particle Toolchain on Ubuntu-based Distros and OSX

Continuing the discussion from Toolchain Installer / Helper for Linux and OSX (I can't edit the post for some reason...)

Github All Releases Slack Status Donate Bitcoin GitHub issues GitHub stars Build Status Circle CI

Particle Offline Utility:

A handy script for installing and using the Particle Toolchain on Ubuntu-based distros and OSX.
This script downloads and installs: dfu-util, nodejs, gcc-arm-embedded, particle-cli, and the Particle Firmware source code.

Quick Install / Update

curl po-util.com/download | bash

Copy and paste this into your terminal.

Info

po-util Copyright (GPL) 2016  Nathan Robinson
This program comes with ABSOLUTELY NO WARRANTY.
Read more at http://bit.ly/po-util

Usage: po DEVICE_TYPE COMMAND DEVICE_NAME
       po DFU_COMMAND
       po install [full_install_path]

Commands:
  install      Download all of the tools needed for development.
               Requires sudo. You can optionally install to an
               alternate location by specifying [full_install_path].
               Ex.:
                   po install ~/particle

               By default, Firmware is installed in ~/github.

  build        Compile code in "firmware" subdirectory
  flash        Compile code and flash to device using dfu-util
  clean        Refresh all code
  init         Initialize a new po-util project
  patch        Apply system firmware patch to change baud rate
  update       Download latest firmware source code from Particle
  upgrade      Upgrade system firmware on device
  ota          Upload code Over The Air using particle-cli
  serial       Monitor a device's serial output (Close with CRTL-A +D)

DFU Commands:
  dfu         Quickly flash pre-compiled code
  dfu-open    Put device into DFU mode
  dfu-close   Get device out of DFU mode

Tips

The three most useful commands are build, flash and clean. Build compiles code in a "firmware" subdirectory and saves it as a .bin file in a "bin" subdirectory. Flash does the same, but uploads the compiled .bin to your device using dfu-util. Clean refreshes the Particle firmware source code.

A po-util project must be arranged like so:

po-util_project/
  └ firmware/
    └ main.cpp
    └ lib.cpp
    └ lib.h

Since po-util compiles .cpp and not .ino files, #include "application.h" must be present in your main.cpp file.

A blank main.cpp would look like:

#include "application.h"

void setup()
{

}

void loop()
{

}

One of the features of po-util is that it changes the baud rate to trigger dfu mode on Particle devices from 14400 to 19200. The reason for this is because Linux can not easily use 14400 as a baud rate. To enable this feature, connect your device and put it into DFU mode, and type:

po DEVICE_TYPE patch

# Replace DEVICE_TYPE with either "photon" or "electron"

Your computer will then recompile both parts of the Particle system firmware and flash each part to your device using dfu-util.

Why I created this script

I created this script because Particle does not currently have a script for easily installing the Particle Toolchain and depedencies on Linux and OSX. I created this script in order to help out other Particle users and to improve my bash scripting skills. It would be my dream come true if Particle added this script to its resources or gave it a shout out in its documentation. If that happened, I would feel very proud of myself for making a meaningful contribution.

Read more at po-util.com

A post was merged into an existing topic: Toolchain Installer / Helper for Linux and OSX