# Local building for Core+Photon

**URL:** <https://community.particle.io/t/local-building-for-core-photon/11221>\
**Category:** Firmware\
**Created:** [April 11, 2015, 9:39am UTC](https://community.particle.io/t/local-building-for-core-photon/11221 "2015-04-11T09:39:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [April 11, 2015, 9:39am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/1 "2015-04-11T09:39:14Z")

</div>

Hi, I’ve been out of the Spark world for a while (messing with crappy ESP8266 sorry!) and am looking to get my hands on a Photon or two.

Sooooo. How to we build for a Photon, as obviously they’re different CPU and wifi chips for a start. Is it handled in the makefiles automatically, or do we have to pass in some arguments?

I’m not concerned with cloud IDE/spark-cli builds.

P.S. did you ever get static IP working (not static dynamic)?

---

<div class="post-metadata">

**Author:** ![kennethlimcp](https://avatars.discourse-cdn.com/v4/letter/k/c0e974/32.png) [@kennethlimcp](https://community.particle.io/u/kennethlimcp)\
**Post date:** [April 11, 2015, 10:17am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/2 "2015-04-11T10:17:14Z")

</div>

Here’s how it works with the implementation of **HAL**

- `make PLATFORM=photon APP=app_name`

This will give you a binary built for Photon

- `make PLATFORM=core APP=app_name`

this will give you a binary build for core

You can see the command available here: [https://github.com/spark/firmware/blob/feature/hal/build/readme.md](https://github.com/spark/firmware/blob/feature/hal/build/readme.md)

We should have something really exciting to announce that will make it super simple for people using linux/mac/windows to compile their binary locally. Stay tuned! 😉

I also see that the network stack has some flags to set the **static ip** but i might be wrong.

@mdma should know this best 😉

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [April 11, 2015, 3:35pm UTC](https://community.particle.io/t/local-building-for-core-photon/11221/3 "2015-04-11T15:35:41Z")

</div>

thanks @kennethlimcp

none of these flags that are dotted around the documentation seem to make any difference, they all build for the core:

PLATFORM\_ID=0/1  
PLATFORM=photon  
SPARK\_PRODUCT\_ID=1/2/3  
SPARK\_NO\_PLATFORM=y

i don’t think the makefile setup needs to get any simpler, jees you download arm-none-eabi and dfu-util and type “make”, the new HAL branch means you only have one repo to download too.

p.s. i don’t like make v=1, can’t we use something normal like -v or --verbose ?

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 22, 2015, 6:18am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/4 "2015-05-22T06:18:57Z")

</div>

The photon build is not available publicly yet - we will be releasing that next week.

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 22, 2015, 6:20am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/5 "2015-05-22T06:20:03Z")

</div>

> [@sej7278](#):
>
> p.s. i don't like make v=1, can't we use something normal like -v or --verbose ?

Sure, if you find out how to make that work, please submit a PR!

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 22, 2015, 9:00am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/6 "2015-05-22T09:00:58Z")

</div>

well i’d get rid of firmware/build/verbose.mk which then defaults us to verbose output. for the very few people who don’t want to see any progress, they can run “make -s” which gives you:

```
$ make -s
Building firmware for Spark core, platform ID: 0
   text data bss dec hex filename
  12932 632 3560 17124 42e4 ../build/target/bootloader/platform-0/bootloader.elf
   text data bss dec hex filename
  79708 1144 11620 92472 16938 ../build/target/main/platform-0/main.elf
```

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 22, 2015, 9:05am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/7 "2015-05-22T09:05:13Z")

</div>

What happens when you do a clean build? I think you’re only seeing the final output since there’s no much for make to do.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 22, 2015, 10:07am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/8 "2015-05-22T10:07:10Z")

</div>

that is a clean build

```
$ make -s clean APP=bmp085_cloud
Building firmware for Spark core, platform ID: 0
$ make -s APP=bmp085_cloud
Building firmware for Spark core, platform ID: 0
   text data bss dec hex filename
  12932 632 3560 17124 42e4 ../build/target/bootloader/platform-0/bootloader.elf
   text data bss dec hex filename
  86084 1168 11632 98884 18244 ../build/target/main/platform-0/applications/bmp085_cloud/bmp085_cloud.elf
```

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 22, 2015, 10:14am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/9 "2015-05-22T10:14:18Z")

</div>

cool! And without -s, what do you get? (again with `clean all`)

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 22, 2015, 10:17am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/10 "2015-05-22T10:17:35Z")

</div>

> <https://gist.github.com/sej7278/38b5cb917776977e7cb7>

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 22, 2015, 10:20am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/11 "2015-05-22T10:20:19Z")

</div>

Cool that make is outputting the commands, but there are many echo messages that aren’t appearing.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 22, 2015, 10:20am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/12 "2015-05-22T10:20:52Z")

</div>

ah is ECHO=echo only defined in verbose.mk ?

what echo’s are missing?

even with make v=1 i’m not seeing lines like:

```
$(call,echo,'Invoking: ARM GNU Create Flash Image')

```

so maybe its busted to start with?

this one has verbose.mk just consisting of ECHO=echo, doesn’t seem any better:

> <https://gist.github.com/sej7278/c7dffe59365bbcd4622b>

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 23, 2015, 11:33am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/13 "2015-05-23T11:33:50Z")

</div>

i’m trying to figure out how libraries are handled on a local build these days.

i thought we could put them in firmware/main/libraries or firmware/main/inc but that only seems to work for header files not c++ files (e.g. the bmp085 library has .cpp and .h files) and it also seems to be compiling every library instead of just the ones #include’d in the cpp source - actually it seems to be building every application - maybe the whole thing is broken - doesn’t seem to be building according to travis-ci either?

surely we don’t have to split .cpp files into src/ and .h files into inc/ ?

i’m sure we had this working months ago…?

i’ve tried the develop branch as well as master and they both seem to have the same problem, which branch should we be using these days?

am i right in that we no longer need core-common-lib or core-communications-lib, just firmware (not core-firmware) ?

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 23, 2015, 9:27pm UTC](https://community.particle.io/t/local-building-for-core-photon/11221/14 "2015-05-23T21:27:29Z")

</div>

The travis-ci build is failing because the core is deactivated. I should remove the integration tests so the build works.

Local libraries with CPP files are not supported at present. The simplest way at present is to copy them to a subdirectory of your application.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 24, 2015, 12:37am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/15 "2015-05-24T00:37:03Z")

</div>

ok thanks for the library info, i got it working as a subdirectory but thought we’d already fixed that - as surely the ide servers only use one copy of a library - or do they copy them for each script?

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 24, 2015, 12:43am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/16 "2015-05-24T00:43:57Z")

</div>

to support libraries locally, at a minimum need some metadata so the compiler knows which libraries to build and link. I’d really like to see this happen soon!

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 24, 2015, 9:47am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/17 "2015-05-24T09:47:22Z")

</div>

well we’d need some info on what that metadata is - i assume that’s linked to the build server setup which we have no visibility of?

the problem at the moment i guess is the recursive search for build.mk files - you can’t use a makefile to append the libraries to $CPPSRC as then every one will get built, and inc/ is only being appended to to the include path (for headers).

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 24, 2015, 9:51am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/18 "2015-05-24T09:51:31Z")

</div>

Another workaround is to include your own `build.mk` file in the application sources, and amend CPPSRC and INCLUDES\_DIR to include the libraries you want to build.

Even doing this doesn’t quite get us there since the library format has a “firmware” directory, which contains all the sources and headers. Yet, the include directive is include “lib/lib.h” - no mention of “firmware”. There is some magic happening in the online IDE, which the local built would have to emulate, via copying or symlinks to fix up the namespace.

---

<div class="post-metadata">

**Author:** ![sej7278](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@sej7278](https://community.particle.io/u/sej7278)\
**Post date:** [May 24, 2015, 11:57am UTC](https://community.particle.io/t/local-building-for-core-photon/11221/19 "2015-05-24T11:57:31Z")

</div>

yes i’ve been using my own build.mk, but as i have one for every app, they all get included!

for now, putting libraries in a subdirectory of the app is fine (for me)

---

<div class="post-metadata">

**Author:** ![mdma](https://sea2.discourse-cdn.com/flex026/user_avatar/community.particle.io/mdma/32/1924_2.png) [@mdma](https://community.particle.io/u/mdma)\
**Post date:** [May 24, 2015, 5:40pm UTC](https://community.particle.io/t/local-building-for-core-photon/11221/20 "2015-05-24T17:40:26Z")

</div>

> [@sej7278](#):
>
> even with make v=1 i'm not seeing lines like:
> 
> $(call,echo,'Invoking: ARM GNU Create Flash Image')
> 
> so maybe its busted to start with?

I'm seeing things like

```auto
Invoking: ARM GCC CPP Compiler

```

appearing.

Probably best you checkout a clean working copy and try again. I didn't use the `-s` switch because I couldn't make it work - if make had set a variable indicating silent mode then I could have used that, but I didn't find any such variable.

But if I'm perfectly honest, it seems a bit petty to spend time worrying about whether we pass `v=1` or `-s` to change verbosity - surely the syntax is moot so long as it's reasonably compact and works?

[Next page](https://community.particle.io/t/local-building-for-core-photon/11221.md?page=2)
