Photon how to setup local compiling

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.

@mdma,
Thanks for the explanation of the meaning off this error. I will not disturb you with simple path matters, but as far as I see the path contains: C:\particle\Toolchain\GCC-ARM\bin;
and there are all the compiler executables. I keep digging.
compliments on the improvements of Photon over Core to you and the team, OTA is even faster than DFU!

.

one thing you all have seemed to miss, in linux it uses the “|” char to pipe, windows uses a “;” for the same thing, it doesnt use the |,

Sorry for the dumb question. I’m a little weary of all the maintenance and just want something to be easy. Where in Linux do I put my application? Add the usual single folder content to ./core-firmware/usr/src? Can it use a .ino or do I have to rename that file to application.cpp?

I think I figured it out. You do have to rename .ino to application.cpp. The stuff goes into firmware/user/src. And flash user-part.bin. Here are the details.

# process for project in ~/particle/Thermostat-Particle-Photon/myThermostat_Particle_DEV
# and device PhotonOBDHYK
cd ~/particle
cp myThermostat-Particle-Photon/myThermostat_Particle_DEV/* firmware/user/src
cp firmware/user/src/myThermostat.ino firmware/user/src/application.cpp
cd /home/davegutz/particle/firmware/main && make clean all PLATFORM=photon
cd ~/particle/firmware/build/target/user-part/platform-6-m
particle flash PhotonOBD9HYK user-part.bin

The version is a llittle old. To get this to compile I had to rollback my Particle.variable syntax:

//Particle.variable("stat", statStr);
Particle.variable("stat", statStr.c_str(), STRING);

This works, anyway. I am running Ubuntu 14.04 on VirtualBox 5.0.10 within Windows 10.

Well I'm sure the Particle team is working hard on the Linux DEV tool which will make the following obsolete very soon, I hope (and thanks by the way).
Here is my toolchain to get setup in Ubuntu 14.04 (I create a folder called ~/particle to contain this stuff). I queried tool versions as I went so you can see just how old this is (made 12/30/2015).

in linux install keys and github following the instructions on these links:

First install the node.js and npm packages following these instructions that also install Homebrew

When I was done:

node -v
v0.10.37
npm -v
1.4.28

now at linux cli:

add_ppa() { grep -h "^deb.*$1" /etc/apt/sources.list.d/* > /dev/null 2>&1; if [ $? -ne 0 ]; then echo "Adding ppa:$1"; sudo add-apt-repository -y ppa:$1; return 0; fi; echo "ppa:$1 already exists"; return 1; }
add_ppa terry.guo/gcc-arm-embedded
sudo apt-get update
sudo apt-get -y install gcc-arm-none-eabi git

mkdir particle && cd particle
git clone https://github.com/spark/firmware && cd firmware && git checkout latest && cd main && make clean all PLATFORM=photon && cd ../build/target/user-part/platform-6-m

sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update 
sudo apt-get install python-software-properties python g++ make nodejs sudo apt-get install build-essential libusb-1.0-0-dev

sudo npm install -g particle-cli
particle --version
1.8.20
particle cloud login
# answer the login questions

cd ~/particle
git clone git@github.com:spark/core-communication-lib.git
git clone git@github.com:spark/core-firmware.git
git clone git@github.com:spark/core-common-lib.git
git clone git://git.code.sf.net/p/dfu-util/dfu-util
cd dfu-util
sudo apt-get build-dep dfu-util
./autogen.sh
./configure
make
sudo make install
cd ..

# Test on Photon
# Hold down the mode button and press and release the reset button until the core starts flashing yellow, then release the mode button.
# Virtual Box - Devices - USB - select the "DFU Mode" device
sudo dfu-util -l

Should look something like:

   Found DFU: [2b04:d006] ver=0200, devnum=3, cfg=1, intf=0, alt=1,     name="@DCT Flash /0x00000000/01*016Kg", serial="00000000010C" Found DFU: [2b04:d006] ver=0200, devnum=3, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/03*016Ka,01*016Kg,01*064Kg,07*128Kg", serial="00000000010C" 

Build and flash tinker

cd /home/davegutz/particle/firmware/main && make clean all PLATFORM=photon
cd ~/particle/firmware/build/target/user-part/platform-6-m

cd ~/particle/firmware
particle setup
particle list

Threw error:

#Error loading command /usr/local/lib/node_modules/particle-cli/commands/SerialCommand.js Error: Cannot find module '/usr/local/lib/node_modules/particle-cli/node_modules/serialport/build/Release/node-v47-linux-x64/serialport.node'

#THIS IS OK.
IT SIMPLY MEANS YOUR VIRTUAL BOX SETTINGS FOR USB ARE UNSET. THE PARTICLE CLI WILL STILL FIND THE PHOTON.

The following should now work

particle flash PhotonExp9HYK tinker

Now load your project

cd ~/particle
git clone git@github.com:davegutz/myThermostat-Particle-Photon.git

Note: Have to revert you Particle.variable statements from

Particle.variable("stat", statStr);
# to
Particle.variable("stat", statStr.c_str(), STRING);

Now the redo loop for a project:

# redo loop for project in ~/particle/Thermostat-Particle-Photon/myThermostat_Particle_DEV
# and device PhotonExp9HYK
cd ~/particle
cp myThermostat-Particle-Photon/myThermostat_Particle_DEV/* firmware/user/src
cp firmware/user/src/myThermostat.ino firmware/user/src/application.cpp
cd /home/davegutz/particle/firmware/main && make clean all PLATFORM=photon
cd ~/particle/firmware/build/target/user-part/platform-6-m
# put your photon into flash safe mode (flash purple)
particle flash PhotonExp9HYK user-part.bin

####Update from git
cd ~/particle/myThermostat-Particle-Photon
git pull