Local building for Core+Photon

yeah, i’m just being anal, but its not worth the development time really. i would prefer verbose mode to be the default though

I just set up a local compile environment with the ‘develop’ branch of the firmware, and the basic functionality is working fine. I can put a program in /user/applications/myProgram/’ and compile it for the photon or the core. Sweet!

I’m having trouble adding a library, though. For starters, I want to use the neopixel library. My first attempt was to grab the library off github and put it into /user/libraries/. That did nothing, and as far as I can tell, the compiler didn’t know to look for it there. I didn’t see an obvious way to add code in the ‘libraries’ directory.
Next, I added a folder in ‘/user/applications/neopixelTest’ with the library code. My directory structure looks like this:

    /user
      |
      /applications
                  |
                  /neopixelTest
                           |
                           application.cpp
                           |
                           /neopixel
                                  |
                                   neopixel.cpp
                                   neopixel.h

The compiler is able to find the code, but I think it’s in a muddle trying to compile neopixel.cpp as a standalone program. Here’s the compiler’s output:

    glass@li497-119:~/cubetube-testing/media/photonware/firmware$ make APP=neopixelTest v=1
Building firmware for Spark core, platform ID: 0, product ID: 0
make -C ./communication   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/communication'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/communication'
make -C ./hal   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/hal'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/hal'
make -C ./platform   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make -C ./services   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make -C ./wiring   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/wiring'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/wiring'
make -C ./bootloader   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/bootloader'
make -C ../platform  'GLOBAL_DEFINES=BOOTLOADER_VERSION=3 MODULE_VERSION=3 MODULE_FUNCTION=2 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=neopixelTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make -C ../services  'GLOBAL_DEFINES=BOOTLOADER_VERSION=3 MODULE_VERSION=3 MODULE_FUNCTION=2 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=neopixelTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
arm-none-eabi-size --format=berkeley ../build/target/bootloader/platform-0-lto/bootloader.elf
   text	   data	    bss	    dec	    hex	filename
  10752	    568	   6332	  17652	   44f4	../build/target/bootloader/platform-0-lto/bootloader.elf
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/bootloader'
make -C ./main   v=1 APP=neopixelTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/main'
make -C ../user  'GLOBAL_DEFINES=MODULE_VERSION=0 MODULE_FUNCTION=3 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=neopixelTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/user'
make[2]: *** No rule to make target `../build/target/user/platform-0-lto/applications/neopixelTest/src/neopixel.o', needed by `../build/target/user/platform-0-lto/applications/neopixelTest/libuser.a'.  Stop.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/user'
make[1]: *** [user] Error 2
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/main'
make: *** [main] Error 2

Is anyone else locally compiling with libraries? How do you do it?

–me

Please use the following to format code:

``` <-- insert this

//paste code here

``` <-- insert this

Place all under the same app folder without a subfolder and change the #include to something like #include neopixel.h for now

I put the neopixel.cpp and neopixel.h files in the same folder and changed the #include statement, but I’m still getting a similar error:

glass@li497-119:~/cubetube-testing/media/photonware/firmware$ make APP=newTest v=1
Building firmware for Spark core, platform ID: 0, product ID: 0
make -C ./communication   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/communication'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/communication'
make -C ./hal   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/hal'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/hal'
make -C ./platform   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make -C ./services   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make -C ./wiring   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/wiring'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/wiring'
make -C ./bootloader   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/bootloader'
make -C ../platform  'GLOBAL_DEFINES=BOOTLOADER_VERSION=3 MODULE_VERSION=3 MODULE_FUNCTION=2 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=newTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/platform'
make -C ../services  'GLOBAL_DEFINES=BOOTLOADER_VERSION=3 MODULE_VERSION=3 MODULE_FUNCTION=2 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=newTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/services'
arm-none-eabi-size --format=berkeley ../build/target/bootloader/platform-0-lto/bootloader.elf
   text	   data	    bss	    dec	    hex	filename
  10752	    568	   6332	  17652	   44f4	../build/target/bootloader/platform-0-lto/bootloader.elf
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/bootloader'
make -C ./main   v=1 APP=newTest submake=1
make[1]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/main'
make -C ../user  'GLOBAL_DEFINES=MODULE_VERSION=0 MODULE_FUNCTION=3 MODULE_DEPENDENCY=0,0,0' COMPILE_LTO=y submake=1 APP=newTest v=1 submake=1
make[2]: Entering directory `/home/glass/cubetube-testing/media/photonware/firmware/user'
make[2]: *** No rule to make target `../build/target/user/platform-0-lto/applications/newTest/src/neopixel.o', needed by `../build/target/user/platform-0-lto/applications/newTest/libuser.a'.  Stop.
make[2]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/user'
make[1]: *** [user] Error 2
make[1]: Leaving directory `/home/glass/cubetube-testing/media/photonware/firmware/main'
make: *** [main] Error 2

I saw a mention earlier in the thread that it’s set up to compile with libraries that just have .h files, but not libraries with .cpp files. Does that have anything to do with this error?

as you have neopixel.h in a subdirectory, your include statement should be:

#include "application.h"
#include "neopixel/neopixel.h"

see https://github.com/technobly/SparkCore-NeoPixel/blob/master/firmware/examples/a-rainbow.cpp

also the src directory here “applications/newTest/src/neopixel.o” looks odd - you are using the spark lib and not an arduino sam lib or something?

fwiw, we don’t recommend building against develop for the Core - there are still issues that need to be resolved for the Core. The develop branch is intended for building photon binaries locally.

2 Likes

just ordered a photon so thought i’d better get up-to-date with the firmware.

the “latest” branch builds fine for both spark/photon, the “develop” branch barely even starts the build:

make[1]: Entering directory 'firmware/main'
make -C ../modules/photon/user-part all
make[2]: Entering directory 'firmware/modules/photon/user-part'
../../../build/checks.mk:5: *** Please note the develop branch contains untested, unreleased code. .... Stop.
make[2]: Leaving directory 'firmware/modules/photon/user-part'
../build/recurse.mk:11: recipe for target 'modules/photon/user-part' failed
make[1]: *** [modules/photon/user-part] Error 2
make[1]: Leaving directory 'firmware/main'
Makefile:15: recipe for target 'all' failed
make: *** [all] Error 2

adding PARTICLE_DEVELOP=1 as per github allows it to build, but what’s that about - just a warning or something?

i assume the latest and releases/v0.4.4 branches work with the photon? what about master? essentially which branch should we be using (i thought it was develop)? cheers.

Hi @sej7278

The “develop” branch is where the team does its work and represents the bleeding edge. It is generally OK but there are times when things are broken for a time on that branch to be fixed by a future commit. The “latest” branch is stable.

Some users thought that using the develop branch would get them closer to the latest commits (which is true) but didn’t realize it was also more fragile.

1 Like

ok thanks, yes i assumed the PARTICLE_DEVELOP flag was for internal use really. i’ll stick to “latest”.

This has come up several times now. The full message is

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)

Despite listing that the develop branch is untested and unreleased, with a pointer to latest for stable firmware seems not everyone is getting it. What can we do to make the message clearer?

1 Like

sorry @mdma i’ve been out of the loop for a while so didn’t know about the message until i scoured the sourcecode and found the github link, in an 80-column terminal the message is not very clear

oh 80 column terminal - is it clipping the message so you don’t see all of it? I wonder if we can put some newlines in the message?

Any news for local building?

Even the simplest blink fails on Mac OS X. Providing an alternative to the cloud IDE is key.

local building does work, i’ve just built 0.4.6 as i was having trouble getting the cloud to work actually!

Building the framework goes fine, but not a basic project. The develop branch isn’t recommended, so I’ve tried with the latest branch, to no avail on Mac OS X.

Viable command line building is becoming critical as more disruptions are experienced on the cloud service.

have you got a log or error message, you can’t be helped by just saying “it doesn’t work” when it does for most of us. don’t tell me you’re using el-capitan?

When I say “it doesn’t work”, I mean 'it doesn’t work". Otherwise, I would have posted lengthy compilation traces, log errors and cryptic codes to decipher.

The code source is as minimal and stupid as the blinky example with the recommended firmware/latest branch. Building and linking complete fine, the resulting executable uploads successfully to the board but, as a result, the D7 LED doesn’t blink. So “it doesn’t work”. It performed the test various times following the same protocol.

The firmware/feature/HAL branch works fine for the Core, but not the new firmware/latest branch for the Core nor the Photon.

Yes, I’m using El Capitan. I’ve experienced no issues so far with other platforms when I use the GCC tool-chain and other SDKs like mbed, different flavours of Linux SDKs, RTOS, and different flavours of the Wiring/Arduino framework.

The “it just works” or plug-and-play or end-user experience includes the hardware, the software but also the documentation and the tutorials. My point was less technical but more user-oriented.

If “it just works” for you, lucky one! Feel free to share your experience, especially for the Custom makefile section. Thank you!

@rei_vilo could you share the command you’re using?

Here’s the way to ensure a clean build for the Photon, with modular firmware (Photon in DFU mode):

~code/firmware/modules $ make clean all -s PLATFORM=photon COMPILE_LTO=n APP=tinker program-dfu

And here’s how to compile a monolithic image if iterating locally:

/firmware/main $ make clean all -s PLATFORM=photon COMPILE_LTO=n APP=tinker program-dfu MODULAR=n

You can replace APP=tinker with a folder of your choice sitting along side of

firmware/user/applications/tinker/
1 Like

Here’s my blink.cpp which i have inside a blink directory somewhere in my $HOME

#include "application.h"

void setup()
{
    pinMode(D7, OUTPUT);
}

void loop()
{
    digitalWrite(D7, HIGH);
    delay(500);
    digitalWrite(D7, LOW);
    delay(500);
}

and here’s my custom Makefile, which is also inside the blink directory:

GCC_ARM_PATH = /stuff/sparkcore/gcc-arm-none-eabi/bin/
APPDIR       = $(realpath $(dir $(realpath $(lastword $(MAKEFILE_LIST)))))
APP          = $(notdir $(CURDIR))
TARGET_DIR   = $(CURDIR)/build-$(PLATFORM)
PLATFORM     = photon

all:

clean: local_clean

upload: all program-dfu

local_clean:
    rm -rf $(TARGET_DIR)

%:
    $(MAKE) -C /stuff/sparkcore/firmware/main APP=$(APP) PLATFORM=$(PLATFORM) APPDIR=$(APPDIR) GCC_ARM_PATH=$(GCC_ARM_PATH) TARGET_DIR=$(TARGET_DIR) v=1 $@

obviously the $(MAKE)…$@ should be all on one line, the forum has wrapped it.

i put the photon into dfu mode (hold setup+reset, let go of reset but keep holding setup until it blinks yellow. auto dfu mode doesn’t work on linux at least, you have to use the buttons) and call “make upload” and it works on my particle photon and spark core, i end up with a directory structure like:

blink/
├── blink.cpp
├── build-core/
├── build-photon/
└── Makefile

tested using gcc-arm-none-eabi-4_9-2015q2-20150609-linux.tar.bz2 and gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 with the “latest” branch