Particle CLI Boilerplate - hope this is useful

Hey all,

I’ve been building a lot of Particle projects recently on the command line rather than using the cloud IDE, so I figured I’d share my boilerplate app template for new Particle projects:

The web IDE is awesome, but there are many situations where it is more convenient to use your desktop text editor, or to pull in libraries and other source code you already have on your computer.

Some features:

  • Organize your code however you like in the src folder
  • Include libraries as git submodules in the lib folder
  • Build with make
  • Install via USB (with auto switch to DFU mode) with make install-usb
  • Install via the cloud with make install

Would love any feedback, comments or PRs!

- j

2 Likes

Cool!

Though flashing via DFU and Cloud is already supported by the firmware makefile itself :wink:

Of course this separates the user firmware and the base firmware which is pretty useful.

1 Like

5 posts were split to a new topic: Update Electron before deploying to my users?

Since building using the firmware makefile requires a ton of steps, and Particle is meant to be a great platform for beginners, I built this to avoid having to pull down the firmware repo and install all the dependencies.

I’m hoping that one day Particle will come to the awesome PlatformIO to make this process much easier in future.

@loopj This sounds interesting.

I have attempted to build locally by using a automated installer Toolchain for Windows Installer

Using that installer one or 2 of the programs that are part of the whole package of programs has a error and did not install which leaves me having to install it properly manually which I have not done yet.

I’m looking for the easiest way to compile locally to use the latest firmware that is not official firmware yet. There is a Sleep function bug fix that I want to test out and building locally is the only way to do it. I also want to be able to setup Webhooks.

So what your sharing sounds like a easier path to build locally.

Pardon my ignorance at this point but will what your offering allow me to build locally without all the programs that the Auto installer here is trying to install? Toolchain for Windows Installer

Any advice is appreciated :smile:

@RWB, the tool uses the Particle CLI so there is no “local” compiling since the CLI uses the Cloud compile servers. For true local compiling, you still need to install a local toolchain.

1 Like

@loopj

I like to have true local compiling and flashing of the firmware via USB. Also I like a debugger.

In PlatformIO I am able to make a custom_boards.json and put it in .platformio/boards.

At this time I have the following inside the custom_boards.json:

{
“photon”:
{
“build”:
{
“core”: “stm32”,
“extra_flags”: “-DSTM32F2XX”,
“f_cpu”: “120000000L”,
“cpu”: “cortex-m3”,
“mcu”: “stm32f205rgyy6”
},
“frameworks”: [],
“name”: “Photon”,
“platform”: “ststm32”,
“upload”:
{
“maximum_ram_size”: 131072,
“maximum_size”: 1048576
},
“url”: “https://docs.particle.io/datasheets/photon-datasheet/”,
“vendor”: “Particle”
}
}

It automatically installs the toolchain for the ARM, probably need to add some stuff to automatically install dfu-util. Now I need to know what the absolute minimum source is to build and flash it in the photon.

How do you autoswitch to DFU mode? I noticed this in the make file, how does it work?

enter-dfu-mode: ## Enter DFU mode on the attached USB device
-stty -f /dev/tty.usbmodem1411 14400

I saw that the particle CLI is using the dfu-util to flash the code.
see: https://github.com/spark/particle-cli/blob/master/lib/dfu.js at line 129 writeDfu.

Any suggestion to make this work?

A little update

{
“photon”:
{
“build”:
{
“core”: “stm32”,
“extra_flags”: “-DSTM32F2 -DSTM32F2XX -DSTM32F205xx”,
“f_cpu”: “120000000L”,
“ldscript”: “photon_user.ld”,
“cpu”: “cortex-m3”,
“mcu”: “stm32f205rgyy6”,
“variant”: “stm32f205xx”
},
“frameworks”: [“cmsis”],
“name”: “Photon”,
“platform”: “ststm32”,
“upload”:
{
“maximum_ram_size”: 131072,
“maximum_size”: 1048576
},
“url”: “https://docs.particle.io/datasheets/photon-datasheet/”,
“vendor”: “Particle”
}
}

I need a correct linker file but the linker file are deeply nested for the photon so it is not clear what settings I need.