Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

richard.kang
Posts: 8
Joined: Tue Mar 01, 2016 7:25 am

Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

Postby richard.kang » Wed Jun 10, 2020 12:07 am

I attempted to include aws-iot-device-sdk-cpp-v2 into my esp-idf CMake project but encountered the following errors, how do I resolve?

Error as follows:

Code: Select all

esp-idf-template % idf.py build
Executing action: all (aliases: build)
Running ninja in directory ~/Documents/github/esp-idf-template/build
Executing "ninja all"...
[0/1] Re-running CMake...
-- Building ESP-IDF components for target esp32
CMake Error at ~/Documents/github/esp-idf/tools/cmake/component.cmake:221 (message):
  CMake Error at
  ~/Documents/github/esp-idf-template/components/aws-iot-device-sdk-cpp-v2/CMakeLists.txt:2
  (project):

    project command is not scriptable

  Call Stack (most recent call first):

    ~/Documents/github/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:60 (include)
    ~/Documents/github/esp-idf/tools/cmake/scripts/component_get_requirements.cmake:76 (__component_get_requirements)

  

  

Call Stack (most recent call first):
  ~/Documents/github/esp-idf/tools/cmake/build.cmake:405 (__component_get_requirements)
  ~/Documents/github/esp-idf/tools/cmake/project.cmake:395 (idf_build_process)
  CMakeLists.txt:6 (project)


-- Configuring incomplete, errors occurred!
See also "~/Documents/github/esp-idf-template/build/CMakeFiles/CMakeOutput.log".
FAILED: build.ninja 
~/.espressif/tools/cmake/3.16.4/CMake.app/Contents/bin/cmake -S~/Documents/github/esp-idf-template -B~/Documents/github/esp-idf-template/build
ninja: error: rebuilding 'build.ninja': subcommand failed
ninja failed with exit code 1
These are my steps:
1. Clone the esp-idf-template

Code: Select all

~/Documents/github % git clone https://github.com/espressif/esp-idf-template.git
2. Clone the aws-iot-device-sdk-cpp-v2 and update to pull in recursively

Code: Select all

~/Documents/github % cd esp-idf-template 
~/Documents/github/esp-idf-template % mkdir components && cd components
~/Documents/github/esp-idf-template/components % git submodule add https://github.com/aws/aws-iot-device-sdk-cpp-v2.git && git submodule update --init --recursive
3. Update the CMakeLists.txt in main/ folder to include aws-iot-device-sdk-cpp-v2

Code: Select all

set(COMPONENT_REQUIRES aws-iot-device-sdk-cpp-v2)
3. Attempt to build

Code: Select all

 ~/Documents/github/esp-idf-template % idf.py build

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

Postby ESP_Angus » Wed Jun 10, 2020 1:14 am

Hi Richard,

The aws-iot-device-sdk-cpp-v2 project uses CMake build system but it's not an ESP-IDF component. This is why you see an error when it's included in the ESP-IDF build process as an ESP-IDF component.

There are two longer answers here:

The first answer is that it's likely that making the AWS IoT C++ SDK work on ESP-IDF is a lot of additional work, not just the build system. The README for the project says "The C++ SDK was specifically designed for devices that are not resource constrained", and as far as I know there is not even support for this SDK on Amazon FreeRTOS (which also supports ESP32, the A:FreeRTOS ESP32 port uses ESP-IDF libraries internally).

So getting the build system to work would likely be the first in a series of porting steps. Not meaning to totally discourage you, it's probably possible - at least if your ESP32 has PSRAM. But it would likely require significant porting work, and the resource footprint at the end may still be a bit excessive.


Currently the supported way to access AWS IoT from ESP-IDF is with the C SDK:
https://github.com/espressif/esp-aws-iot

--

The second answer is about the build system details. There are two ways to build a third party CMake project with ESP-IDF. One is to wrap one or more third party CMake library projects into an ESP-IDF component, the other is to include ESP-IDF itself as a library in a third party CMake executable project.

Both methods have examples provided in ESP-IDF and are documented here:
https://docs.espressif.com/projects/esp ... components

(Note: these are docs for the master branch v4.2-dev of ESP-IDF, use the version switcher if you're using v4.0.x or v4.1. Although any differences will be minor.)

richard.kang
Posts: 8
Joined: Tue Mar 01, 2016 7:25 am

Re: Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

Postby richard.kang » Wed Jun 10, 2020 1:47 am

Thanks for the quick response Angus, especially the second answer about the build system!

Reason of looking at aws-iot-device-sdk-cpp-v2 is that we would like to use the AWS Provisioning API that has been committed into the master branch of aws-iot-device-sdk-cpp-v2 (https://github.com/aws/aws-iot-device-s ... bc05a97e4c).

However, that feature somehow is in a different branch for the aws-iot-device-sdk-embedded-C version (https://github.com/aws/aws-iot-device-s ... oning_beta).

Another question: How frequent do https://github.com/espressif/esp-aws-iot merge the changes from https://github.com/espressif/aws-iot-de ... embedded-C? I see the version of the submodule used was 2018 (https://github.com/espressif/aws-iot-de ... 10eaca62cf).

ESP_Mahavir
Posts: 188
Joined: Wed Jan 24, 2018 6:51 am

Re: Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

Postby ESP_Mahavir » Wed Jun 10, 2020 7:02 am

Hi Richard,

If you see here https://github.com/aws/aws-iot-device-s ... C/releases, last stable release was from 2018 time-frame. We typically move to newer releases as and when they are available upstream.

Mahavir

richard.kang
Posts: 8
Joined: Tue Mar 01, 2016 7:25 am

Re: Include aws-iot-device-sdk-cpp-v2 in esp-idf CMake

Postby richard.kang » Wed Jun 10, 2020 11:18 pm

Gotcha, really appreciate all the details!

Who is online

Users browsing this forum: Majestic-12 [Bot] and 210 guests