Photon how to setup local compiling

Hi everybody,

Where do I find the instructions for setting up local compile for the photon?
I use netbeans, W7.

Marcus

1 Like

@marcus, you can start here:

:smile:

1 Like

You could take the easy route and use this, which has Netbeans included :smile:

Works for me but what happened to the modules folder?

How do we build these repositories?

at page:

https://github.com/spark/firmware/blob/develop/docs/gettingstarted.md#2-download-and-build-repositories

It tells me under step 2 to:

How do we build these repositories?

Make sure you have downloaded and installed all the required dependencies as mentioned previously. Note, if you've downloaded or cloned these previously, you'll want to git pull or redownload all of them before proceeding.

Open up a terminal window, navigate to the modules folder under firmware (i.e. cd firmware/modules) and type:

make clean all PLATFORM=photon -s program-dfu

The repo I downloaded does not have a modules directory :cry:
Is it moved, the name changed or…

@marcus, I use git to clone a repo to my PC since I can just “git pull” to get updates. To use git you need to clone the “develop” branch with:

git clone -b develop https://github.com/spark/firmware

The clone will create a firmware directory with the entire repo under it. You should then be able to find the modules directory as expected. :smile:

A ha,
I cloned another repo.

1 Like

ATTACK OF THE CLONES! :stuck_out_tongue_closed_eyes:

3 Likes

Couldn’t resist…

4 Likes

Well since it’s a biautiful evening,
How about this error message:

C:\particle\firmware\modules>make clean all PLATFORM=photon -s program-dfu
'head' is not recognized as an internal or external command,
operable program or batch file.
The system cannot find the file specified.
The system cannot find the file specified.

It seems my computer does not want to give … :wink:
What do I do wrong?

Hi @marcus,

Looks like you’re compiling on windows, make sure you have git installed / maybe using the git command prompt? And you want to be in the right branch, try:

git checkout releases/v0.4.4

Thanks,
David

Hi @Dave,

I work on windows. and git is installed, but the option you give me also generates an error.

C:\particle\firmware>git checkout releases/v0.4.4
error: pathspec 'releases/v0.4.4' did not match any file(s) known to git.

Are all you guys working with Linux or Apple? That would explain a lot…

Hi @marcus,

The windows command prompt likes to throw lots of curve balls, do you have tortoiseGIT or something similar installed that will let you get the right branch?

Thanks,
David

Hi @Dave,
I have installed: git version 2.5.0.windows.1

And with this version of git I obtained the firmware. Do you advise me to get tortoise?

cheers,
Marcus

Hi @marcus,

You probably don’t need Tortoise, but sometimes the GUI tools can be more forgiving. :slight_smile: Git has a handful of GUI alternatives if that’s something you’re into ( https://git-scm.com/downloads/guis ).

The error you’re seeing “error: pathspec ‘releases/v0.4.4’ did not match any file(s) known to git.” Makes me think something is weird about which directory you’re in, or maybe you haven’t pulled / fetched tags from the origin? Maybe Windows is being confused by the slash or something?

# how about something like this?
git fetch --all

git checkout "releases/v0.4.4"
#or if that didn't work try this branch without special characters
git checkout latest

git pull

I hope that helps!

Thanks,
David

Well,
It is not going so well… with the local compile setup on windows 7. Good I use a new laptop for this, and not my working spark laptop,…

When I read the make files this get’s my attention:

In the makefile: arm-tools, the compiler version is looked up:

# Check if the compiler version is the minimum required
arm_gcc_version:=$(shell $(CC) --version | head -n 1)
arm_gcc_version:=$(strip $(subst arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors),,$(arm_gcc_version)))
expected_version:=4.8.4

This results in an compiler error:

'head' is not recognized as an internal or external command,
operable program or batch file.

I tested this by entering the compiler command by hand:

C:\Particle\Toolchain\GCC-ARM>arm-none-eabi-gcc --version | head -n 1

And indeed it gives the error. My compiler version is 4.9.3, instead of 4.8.4.
Is this the source of the problem, or am I using the wrong compiler.
The make file does require 4.8.4 as a minimum version, ergo it should work, well it is reasonable to expect it to work…
I intalled everything with the toolchain installer, nice work @mumblepins, by the way!
So what to do?

GOING BACK TO LINUX! I wish it was possible for me. Spend hours to get the Photon repo to compile…
It happens that the PATH variable is a bit sticky, and refuses to do what it needs to do: store paths to files.

I resolved the matter with eveditor.

I added manually the following to the user path:

C:\Particle\Tools\Git\cmd;
C:\Program Files (x86)\nodejs\;
C:\Particle\Toolchain\MinGW;
C:\Particle\Toolchain\MinGW\msys\1.0\bin;
C:\Particle\Tools\DFU-util;
C:\particle\Toolchain\GCC-ARM\bin;
C:\particle\Toolchain\Make\bin;
C:\Particle\Tools\Git\cmd;

Don’t ask me why manually altering the path or the registry failed.
Even the nice installer from @mumblepins failed to get it right.

1 Like

head is a command in MinGW - you should be able to type that into your console and see the command is found. Similarly for stat. If these commands aren’t found the build cannot succeed.

Thanks @mdma,

As I wrote, the path problems where the source of almost all failures.
I resolved this problem with eveditor. For others experiencing the same problems, install eveditor, add the paths needed, save your user path and ready.

I added the following lines to the user path:

C:\Particle\Tools\Git\cmd;
C:\Program Files (x86)\nodejs\;
C:\Particle\Toolchain\MinGW;
C:\Particle\Toolchain\MinGW\msys\1.0\bin;
C:\Particle\Tools\DFU-util;
C:\particle\Toolchain\GCC-ARM\bin;
C:\particle\Toolchain\Make\bin;
C:\Particle\Tools\Git\cmd;
1 Like

For windows 7 users, compiling locally, how I got it to work.
Before you begin remove the following packages, if installed:
Gcc compilers,
make,
node.js,
dfu-util,
with Zadig:libusbK (v3.0.7.0).
reboot.
Yeah a bit drastic but necessary to clean up.

Software:
download node.js, to the default directory, Program Files (x86\nodejs
install Toolchain from @mumblepins
Driver: install spark_core.inf
Now the tricky part:
Edit with eveditor the user path.
add:

C:\Particle\Tools\Git\cmd;
C:\Program Files (x86)\nodejs\;
C:\Particle\Toolchain\MinGW;
C:\Particle\Toolchain\MinGW\msys\1.0\bin;
C:\Particle\Tools\DFU-util;
C:\particle\Toolchain\GCC-ARM\bin;
C:\particle\Toolchain\Make\bin;
C:\Particle\Tools\Git\cmd;

Why? even if you do this from the command line, or via an installer the path will not be altered, some of the times. That behaviour costed me a lot of time.

Next: set the following USER environment variables with evedit:

PLATFORM = photon
PLATFORM_NAME = photon
PYTHON = C:\Particle\Tools\Python27
PYTHON_PATH = C:\Particle\Tools\Python27

It sounds like doing things double, maybe, but it works.
Save variables with the SET ‘button’ left mid of the screen of eveditor
Exit

REBOOT

And then automagically:

  1. Particle command line interface works.
  2. DFU-util works.
  3. Compile from command window with particle works.
  4. Compiling of the complete source from C:\particle\firmware works (make clean all)

However:
I could not tame Netbeans. As soon as the compiler is invoked it start’s to wine that it can not find a file. This is the error message:

  make.exe[3]: Entering directory `C:/Particle/firmware/user'
    Building file: src/application.cpp
    Invoking: ARM GCC CPP Compiler
    mkdir -p ../build/target/user/platform-6-m/src/src/
    arm-none-eabi-gcc
...... I cut out the flags to save space .....
 -fno-exceptions -fno-rtti -fcheck-new -c -o ../build/target/user/platform-6-m/src/src/application.o src/application.cpp
    arm-none-eabi-gcc: error: CreateProcess: No such file or directory
    make.exe[3]: *** [../build/target/user/platform-6-m/src/src/application.o] Fel 1
    make.exe[3]: Leaving directory `C:/Particle/firmware/user'
    make.exe[2]: *** [user] Fel 2
    make.exe[2]: Leaving directory `C:/Particle/firmware/modules/photon/user-part'
    make.exe[1]: *** [modules/photon/user-part] Fel 2
    make.exe[1]: Leaving directory `C:/Particle/firmware/main'
    make.exe : *** [main] Fel 2
    
    BUILD FAILED (exit value 2, total time: 18s)

My make.exe decided to speak swedish, so don’t mind the ‘Fel’ :wink:
If anyone can help from this point on, please let me know.

And a question to more experienced makefile guru’s:
I would like to have a rule that compiles and links only the user part. See the makefile in Particle\firmware

I hope this helps others to get going in Windows, hmm a contradiction in terms, I know…

That means it can’t find the arm gcc compiler. You’ll need the arm gcc toolchain installed and in your path.