I’ve been setting up a local build environment on a Mac. Here are some problems with the current documentation and their solutions.
-
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
- 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
-
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: https://launchpad.net/gcc-arm-embedded
• Download this for OSX: https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q1-update/+download/gcc-arm-none-eabi-4_9-2015q1-20150306-mac.tar.bz2
• Read the readme.txt: https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q1-update/+download/readme.txt
And add the bin directory, gcc-arm-none-eabi-4_9-2015q1/bin, to your path.
-
For Photon, grab the current development branch of the repository. Use:
$ git clone -b feature/hal https://github.com/spark/firmware
-
Now you can compile the firmware.
$ cd firmware/main
$ make PLATFORM=photon -
To flash, put the Photon into the DFU mode (blinking yellow), following Section 4, step 1 here: https://github.com/spark/firmware/tree/develop#4-flash-it
$ 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.
-
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/module.mk 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.