How to build esp-rainmaker examples in VSC (esp idf)

asierdo
Posts: 11
Joined: Mon Sep 18, 2023 10:37 am

How to build esp-rainmaker examples in VSC (esp idf)

Postby asierdo » Tue Nov 07, 2023 9:05 am

Hi,
I'm getting started with esp rainmaker. I can see that web guide explain how to get start with CLI esp idf, but I can't find any information about how to build esp rainmaker examples with Visual Studio Code. I try to do that but I get some issues about setting up IDE in right way.

I've done next steps:
1 - From VSC "View/Command palette..." execute "ESP-IDF: Install ESP-Rainmaker", so we get "C:\Users\ASIER.DINUY\.espressif\esp-rainmaker" directory.
2- Then I do "Code ." from "C:\Users\ASIER.DINUY\.espressif\esp-rainmaker\examples\led_light" and VSC is opened.
3- I select target esp32c3 and COM port.

In here, trying to build, we get the following problems:

Executing task: cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B c:\Users\ASIER.DINUY\.espressif\esp-rainmaker\examples\led_light\build -S c:\Users\ASIER.DINUY\.espressif\esp-rainmaker\examples\led_light

-- Found Git: C:/Users/ASIER.DINUY/.espressif/tools/idf-git/2.30.1/cmd/git.exe (found version "2.30.1.windows.1")
-- Component directory C:/Users/ASIER.DINUY/.espressif/esp-rainmaker/components/esp-insights does not contain a CMakeLists.txt file. No component will be added
-- The C compiler identification is GNU 11.2.0
-- The CXX compiler identification is GNU 11.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/ASIER.DINUY/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/ASIER.DINUY/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/ASIER.DINUY/.espressif/tools/riscv32-esp-elf/esp-2022r1-11.2.0/riscv32-esp-elf/bin/riscv32-esp-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32c3
Solving dependencies requirements
........CMake Error at C:/Users/ASIER.DINUY/esp/esp-idf/tools/cmake/build.cmake:519 (message):
ERROR: Can't reliably evaluate relative path without context:
..\rmaker_common

Call Stack (most recent call first):
C:/Users/ASIER.DINUY/esp/esp-idf/tools/cmake/project.cmake:440 (idf_build_process)
CMakeLists.txt:16 (project)


-- Configuring incomplete, errors occurred!
See also "C:/Users/ASIER.DINUY/.espressif/esp-rainmaker/examples/led_light/build/CMakeFiles/CMakeOutput.log".

* The terminal process "C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -Command cmake -G Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B c:\Users\ASIER.DINUY\.espressif\esp-rainmaker\examples\led_light\build -S c:\Users\ASIER.DINUY\.espressif\esp-rainmaker\examples\led_light" terminated with exit code: 1.


How should I configure the environment to solve these issues ?

Thanks so much,
Asier.

JoshNOA
Posts: 25
Joined: Wed Aug 02, 2023 12:19 pm

Re: How to build esp-rainmaker examples in VSC (esp idf)

Postby JoshNOA » Thu Nov 09, 2023 12:06 pm

Hey bud,

Just saw this in passing and maybe I can give a few pointers, as someone who uses IDF with VSC everyday.

Firstly, id use docker for setting up the dev environment (even if you dont really have experience with docker) its easier to learn docker than it is decipher the IDF readmes.

Secondly, your error is CMAKE in nature, as far as I can tell. You are trying to reference the examples in their original folders, but CMAKE is trying to find resources relative to these paths, and its not finding the rmaker_common directory in any of them.

You should build your project above the .espressif folder, and as such I would recco working with docker again, as youll only have to go through this trouble once and you will have a portable dev environment.

Once you have a functional docker within VSC expressed as a devcontainer.json, you will be able to go straight into the examples folder, attach the container, and use the examples as you are currently attempting.

Best of Luck,

JC

asierdo
Posts: 11
Joined: Mon Sep 18, 2023 10:37 am

Re: How to build esp-rainmaker examples in VSC (esp idf)

Postby asierdo » Fri Nov 10, 2023 5:28 pm

Hi joshNOA,

Thanks for replying.

I don't want to introduce more new variables to my problem, so I leave docker and containers functionality to the future.

My goal is to build "..\esp-rainmaker\examples\led_light" example in VSC IDE. So, I open the folder in VSC and firstly I do "ESP-IDF: Add vscode configuration folder" from command palette. It creates "c_cpp_properties.json", "settings.json".. in .vscode folder.

Next I define "idf.espIdfPathWin" and "idf.toolsPathWin" in settings.json file.

I modify project's "CMakeLists.txt" file to add the correct path for EXTRA_COMPONENT_DIRS, that way:

set(MY_PATH C:/Users/ASIER.DINUY/.espressif/esp-rainmaker)
set(EXTRA_COMPONENT_DIRS ${MY_PATH}/components/esp-insights/components ${MY_PATH}/components ${MY_PATH}/examples/common)

After doing those modification I get same issues:
Component directory C:/Users/ASIER.DINUY/.espressif/esp-rainmaker/components/esp-insights does not contain a CMakeLists.txt file. No component will be added

Solving dependencies requirements
........CMake Error at C:/Users/ASIER.DINUY/esp/esp-idf/tools/cmake/build.cmake:519 (message):
ERROR: Can't reliably evaluate relative path without context:
..\rmaker_common

Any solution ?

Thank you,
Asier.

ESP_Piyush
Posts: 309
Joined: Wed Feb 20, 2019 7:02 am

Re: How to build esp-rainmaker examples in VSC (esp idf)

Postby ESP_Piyush » Fri Nov 10, 2023 7:24 pm

Seems this error is coming via the dependencies specified for component manager, so it will be worthwhile to pull rainmaker and its dependencies directly via component manager. For this, remove the ${RMAKER_PATH}/components/esp-insights/components and ${RMAKER_PATH}/components from CMakeLists.txt file and also remove the override paths from examples/common/app_insights/idf_component.yml. Here is a patch to show what these changes are.

Code: Select all

 diff --git a/examples/common/app_insights/idf_component.yml b/examples/common/app_insights/idf_component.yml
 index c39581f..fc3c13c 100644
 --- a/examples/common/app_insights/idf_component.yml
 +++ b/examples/common/app_insights/idf_component.yml
 @@ -2,7 +2,5 @@
  dependencies:
    espressif/esp_rainmaker:
      version: "~1.0.0"
 -    override_path: '../../../components/esp_rainmaker/'
    espressif/esp_insights:
      version: "~1.0.1"
 -    override_path: '../../../components/esp-insights/components/esp_insights/'
 diff --git a/examples/led_light/CMakeLists.txt b/examples/led_light/CMakeLists.txt
 index 8ce742d..7f59ae7 100644
 --- a/examples/led_light/CMakeLists.txt
 +++ b/examples/led_light/CMakeLists.txt
 @@ -9,7 +9,7 @@ else()
  endif(DEFINED ENV{RMAKER_PATH})
 
  # Add RainMaker components and other common application components
 -set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/components/esp-insights/components ${RMAKER_PATH}/components ${RMAKER_PATH}/examples/common)
 +set(EXTRA_COMPONENT_DIRS ${RMAKER_PATH}/examples/common)
 
  set(PROJECT_VER "1.0")
  include($ENV{IDF_PATH}/tools/cmake/project.cmake)
 -- 
 2.37.3
Please try recompiling after these changes and let me know if it helps.

asierdo
Posts: 11
Joined: Mon Sep 18, 2023 10:37 am

Re: How to build esp-rainmaker examples in VSC (esp idf)

Postby asierdo » Mon Nov 13, 2023 10:19 am

I modified both files as you said and now I can build the project.
Thank you so much,
Asier
Last edited by asierdo on Mon Nov 13, 2023 5:31 pm, edited 1 time in total.

ESP_Piyush
Posts: 309
Joined: Wed Feb 20, 2019 7:02 am

Re: How to build esp-rainmaker examples in VSC (esp idf)

Postby ESP_Piyush » Mon Nov 13, 2023 10:50 am

In this file, just delete the 2 lines that begin with override_path.

Who is online

Users browsing this forum: No registered users and 90 guests