C for ESP-IDF? Dev Environment?

klaatu2
Posts: 5
Joined: Wed Feb 08, 2023 11:32 pm

C for ESP-IDF? Dev Environment?

Postby klaatu2 » Mon Mar 06, 2023 5:39 pm

I'm coming from an entirely different platform and hardware family. So I'm a little lost. :?:

Will be porting existing C code to the ESP32-S3

From what I can tell, the best path is to go with VS Code and install ESP-IDF in it.
When doing so, its offers 3 choices; Express, Advanced, "Use Existing Setup". Each seems to be focused on Python

Can someone point me to a document, page, video, which describes how to setup a C environment, in VS Code, for the ESP32?
I have installed the MS C/C++ extension in VS code

What headaches are ahead using C? I assume all the ESP32 libraries are all in Python?

Thanks,

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

Re: C for ESP-IDF? Dev Environment?

Postby ESP_Sprite » Wed Mar 08, 2023 1:03 am

klaatu2 wrote:
Mon Mar 06, 2023 5:39 pm
From what I can tell, the best path is to go with VS Code and install ESP-IDF in it.
When doing so, its offers 3 choices; Express, Advanced, "Use Existing Setup". Each seems to be focused on Python
Just go with the express setup then. The focus on Python is because a lot of ESP-IDF tools (which run on your PC to help generate/upload your ESP32 program) are written in Python.
What headaches are ahead using C? I assume all the ESP32 libraries are all in Python?
No, all code that runs on the ESP32 itself is written in C/C++, so you should have few problems integrating existing C code (given it's written in a somewhat portable way)

Thierry91
Posts: 6
Joined: Thu Mar 02, 2023 3:43 pm

Re: C for ESP-IDF? Dev Environment?

Postby Thierry91 » Wed Mar 08, 2023 4:29 pm

Same for me, I come from a different world.
Setting up a functional vs code environment took me a few retries and quite a lot of time before it works fine.

My advices :
-Fully uninstall vs code. The uninstaller does not erase all folders. Do it by hand (including a "code" folder that you will find somewhere in your directory tree under your user directory
-Erase all the folders with "espressif" and / or "idf" that you will find
-launch a brand new install of vs code
-in vs code, install the espressif extension, and only this one, no need for other extensions
-Express setup is fine
-From this point, always use the command palette tool for any action. It is in the "view" menu
-To create your project, in this palette use ESP-IDF: NewProject
-set up your params. You can leave le component field blank
-go to next page.
-Now it is very important to choose ESP-IDF in the first combo and then to select esp-idf/get-started/sample_projet
-Then click the "create project using template....." button which is top right of the screen. This will create for you an empty project AND set up all the environment so that all the tools work for you from inside vs code. If you don't do it this way, it will trough a lot of error at compile time
You can add c files and h files to you project using the + button locate in the explorer on the left side.
At some point you will have to launch "ESP-IDF: SDK configuration editor" to set the params of you target and preferably before your first compile
But remember that every time you change the structure of you project (add a file for exlample) you MUST re-run "ESP-IDF: SDK configuration editor" and click the save button even if you don't change any param. Otherwise it will not compile. Again it will set up the env accordingly to your project new structure.
Use the other "ESP-IDF:" commands that you will find in the palette to build you project

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

Re: C for ESP-IDF? Dev Environment?

Postby Craige Hales » Wed Mar 08, 2023 6:40 pm

agree, vs code is a good choice. Especially if you have used MS Visual Studio for development in the past: many of the keyboard short cuts will seem familiar.
It's still a long learning curve. I initially found the "flame" tool quite useful, then figured out control-e,d did the same thing...compile, upload, run. The top-left folder is the view you'll usually want.
vscode.png
vscode.png (384.97 KiB) Viewed 3222 times
I generally dislike dark mode, but the dark-high-contrast theme is working better for me than the light-high-contrast.

Use the View->CommandPalette and type to search. There is a lot of stuff hiding there.
Craige

MicroController
Posts: 1390
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: C for ESP-IDF? Dev Environment?

Postby MicroController » Thu Mar 09, 2023 6:09 pm

Can someone point me to a document, page, video, which describes how to setup a C environment, in VS Code, for the ESP32?
It's all there: https://docs.espressif.com/projects/esp ... index.html ;-)

Craige Hales
Posts: 94
Joined: Tue Sep 07, 2021 12:07 pm

Re: C for ESP-IDF? Dev Environment?

Postby Craige Hales » Fri Mar 10, 2023 5:11 pm

Especially the link at the bottom of the page
vcode.png
vcode.png (29.5 KiB) Viewed 3118 times
which will take you to https://github.com/espressif/vscode-esp ... install.md
Craige

User avatar
mbratch
Posts: 300
Joined: Fri Jun 11, 2021 1:51 pm

Re: C for ESP-IDF? Dev Environment?

Postby mbratch » Sat Mar 11, 2023 7:02 pm

klaatu2 wrote:
Mon Mar 06, 2023 5:39 pm
What headaches are ahead using C? I assume all the ESP32 libraries are all in Python?
Nope. ESP-IDF is written in C. You can find the source code on github.

fabianmejia
Posts: 2
Joined: Fri Feb 03, 2023 2:20 pm

Re: C for ESP-IDF? Dev Environment?

Postby fabianmejia » Sat Mar 11, 2023 10:14 pm

I've been using VS code already for about 2 months.
I am running on a lyrat-mini, and I was very skeptic about the setup.
To my surprise the esp_idf extension works like a charm. I just had to set the default installation (express) and compile one of the examples.
The extension already comes with all the things you need to develop your project.

One thing to note, I am using both c and c++ code.
klaatu2 wrote:
Mon Mar 06, 2023 5:39 pm
I'm coming from an entirely different platform and hardware family. So I'm a little lost. :?:

Will be porting existing C code to the ESP32-S3

From what I can tell, the best path is to go with VS Code and install ESP-IDF in it.
When doing so, its offers 3 choices; Express, Advanced, "Use Existing Setup". Each seems to be focused on Python

Can someone point me to a document, page, video, which describes how to setup a C environment, in VS Code, for the ESP32?
I have installed the MS C/C++ extension in VS code

What headaches are ahead using C? I assume all the ESP32 libraries are all in Python?

Thanks,

Who is online

Users browsing this forum: srjasz and 54 guests