VS code ESP IDF components issue

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

VS code ESP IDF components issue

Postby Jimis1 » Wed Sep 13, 2023 1:41 pm

I'm trying to take an example code from ESP IDF (https_advanced_ota) and put it inside a folder called "ota" so that it's not in the root and keep it tidy.
This creates a problem with the includes and declarations. I updated the cmakelists.txt files accordingly which was a bit of a nightmare to understand how they work. I think I managed to do most correctly, but I still get an error of a file not included, although I explicitly tell the compiler where the file is by providing the path in the #include statement and the c_cpp_properties.json

Can someone take a look and help me find the problem? I'm obviously missing something here.
Attachments
folders.zip
(31.38 KiB) Downloaded 548 times
2.jpg
2.jpg (185.36 KiB) Viewed 3005 times
1.jpg
1.jpg (233.12 KiB) Viewed 3005 times

ESP_Sprite
Posts: 9307
Joined: Thu Nov 26, 2015 4:08 am

Re: VS code ESP IDF components issue

Postby ESP_Sprite » Thu Sep 14, 2023 1:27 am

Yeah, don't use absolute paths like that, you should be able to simply #include "freertos/FreeRTOS.h". Your issue is that your component doesn't state it needs FreeRTOS so the build system doesn't include it in its include path. See here, but tl;dr is that you need to add a 'REQUIRES freertos' in your CMakeLists.txt.

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: VS code ESP IDF components issue

Postby Jimis1 » Thu Sep 14, 2023 10:50 am

Thanks a lot ESP_Sprite ! Really saved my day :)

I had been struggling to understand how these declarations (includes) of files work. The examples in ESP IDF documentation are very basic. I think I get it now so I can keep my code files tidy.I get some variables issues but I think I can sort them out.

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: VS code ESP IDF components issue

Postby Jimis1 » Fri Sep 15, 2023 8:44 am

The build stops but I see no errors. If I open a few files VScode finally start to show the errors (2nd pic).

The error seems to be socket.h missing but actually a variable inside it says is undefined.

I also have a question.

How do I find which components I need to include in the cmakelists.txt files in my case for the https_advanced_ota example ?
Screenshot_8.jpg
Screenshot_8.jpg (211.96 KiB) Viewed 2780 times
Screenshot_1.jpg
Screenshot_1.jpg (282.39 KiB) Viewed 2761 times
Screenshot_4.jpg
Screenshot_4.jpg (131.53 KiB) Viewed 2761 times

boarchuz
Posts: 575
Joined: Tue Aug 21, 2018 5:28 am

Re: VS code ESP IDF components issue

Postby boarchuz » Fri Sep 15, 2023 9:30 am

The red squiggles are courtesy of Intellisense, not the build process. Ideally the errors from both would be the same, but as you can see if there's any issue with the Intellisense configuration then you can get these annoying red herrings.

The build output contains your actual error. In this case, it's from the linker:
undefined reference to `_binary_ca_cert_pem_start`
Check the relevant CMakeLists.txt for EMBED_TXTFILES or EMBED_FILES containing the path to this file (ca_cert.pem), and that the file exists.
How do I find which components I need to include in the cmakelists.txt
When you're developing the component you can add dependencies as you use them. Or you can look through the 'include's in the component's source files which usually give a pretty good hint of what you need. But the easiest of all is probably to brute force it: keep trying to build, adding dependencies every time you get an undefined reference error in that component, until it builds successfully.

Jimis1
Posts: 35
Joined: Wed May 03, 2023 6:20 am

Re: VS code ESP IDF components issue

Postby Jimis1 » Fri Sep 15, 2023 11:59 am

Bullseye ! Thanks a lot boarchuz :)

I hadn't even noticed the `_binary_ca_cert_pem_start` part in the build output. I had to include that line you posted.
Intellisense has issues.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 65 guests