Local Build Confusion

I’m trying to do a local build for the first time, and can’t get it to work .I’m following (or trying to anyway) the instructions in the “Getting Started” doc on GitHub. I created an empty folder, /Particle, and navigated to that folder in the terminal. I typed in the following,

git clone https://github.com/spark/firmware.git

This works fine, the folder is populated with a top folder of “firmware”.

From this point, I tried several things. I replaced the application.cpp file with my own test code, and then did the following, from the firmware/modules directory, as it says to do in the “How do we build these repositories?” section:

make clean all PLATFORM=photon -s program-fu

This gives me this error:

/Particle/firmware/modules/photon/system-part1/makefile /Particle/firmware/modules/photon/system-part2/makefile /Particle/firmware/modules/photon/user-part/makefile
…/…/…/build/checks.mk:5: *** Please note the develop branch contains untested, unreleased code. We recommend using the ‘latest’ branch which contains the latest released firmware code. To build the develop branch, please see the the build documentation at https://github.com/spark/firmware/blob/develop/docs/build.md#building-the-develop-branch. Stop.
make: *** [/Particle/firmware/modules/photon/system-part1/makefile] Error 2

Since the text refers to the “latest” branch, I started over (deleted the contents of my Particle folder), and ran the following two commands,
git clone https://github.com/spark/firmware.git git checkout latest
The first command works properly, but the second one gives me an error:
fatal: Not a git repository (or any of the parent directories): .git
I’m not sure what this means.

CD to the firmware folder before doing git checkout latest

1 Like

@kennethlimcp, thanks, that worked. Further down in the “Edit and Rebuild” section, it says, after editing the code, to run the make command from firmware/main, but that gave errors for me. If I run make from firmware/modules, it seemed to work correctly. I made one minor change to the firmware, and substituted my code for the Tinker app, and the code running on my Photon reflected those changes. One thing i noticed, and I don’t know if this has anything to do with the local build, was that my Photon ran fine for 15 seconds or so, then went into rapid cyan flashing, followed by 3 or 4 rapid orange flashes, a quick rapid cyan again, and then back to breathing cyan. It did this twice, before behaving normally for the rest of my test (half an hour or so).

Does the original tinker firmware work fine?

I don’t know, since I haven’t tried to flash it again. I did quite a bit of testing after I wrote that last post, and I never saw that problem again.

@kennethlimcp, @BDub, @mdma I’m in the process of writing an OS X app to provide a GUI for doing local building and flashing of code. In my testing, I’ve come across a problem that seems to indicate that the order of arguments passed to ‘make’, makes a difference – I was under the impression that the order shouldn’t matter. After cloning the develop branch from github, and changing the directory to /Particle/firmware/modules I tried the following commands,

This one worked:
make PLATFORM=photon clean all program-dfu APPDIR=/Particle/Apps/blink2 PARTICLE_DEVELOP=1

This one doesn’t work:
make all clean PARTICLE_DEVELOP=1 PLATFORM=photon APPDIR=/Particle/Apps/blink2 program-fu

That second one gives me these errors,

cp: …/…/…/build/target/system-part1/platform-6-m/system-part1.bin: No such file or directory
make[1]: *** […/…/…/build/target/system-part1/platform-6-m/system-part1.dfu] Error 1
make: *** [/Particle/firmware/modules/photon/system-part1/makefile] Error 2

I haven’t tried any other orders than these two, but I’ve tested each of these two variants several times (from terminal, not my app).

make executes targets in the order you specify them, so running all clean will build everything first, then clean it.

Ok, thanks for the quick response. So should the order of ‘all’ and ‘clean’ be the only thing I have to be concerned with here? Should the placement of program-dfu matter?

yes, program-dfu is a target too. Targets appear in the order you want them executed.

Aside from targets there are

  • switches - these start -, e.g. -s
  • variables - these are like X=Y

These are also processed from left to right, but typically the order doesn’t matter.

http://www.gnu.org/software/make/manual/make.html#Running

Ok. Thanks for clearing that up, and for the reference.