Trouble configuring project for BME 688 sensor and nrf52840

SDK version - v2.7.0

Project repository

Hi! I am a junior embedded systems software developer, and I just started working with Nordic's environment. This is my first time using an external library, and I’m having trouble with the BME68X sensor.

I began by creating a new application by copying the "BME68X Sensor Sample" and quickly realized that I needed to download the external library separately, which I did.

I proceeded to download the BME68X library and placed the relevant files in the location shown at the end of this post (see the CMakeLists.txt content). I also downloaded the BSEC static library. Then I built the project to check for any errors, and I encountered the following:


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/emericopedrazagomez/Documents/zephyr/bme68x_iaq/build
-- west build: building application
ninja: error: '/opt/nordic/ncs/v2.7.0/modules/lib/bsec/src/cortex-m4/fpv4-sp-d16-hard/libalgobsec.a', needed by 'zephyr/zephyr_pre0.elf', missing and no known rule to make it
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/f8037e9b83/bin/cmake --build /Users/emericopedrazagomez/Documents/zephyr/bme68x_iaq/build


I don’t fully understand how to include external pre-compiled libraries yet. Based on this example, it seems that I just need to add the location of the .a file and the directory of the other files using the library. So I added the following lines to my CMakeLists.txt:

add_library(mylibalgobsec STATIC IMPORTED GLOBAL)
set_target_properties(mylibalgobsec PROPERTIES IMPORTED_LOCATION {$LIB_DIR}/BSEC/algo/bsec_IAQ/bin/gcc/Cortex_M4/libalgobsec.a)
set_target_properties(mylibalgobsec PROPERTIES INTERFACE_INCLUDE_DIRECTORIES /opt/nordic/ncs/v2.7.0/modules/lib/bme68x/src/bme68x)
target_link_libraries(app PUBLIC mylibalgobsec)

However, I’m still getting the same error when building the application. Why do I need to use the location shown in the error?

I tried moving the files to that location, which resulted in different errors, but I’d like to understand what I’m doing wrong here first.

I apologize if this question seems basic—any help would be appreciated!

  • My bad, the name is different in the toolchain, you will find this exe with little different name in this path

    toolchains/ce3b5ff664/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc                                                                                                                        

  • I see, thanks. When I run the command

    readelf -A /path/to/libalgobsec.a

    I can see many libraries, each of them containing many Tags, but none of them has the Tag_ABI_VFP_args tag. If the tag is missing, does it mean the library uses soft float? Here's an example of the output from only one object file inside libalgobsec.a

    File: libalgobsec.a(sortIdx.o)
    ELF Header:
      Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
      Class:                             ELF32
      Data:                              2's complement, little endian
      Version:                           1 (current)
      OS/ABI:                            UNIX - System V
      ABI Version:                       0
      Type:                              REL (Relocatable file)
      Machine:                           ARM
      Version:                           0x1
      Entry point address:               0x0
      Start of program headers:          0 (bytes into file)
      Start of section headers:          1000 (bytes into file)
      Flags:                             0x5000000, Version5 EABI
      Size of this header:               52 (bytes)
      Size of program headers:           0 (bytes)
      Number of program headers:         0
      Size of section headers:           40 (bytes)
      Number of section headers:         10
      Section header string table index: 9
    
    Section Headers:
      [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
      [ 0]                   NULL            00000000 000000 000000 00      0   0  0
      [ 1] .text             PROGBITS        00000000 000034 0001c0 00  AX  0   0  4
      [ 2] .rel.text         REL             00000000 000394 000008 08   I  7   1  4
      [ 3] .data             PROGBITS        00000000 0001f4 000000 00  WA  0   0  1
      [ 4] .bss              NOBITS          00000000 0001f4 000000 00  WA  0   0  1
      [ 5] .comment          PROGBITS        00000000 0001f4 00007a 01  MS  0   0  1
      [ 6] .ARM.attributes   ARM_ATTRIBUTES  00000000 00026e 00002e 00      0   0  1
      [ 7] .symtab           SYMTAB          00000000 00029c 0000b0 10      8   9  4
      [ 8] .strtab           STRTAB          00000000 00034c 000046 00      0   0  1
      [ 9] .shstrtab         STRTAB          00000000 00039c 000049 00      0   0  1
    Key to Flags:
      W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
      L (link order), O (extra OS processing required), G (group), T (TLS),
      C (compressed), x (unknown), o (OS specific), E (exclude),
      D (mbind), y (purecode), p (processor specific)
    
    There are no section groups in this file.
    
    There are no program headers in this file.
    
    There is no dynamic section in this file.
    
    Relocation section '.rel.text' at offset 0x394 contains 1 entry:
     Offset     Info    Type            Sym.Value  Sym. Name
    00000064  0000090a R_ARM_THM_CALL    00000000   __aeabi_fcmple
    
    There are no unwind sections in this file.
    
    Symbol table '.symtab' contains 11 entries:
       Num:    Value  Size Type    Bind   Vis      Ndx Name
         0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
         1: 00000000     0 FILE    LOCAL  DEFAULT  ABS sortIdx.c
         2: 00000000     0 SECTION LOCAL  DEFAULT    1 .text
         3: 00000000     0 SECTION LOCAL  DEFAULT    3 .data
         4: 00000000     0 SECTION LOCAL  DEFAULT    4 .bss
         5: 00000000     0 NOTYPE  LOCAL  DEFAULT    1 $t
         6: 00000001   254 FUNC    LOCAL  DEFAULT    1 ogtmbyichanvwdex[...]
         7: 00000000     0 SECTION LOCAL  DEFAULT    5 .comment
         8: 00000000     0 SECTION LOCAL  DEFAULT    6 .ARM.attributes
         9: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND __aeabi_fcmple
        10: 00000101   192 FUNC    GLOBAL DEFAULT    1 insdmaxrflhpgwqy
    
    No version information found in this file.
    Attribute Section: aeabi
    File Attributes
      Tag_CPU_name: "7E-M"
      Tag_CPU_arch: v7E-M
      Tag_CPU_arch_profile: Microcontroller
      Tag_THUMB_ISA_use: Thumb-2
      Tag_ABI_PCS_wchar_t: 4
      Tag_ABI_FP_denormal: Needed
      Tag_ABI_FP_exceptions: Needed
      Tag_ABI_FP_number_model: IEEE 754
      Tag_ABI_align_needed: 8-byte
      Tag_ABI_align_preserved: 8-byte, except leaf SP
      Tag_ABI_enum_size: small
      Tag_ABI_optimization_goals: Aggressive Speed
      Tag_CPU_unaligned_access: v6

    I tried filtering the output to search for Tag_ABI_VFP

    readelf -A /path/to/libalgobsec.a | grep -i "Tag_ABI_VFP"

    But I did not get any matches among all the object files.

    Does this mean I would need to create my own library to use the sensor?

    P.D: The gcc info of the library is:
    GCC: (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]

    And the version of the compiler inside the toolchain is:
    arm-zephyr-eabi-gcc (Zephyr SDK 0.16.5-1) 12.2.0

    I appreciate your help during this process. 

Related