Web server Library example compiles, but gives linkage errors when flashing a Photon

Hi ,
I created a new App, named it Test, opened the Webserver library, clicked on the Web_AjaxRGB_mobile.ino example and then clicked on “Include in App”, and included it in the newly created Test App.
This added the following line in my App -

// This #include statement was automatically added by the Spark IDE.
#include "WebServer/WebServer.h"

I just had empty setup() and loop() functions in this file.

I clicked Verify, got a message "Great Work"
I clicked on Flash, got following error -

In file included from ../wiring/inc/spark_wiring.h:47:0,
from ./inc/application.h:29,
from /spark/compile_service/shared/workspace/6_hal_12_0/firmware-privatest.cpp:2:
../wiring/inc/spark_wiring_ticks.h:32:22: error: previous declaration of 'system_tick_t millis()' with 'C++' linkage
inline system_tick_t millis(void) { return HAL_Timer_Get_Milli_Seconds(); }
^
In file included from /spark/compile_service/shared/workspace/6_hal_12_0/firmware-privatest.cpp:2:0:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:150:37: error: conflicts with new declaration with 'C' linkage
extern "C" unsigned long millis(void);
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h: In member function 'bool WebServer::readPOSTparam(char*, int, char*, int)':
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:1044:39: warning: narrowing conversion of 'ch1' from 'int' to 'char' inside { } [-Wnarrowing]
char hex[3] = { ch1, ch2, '\x0' };
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:1044:39: warning: narrowing conversion of 'ch2' from 'int' to 'char' inside { } [-Wnarrowing]
make[1]: *** [../build/target/user/platform-6test.o] Error 1
make: *** [user] Error 2

Flash unsuccessful.

The I copy - pasted the sketch from the Web_AjaxRGB_mobile.ino file (removed the #include from the original and kept the new #include statement), and compiled, It compiled successfully, but flashing gave me the exact same error as above.

I then removed the included Webserver library from the project, added a new header file “Webserver.h” and copy-pasted the code from Webserver.h in this file.
This also compiled fine, but game me the same error when flashing the code.

Please help for flashing

Thanks in advance

Update:
I tried to include other libraries, they all are giving similar issues while flashing, but no issues while compiling.
I wrote my own simple sketch to turn on/off LEDs from my phone app, and am able to flash that and it works great.
Looks like the flashing issue is only when I include some library or try to use a library
Hope someone can help me resolve this soon as I want to test and use the Webserver example

Is this compiling for the photon or the core?

This is for the Photon, Edited the title

It’s strange you get two different results from verify and compile. We’ve seen some differences there in connection with how the target device is passed from the IDE to the API and compile service. cc: @suda, @Dave

The specific error you are seeing is due to a function signature change. I will take steps to revert and fix. Will post back when this is done!

Great! Hope this doesn’t take too long and I get to demo something cool to my team before the long weekend starts :smile:

Hmm, maybe try refreshing the page to make sure you’re using the latest version of the web IDE? Are you using a beta photon, or a normal photon?

Thanks,
David

I’m using the Photon for the first time, used the Web IDE for the first time, I guess it should be the latest Web IDE. I have logged out and logged in again, so I guess it should have been refreshed.
I got the Photon from the Maker Faire, not sure if its Beta or normal - how do I tell that?

Hi @SCS01,

Can you send me the device ID and I can check?

Thanks
David

The Device ID being shown on my Web IDE? Is it O.K. to share it here? Or do you want the number on the back of my Photon board?

Typically we don’t consider device IDs sensitive info, but if you want to PM it to me, or email me at david@spark.io / david@particle.io that works too if you’re okay with that. Otherwise if its registered to your email, I can use that to lookup the device also if that’s okay.

Thanks,
David

To get the device ID from the web IDE, click on the Devices drawer (the crosshair icon) in the bottom left, and then click on the right arrow next to the device you’re currently using to display the device ID. It’s pretty safe to post the device ID on the forums. If you’d rather be safe than sorry, I’m sure @Dave will access a private message too. :wink:

1 Like

Thanks,
I’m already using the device ID for the cloud communication APIs, I just wasn’t sure if it was safe to share it on a public forum. This board is very new, so can’t think of situations where my Photon could be hacked by the smart people here. Anyways, I’m giving it here for Dave’s reference… will let you know if there’s any hacking :wink:
Device ID: 190033000547343232363230

1 Like

Hi @SCS01,

Looks like you have a normal photon and not a beta one. So long as you only have one device in the IDE, or your photon is ‘starred’, then you should see the same errors when verifying vs. flashing. Was the photon starred when you hit verify earlier?

Thanks,
David

No David,
I’m the only one using this Photon. I can reproduce this repeatedly at my end, all the time - compile, ok, flash, error.
Change library, compile, ok, flash, error
create new project, simple sketch - compile, ok, flash ok, include library - compile, ok, flash, error.
Are you able to compile and flash the Webserver library? Can you please give me the steps you are following to include and flash the project?

Thanks

Hi @SCS01,

Hmm, when targeting my photon, when i hit compile I see:


In file included from ../wiring/inc/spark_wiring.h:47:0,
from ./inc/application.h:29,
from /spark/compile_service/shared/workspace/6_hal_12_0/firmware-privawebserver-test.cpp:2:
../wiring/inc/spark_wiring_ticks.h:32:22: error: previous declaration of 'system_tick_t millis()' with 'C++' linkage
inline system_tick_t millis(void) { return HAL_Timer_Get_Milli_Seconds(); }
^
In file included from /spark/compile_service/shared/workspace/6_hal_12_0/firmware-privawebserver-test.cpp:2:0:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:150:37: error: conflicts with new declaration with 'C' linkage
extern "C" unsigned long millis(void);
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h: In member function 'bool WebServer::readPOSTparam(char*, int, char*, int)':
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:1044:39: warning: narrowing conversion of 'ch1' from 'int' to 'char' inside { } [-Wnarrowing]
char hex[3] = { ch1, ch2, '\x0' };
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaWebServer/WebServer.h:1044:39: warning: narrowing conversion of 'ch2' from 'int' to 'char' inside { } [-Wnarrowing]
make[1]: *** [../build/target/user/platform-6webserver-test.o] Error 1
make: *** [user] Error 2

So I don’t think this library is working for the photon yet, is that what you’re seeing?

Thanks,
David

Exactly same as what I pasted in my original question. I was able to comply the libraries, but not flash them.
Can you compile and flash any of the libraries at all? I can’t!!

Hi @SCS01,

Sorry about any confusion! I was checking to make sure the “verify” vs. “flash” behavior was consistent, not looking into why the library wasn’t working. Most of our libraries were built for the Core, and the Photon uses a very new set of firmware, so I think as library creators from the community receive photons, they’ll be able to port those libraries forward to be compatible with both.

Lots of libraries are already compatible with the Photon, I just tested the “Adafruit_DHT” library and it worked normally. Lets start a thread on which libraries need porting, thoughts @christine ?

Thanks!
David

1 Like

Sounds like a good idea, @Dave! Everyone make a list of non-working libraries here:

Also I feel like I should get some kind of prize for this being the 12000th topic. :smile:

2 Likes

Yes, but there is no way for me to select the target when flashing. How do I know whether the library has been written for photon or Core?
Does this mean that none of the examples from the library would get flashed in the Photon, even though they would all compile successfully from the Web IDE?
Do you need to add an option - compile for Core/compile for Photon?
Sorry, but this is confusing - how could Adafruit example get flashed if it’s been written for Core?

Hi @SCS01

The web IDE “knows” what device you are targeting via the target menu, so that part will be fine. There are a couple of ways you can accidentally try to flash a Core binary to a Photon but the good news is that they don’t hurt anything and your Photon will just reboot.

The plan for libraries in general is to make them work for both the Core and the Photon (and the Electron eventually) but it will take time and energy from the community to get that done! Libraries that use low-level hardware features need to have some rework but a lot of things (like the Adafruit example) will just work.

The first step is reporting what works already and what needs some TLC.

2 Likes