Photon OSX local build setup notes on 20150531

I’ve been setting up a local build environment on a Mac. Here are some problems with the current documentation and their solutions.

  1. The documentation says to install particle-cli with the global flag, -g. That led to permissions errors for me, so I dropped the flag, then it worked. I used:

    $ npm install particle-cli

Then added it to my ~/.profile like:

export PATH=/Users/Gary/.node-gyp/0.10.12/node_modules/.bin/:$PATH
  1. The documentation notes that you need openssl and dfu-util. I already had these installed via MacPorts. The MacPorts versions seem to work correctly for Photon programming.

At this point, you can run the particle command and do things like:

$ particle list
$ particle setup
$ particle device rename long_id_number good_name
  1. Next, you need to install the cross compiler, arm-none-eabi-gcc. The documentation says to use homebrew. But note that the brew command doesn’t work because there’s no longer a brew recipe for it. Note that there’s a MacPorts port for it, but I tried that and it doesn’t not work. Instead, just download the OSX precompiled binaries from the arm site:

    • See here:
    • Download this for OSX:
    • Read the readme.txt:

And add the bin directory, gcc-arm-none-eabi-4_9-2015q1/bin, to your path.

  1. For Photon, grab the current development branch of the repository. Use:

    $ git clone -b feature/hal

  2. Now you can compile the firmware.

    $ cd firmware/main
    $ make PLATFORM=photon

  3. To flash, put the Photon into the DFU mode (blinking yellow), following Section 4, step 1 here:

    $ dfu-util -l

to make sure the dfu-util sees your Photon online. Then:

$ particle flash --usb ../build/target/main/platform-0/main.bin

Note the –usb and note that you pull the .bin file from the build directory, which is not in the firmware/main directory where you started the build.

Alternatively, you can use the dfu-util directly like this:

$ dfu-util -d 2b04:d006 -a 0 -s 0x080A0000:leave -D  ../build/target/main/platform-0/main.bin

Note that the ids in the -d and the memory location in the -s are different for Photons compared to the original values for Cores.

  1. The documentation says that you can flash after building by adding program-dfu to the make commend line. But note that this won’t work, as installed, because the current makefiles are set up for Core, not Photon. To change it, change the build/ dfu line to look like this:

     $(DFU) -d 2b04:d006 -a 0 -s 0x080A0000:leave -D $<

There’s another place in that file where you have to change the values as well.

Now you can build and flash using:

$ make PLATFORM=photon program-dfu

Ok, that’s it so far. Hope this helps others.

Please correct or expand on any of the above.

1 Like

You should do sudo npm install -g particle-cli if you face permissions issues.

It’s actually using the develop branch and not the feature/hal. feature/hal does not contain the latest firmware but a stable version used in the build farm. Over the next few weeks, there will be development time allocated to get this fully working with the core

The particle-cli is designed to help you with flashing with DFU and you don’t need to be bother about the DFU addresses regardless or core or photon.

particle flash --usb xxx.bin will automagically detect the device plugged in.

make all APP=xxx PLATFORM=core program-dfu works with the develop branch already :wink:

Thanks, Kenneth, for the corrections and additional information.

One note: Yes, I did try using ‘sudo’ with the npm -g command, but it still failed with permission issues. Not sure why.

That’s weird but glad you made it work anyways! :smiley:

The current development branch is develop, so that would be

$ git clone -b develop

The feature/hal branch contains a former development state for the Core only. To target the photon, the develop branch is required.

To build the firmware, the target all should also be given to be sure the firmware is actually rebuilt, rather than just flashed, so

make PLATFORM=photon all program-dfu
1 Like

it also seems our applications have moved into firmware/user/applications/ instead of firmware/applications/

hmm, seems the actual firmware (communications libs etc.) isn’t being built for the develop branch for the core, the dfu file ends up as 16 bytes

Hey @sej7278,

i guess you are using the develop branch?

The last time i built for a core, i have a binary that is suitable for the core. What’s the make command that you ran?

With the new APPDIR variable you can place your application code anywhere.

The build documentation has all the details.

turns out (with the develop branch) you have to build from firmware/main/ which is what the docs say, had i read them! can flash the core fine now.

next i’ve got to look into APPDIR and such so i can use my own Makefile (not and source directory etc; without having to build from inside the firmware repo.

1 Like

After all of the above, I found that my setup wouldn’t successfully flash the built code to the Photon. That was because you also have to build/flash the firmware to version 2. See here for details. Now it works.

Also, note that on the new develop branch, the file has been updated, so my original step 7 above modifications are not needed.

Thanks, everyone for your help. Hopefully, these notes will help others.

Oh, and see also the build documentation.

this seems to work quite nicely as a local Makefile using the new options from the develop branch.

it allows me to store my apps and gcc in whatever directory i like (not inside the firmware repo) and just call “make” from inside my app directory, it will then compile a dfu file in cwd/build-core/ or cwd/build-photon/ and i can upload using “make all program-dfu”

i also updated the “clean” target to remove the cwd/build-core/ directory, not just the stuff inside firmware/build/target/

i turn on verbose by default.

nothing is hardcoded, so i can use the same Makefile in all of my apps. and just modify the PLATFORM.


GCC_ARM_PATH = $(HOME)/gcc-arm-none-eabi/bin/
APPDIR       = $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
APP          = $(notdir $(CURDIR))
PLATFORM     = core


clean: local_clean

    rm -rf $(TARGET_DIR)


everything after the $(MAKE) should be all on one line, but the forum has wrapped it.

you end up with a directory structure like:

├── blink.cpp
├── build-core
│   ├── blink.bin
│   ├── blink.bin.crc_block
│   ├── blink.bin.no_crc
│   ├── blink.elf
│   ├── blink.hex
│   ├── blink.lst
│   ├──
│   └── obj
└── Makefile

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

Hi. @DrPhoton
This thread is old, but I would still like to make a contribution.

I have recently been developing a script for installing and using the Particle Toolchain on Ubuntu-based Distros and OSX. I have done lots of testing and it is now very stable. Read more at, or download it instantly with:

curl -fsSL | bash

1 Like