locked
Error when calling external library in high level app RRS feed

  • Question

  • I'm trying to link against an external library that has been pre-compiled for Cortex-A7.

    The application is building fine but when my code calls the library, I get an error when I try to debug the application:


    If I just link to the library and don't call it, then I don't get any problem.

    Here are the steps to reproduce this problem. I'm using an Avnet dev board, but it should work on any Azure Sphere board. No special hardware is required to reproduce the problem.


    1. Check out the Azure samples Github project https://github.com/Azure/azure-sphere-samples
    2. Download BSEC_1.4.7.4_Cortex-A7_with_fPIC.zip from here: https://community.bosch-sensortec.com/t5/MEMS-sensors-forum/BSEC-library-for-Azure-Sphere/m-p/10122/highlight/true#M1717
    3. Open the GPIO_HighLevelApp from the cloned Azure-Sphere-samples repo
    4. Build and run application, verify that it works and debugging is ok.
    5. Open the ZIP file from step 2.
    6. Copy these files from the ZIP into the GPIO_HighLevelApp project folder:
      libalgobsec.a
      bsec_interface.h
      bsec_datatypes.h
    7. Add algobsec to the libraries that will be linked:

    8. Add these lines at the top of main.c:
      #include "bsec_datatypes.h"
      #include "bsec_interface.h"
    9. Add a call to bsec_init() in main():

    I appreciate any help on this, as it is blocking my current project.



    • Edited by Jeremy_K Monday, November 4, 2019 7:43 PM clarification of problem
    Monday, November 4, 2019 1:03 PM

Answers

  • The answer is the library was not compatible with the environment.

    The source for that library is not available, therefore you cannot use the BSEC with Linux on the Cortex-A7.

    My work-around (hack) was to use the BSEC library for the M4 core in a real-time app and pass the data from the high-level app for processing.

    I did try using the M4F build of the library, but I ran into multiple problems:

    1. By default,  the .cmake file in the Azure Sphere toolchain does not compile with the hard float option.

    2. Also, I was getting hard faults when trying to use floating point operations, so perhaps there is some other hardware restriction?

    • Marked as answer by Jeremy_K Thursday, December 5, 2019 12:46 AM
    Thursday, December 5, 2019 12:45 AM

All replies

  • execute once:

     azsphere device prep-debug

    Monday, November 4, 2019 1:34 PM
  • and this lib is for baremetal

    find source codes in github and add to your project 

    https://github.com/mongoose-os-libs/bme680/tree/master/BSEC_1.4.7.4_Generic_Release/bsec/src

    btw: source is on C++

    Monday, November 4, 2019 1:49 PM
  • Please read my post again.

    The library I am linking is for a Cortex-A7.

    Debugging works fine, even when I link the library.

    The problem occurs as soon as I *call* the library.

    Monday, November 4, 2019 7:40 PM
  • you cannot run baremetal library on Linux OS

    your library is compiled with gcc-arm-none-eabi ( float unknow ) thumb

    for Linux based Azure Sphere must be gcc-arm-linux-eabi-hf

    function calls between linux and baremetal is different, reent tooo....

    try raspberry library or source code for BME680

    https://github.com/juergs/BME680_cc_sensor_v1_5_V3_D1_WROOM_VS/blob/master/bme680.c



    • Edited by WizIO.bg Monday, November 4, 2019 8:29 PM
    Monday, November 4, 2019 8:23 PM
  • OK, so I need a Linux library, not a baremetal one.

    I will ask Bosch to provide one. The reason I am interested in the BSEC library is for additional processing.

    Monday, November 4, 2019 9:37 PM
  • https://www.bosch-sensortec.com/bst/products/all_products/bsec

    in zip file exist Raspberry lib(32) - try link

    If ask - ask for float Hard


    • Edited by WizIO.bg Monday, November 4, 2019 9:43 PM
    Monday, November 4, 2019 9:42 PM
  • I did try using the PiThree_ArmV8-a-64bits and PiZero_ArmV6-32bits variants, but they either don't link or throw seg faults.

    I have suggested to Bosch they compile their library with the Azure Sphere toolchain for the maximum chance at success.

    Tuesday, November 5, 2019 6:10 AM
  • or integrate Bosch BME680 driver in your project

    https://github.com/BoschSensortec/BME680_driver

    you need only 3 functions - read, write and delay :)

    hint: how to make this functions for Azure Linux - search sources for BME680 & Raspberry



    • Edited by WizIO.bg Tuesday, November 5, 2019 12:26 PM
    Tuesday, November 5, 2019 12:24 PM
  • I have already integrated this driver. I'm looking to use higher-level processing.
    Tuesday, November 5, 2019 1:00 PM
  • Hi Jeremy,

    Were you able to find a solution\workaround? If so please mark the answer as answered so others can benefit from your research.

    Thank you!

    Wednesday, December 4, 2019 11:10 AM
  • The answer is the library was not compatible with the environment.

    The source for that library is not available, therefore you cannot use the BSEC with Linux on the Cortex-A7.

    My work-around (hack) was to use the BSEC library for the M4 core in a real-time app and pass the data from the high-level app for processing.

    I did try using the M4F build of the library, but I ran into multiple problems:

    1. By default,  the .cmake file in the Azure Sphere toolchain does not compile with the hard float option.

    2. Also, I was getting hard faults when trying to use floating point operations, so perhaps there is some other hardware restriction?

    • Marked as answer by Jeremy_K Thursday, December 5, 2019 12:46 AM
    Thursday, December 5, 2019 12:45 AM
  • BTW: M4F work fine with hard float - I run last FreeRTOS version with hard-float ...

    https://www.youtube.com/watch?v=9-ozj0XCyF8

    Thursday, December 5, 2019 7:43 AM