Is it possible to use precompiled library binaries on a Particle Photon?

There is a closed-source library for the BME680 weather sensor that allows it to detect specific gases based on some advanced mathematical manipulation of the raw sensor data:

But unfortunately they are only distributed as precompiled binaries, in the .a file format, for various chip types.

But they do offer one for the ARM Cortex M3, which I'm pretty sure is the same chip that is in my Particle Photon.

Is it at all possible to import and use these .a files in the Particle IDE? Just wondering if this is even possible before I go digging into how.

It is not possible to use a pre-compiled .a file with the cloud compilers.

It may be possible with the gcc-arm local compiler and Particle Workbench. However, you can't do it using the build.mk file, so you actually need to modify the Makefiles in the device-os source in order to get it to work.

1 Like

There was a mention on something like this in this post, if you wanted to read:

cheers

1 Like

Cheers, thanks for the info and the link!

1 Like

Success! Thanks to the link you gave me, I was able to flash the precompiled BSEC library to my Particle Photon. I had to rearrange the library a bit so that the .a file I needed was in the root, and then just like that user described, it was just a matter of editing the two makefiles:

adding

LIBS += algobsec
LIB_DIRS += $(APPDIR)/lib/BSEC-Arduino-library-master/src

to C:\Users\USERNAME\.particle\toolchains\deviceOS\2.3.1\modules\photon\user-part\makefile

and adding

export LDFLAGS = -L$(value PROJECT_ROOT)/BSEC/src/ -llibalgobsec

to C:\Users\USERNAME\.particle\toolchains\buildscripts\1.10.0\makefile

I wasn't actually sure what I was doing translating linux directories to Windows file structure, but I was pretty sure that what I had just told it with project_root was to look in C:\Users\USERNAME.particle\toolchains\deviceOS\2.3.1, so that's where I added the BSEC library as well, and I just renamed it BSEC to shorten it. I'm not sure which directory the compiler was really looking at, so I just made sure if I made any changes to BSEC library in one, I copied them to the other.

It compiled successfully, but threw up an error when trying to use the cloud compile button, so I just ran

particle flash MYTARGETDEVICENAME target\2.3.1\photon\weatherstationoutdoors.bin

And it flashed successfully. And now I'm getting CO2 levels out of a tin dioxide gas sensor thanks to Bosch's 20kB of sensor integration code based on lab analysis. Neato. Thanks guys!

3 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.