Page 1 of 1

VS Code Extension - Cmake help needed. (or other direction)

Posted: Sun Jul 18, 2021 10:49 pm
by -Rudy-
I am trying to run a series of examples with the VS Code Extension. The problem I have is with Cmake instructions.

I am trying to go through the examples in the Espressif ESP Jumpstart repository. https://github.com/espressif/esp-jumpstart
There are 7 incremental steps to the project.
  • 1_hello_world
  • 2_drivers
  • 3_wifi_connection
  • 4_network_config
  • 5_cloud
  • 6_ota
  • 7_mfg
I have been able to run the 1_hello_world example. I have not been able to compile 2_drivers.

There are function calls to an external library in 2_drivers. I can't figure out how to include this library into the Cmake instructions so that it can compile in the 2_drivers example code.

The included code is in Espressif esp-iot-solution. https://github.com/espressif/esp-iot-solution

I have gone through the ESP-IDF: Show Examples Projects and I have not been able to find any that include additional libraries. I have looked for other examples that I might learn from but I have found little, and what I have found has left me confused. I have read through some of the Build System documentation https://docs.espressif.com/projects/esp ... w-project but I am still totally confused.

I wish there was some working examples that went along the Build System documentation, and even more specifically, real examples with external libraries with the VS Code framework. This seems to be a big hole considering how detailed the Espressif documentation appears to be.

What I have is
C:\Users\Rudy\esp\esp-idf
C:\Users\Rudy\esp\esp-iot-solution
C:\Users\Rudy\ESP32-projects\esp-jumpstart\2_drivers


C:\Users\Rudy\ESP32-projects\esp-jumpstart\2_drivers
\.vscode
\build
\main
CMakeLists.txt
Makefile
sdkconfig
sdkconfig.old

C:\Users\Rudy\esp\esp-iot-solution
\components
\docs
\examples
\tools
component.cmake
component.mk

C:\Users\Rudy\esp\esp-iot-solution\components
\audio
\bus
\button
\display
\expander
\gui
\led
\motor
\sensors
\storage

C:\Users\Rudy\esp\esp-iot-solution\components\button The component needed
\include
\test
button_adc.c
button_gpio.c
CMakeLists.txt
component.mk
iot_button.c
Kconfig


C:\Users\Rudy\esp\esp-iot-solution\components\button\CMakeLists.txt
idf_component_register(SRCS "button_adc.c" "button_gpio.c" "iot_button.c"
INCLUDE_DIRS include
PRIV_REQUIRES esp_adc_cal)

What I want to do is to be able to make the available esp-iot-solution library available to whatever project needs it. If I can't do that then I would want to at least move the button component into the Jumpstart example files.

I am not a programmer. I have been playing around with the Arduino IDE for a few years. I am a hardware designer. Normally I design the hardware for a new product and it gets passed to a firmware programmer to write the code. The Engineering manager wanted me to use a WiFi radio from Microchip. I convinced him that the Espressif part would be a better choice. He said OK but then asked me to handle the code for this project. I have been designing electronics for 35 years. I know next to nothing about ESP-IDF and VS Code. The Espressif ESP-Jumpstart looks like it has a lot of what I need in this project. But I first need to get it to compile.

Re: VS Code Extension - Cmake help needed. (or other direction)

Posted: Mon Jul 19, 2021 4:29 am
by ESP_bignacio
HI Rudy,

As shown in the ESP-IOT project here, you need to add an include in your project's root CMakeLists.txt as shown below:

Code: Select all

cmake_minimum_required(VERSION 3.5)

include($ENV{IOT_SOLUTION_PATH}/component.cmake)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)

project(project-name)
in the previous case assuming you set an environment variable in your system called IOT_SOLUTION_PATH with the path to esp-iot-solution or just use the full path of component.cmake instead of $ENV{IOT_SOLUTION_PATH}/component.cmake.

After adding this, you should be able to include source code from ESP-IOT-Solution as you do in the ESP-IOT-SOLUTION examples.