Adding 3rd party Library in AWS Freertos

Hello,

I have been trying to add a 3rd party library into AWS freertos and I tried tried adding it to /vendors/espressif/esp-idf/components/ and also under libraries/3rdparty but am failing to port it fully (maybe due to Cmakelists.txt).

I am trying to port this library
Please help me out.

Thanks in advance.

You should add what exactly you’ve tried so far and describe/post the problem. That provides a better starting point for others to help.

1 Like

So in libraries/3rdparty/Cmakelist.txt I added this part

if(EXISTS "${AFR_3RDPARTY_DIR}/depthai-spi-api")
    set(depthai-spi-api_src
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/datatype/DatatypeEnum.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/general/data_writer.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/logger/logs_writer.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/stream/stream_info.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/xlink/xlink_wrapper.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/disparity_luts.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src/json_helper.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/nlohmann/json.hpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/decode_raw_mobilenet.c"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/decode_raw_mobilenet.h"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/esp32_spi_impl.c"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/esp32_spi_impl.h"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/spi_api.hpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/spi_api.cpp"
    )
    add_library(
        afr_3rdparty_depthai-spi-api STATIC EXCLUDE_FROM_ALL
        ${depthai-spi-api_src}
    )
    target_sources(
        afr_3rdparty_depthai-spi-api
        PRIVATE
            ${depthai-spi-api_src}
    )
    target_include_directories(
        afr_3rdparty_depthai-spi-api
        PUBLIC
            "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/src"
    )
    target_link_libraries(
        afr_3rdparty_depthai-spi-api
        PRIVATE AFR::compiler::mcu_port
    )
    target_compile_options(
        afr_3rdparty_depthai-spi-api
        PRIVATE
            $<$<C_COMPILER_ID:GNU>:-w>
    )
    add_library(3rdparty::depthai-spi-api ALIAS afr_3rdparty_depthai-spi-api)
endif()

And I added in #include “decode_raw_mobilenet.h” in vendors/espressif/boards/esp32/aws_demos/application_code/main.c which is throwing the error “fatal error: decode_raw_mobilenet.h: No such file or directory
#include “decode_raw_mobilenet.h””

Maybe I’m completely wrong shouldn’t you set ${AFR_3RDPARTY_DIR}/depthai-spi-api/common in target_include_directories ?

Thank you @hs2

It worked by adding the following block in /vendors/espressif/boards/esp32/CMakeLists.txt

target_include_directories(
    AFR::kernel::mcu_port
    INTERFACE
        ${kernel_inc_dirs}
        "${AFR_KERNEL_DIR}/portable/ThirdParty/GCC/Xtensa_ESP32/include/"
        "${aws_credentials_include}"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api"
        "${board_dir}/config_files"
        "$<$<NOT:${AFR_METADATA_MODE}>:${CMAKE_BINARY_DIR}/config>"
)

Thanks @Prakash for reporting back your solution !

I am facing the same issue. Please keep suggesting such answer to my issue.

MyAARPMedicare

As suggested by @hs2 I added library directory paths in target_include_directories and also the library files under target_sources

Something like

target_sources(
    AFR::kernel::mcu_port
    INTERFACE
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/common/xxx.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-shared/yyy.cpp"
        "${AFR_3RDPARTY_DIR}/depthai-spi-api/depthai-spi-library/zzz.cpp"
)