Select Different ESP-IDF framework for different Projects with Visual Code

nefen1
Posts: 4
Joined: Sun Apr 17, 2022 4:12 am

Select Different ESP-IDF framework for different Projects with Visual Code

Postby nefen1 » Wed Jan 11, 2023 1:22 pm

I have three installed frameworks:
1. v4.2.3 (in a specific commit)
2. v4.4.2
3. v5.0

I would like to use different frameworks in different projects (folders or even Workspaces).
How can I do that?

Where does esp-idf extension for Visual Code gets the "current" or "default" framework to use?

ESP_bignacio
Posts: 229
Joined: Wed May 02, 2018 12:12 pm

Re: Select Different ESP-IDF framework for different Projects with Visual Code

Postby ESP_bignacio » Thu Jan 12, 2023 8:36 am

You can use multiple versions of ESP-IDF (one for each project) by define the extension configurations settings in each workspace folder as described in working with multiple projects documentation.

On your current open project, set idf.saveScope in your <project-dir>/.vscode/settings.json to WorkspaceFolder or with the ESP-IDF: Select where to save configuration settings. After that use the setup wizard settings will be set in the current workspace folder.

Close first project, open second project, repeat as previously shown.

nefen1
Posts: 4
Joined: Sun Apr 17, 2022 4:12 am

Re: Select Different ESP-IDF framework for different Projects with Visual Code

Postby nefen1 » Mon Jan 23, 2023 7:35 am

Thank you.

For Windows with VS Code, the simplest way I had found was to keep a different set of settings files and just paste them inside the settings.vscode.

Then, I thought it might be a more professional way and I had somewhere read that esp-idf add-on will find the different esp-idf installations when I run the "ESP-IDF: Configure ESP-IDF Extension" and will give me a choice to select one from the already installed.
I thought there might be a way to make this nice procedure to work.

I also had found that esp-idf extension looks for different esp-idf installation in file esp-idf.json located in the root of espressif installation folder. Actually the file is correctly set-up, though I haven't managed to make this process to work.

Anyway, following your instructions, I revert to my initial solution, which works!

So, in detail for anyone facing the same problem, I done the following:
a. I run ESP-IDF: Select where to save configuration settings and I selected global. Now all settings have been placed inside %APPDATA%\Code\User\settings.json
b. Then, for each esp-idf installation I would like to work in different projects:
1. I installed the esp-idf version.
2. I then made a copy of the above mentioned settings.json and renamed it according to the esp-idf I would like to use.
For example for esp-idf v4.4.2 I copied the file to settings4.4.2.json and kept only the vital se-up information to run esp-idf. So the file looked like this:
{
"idf.espIdfPathWin": "C:/Espressif/frameworks/esp-idf-v4.4.2/",
"idf.pythonBinPathWin": "C:/Espressif/python_env/idf4.4_py3.8_env/Scripts/python.exe",
"idf.toolsPathWin": "C:\\Espressif",
"idf.customExtraPaths": "C:\\Espressif\\tools\\xtensa-esp32-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32-elf\\bin;C:\\Espressif\\tools\\xtensa-esp32s2-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32s2-elf\\bin;C:\\Espressif\\tools\\xtensa-esp32s3-elf\\esp-2021r2-patch3-8.4.0\\xtensa-esp32s3-elf\\bin;C:\\Espressif\\tools\\riscv32-esp-elf\\esp-2021r2-patch3-8.4.0\\riscv32-esp-elf\\bin;C:\\Espressif\\tools\\esp32ulp-elf\\2.28.51-esp-20191205\\esp32ulp-elf-binutils\\bin;C:\\Espressif\\tools\\esp32s2ulp-elf\\2.28.51-esp-20191205\\esp32s2ulp-elf-binutils\\bin;C:\\Espressif\\tools\\cmake\\3.23.1\\bin;C:\\Espressif\\tools\\openocd-esp32\\v0.11.0-esp32-20220411\\openocd-esp32\\bin;C:\\Espressif\\tools\\ninja\\1.10.2;C:\\Espressif\\tools\\idf-exe\\1.0.3;C:\\Espressif\\tools\\ccache\\4.3\\ccache-4.3-windows-64;C:\\Espressif\\tools\\dfu-util\\0.9\\dfu-util-0.9-win64",
"idf.customExtraVars": "{\"OPENOCD_SCRIPTS\":\"C:\\\\Espressif\\\\tools\\\\openocd-esp32\\\\v0.11.0-esp32-20220411/openocd-esp32/share/openocd/scripts\",\"IDF_CCACHE_ENABLE\":\"1\"}",
"idf.gitPathWin": "C:/Espressif/tools/idf-git/2.34.2/cmd/git.exe"
}
3. At the end, I had one settings file per esp-idf installation.

Now, when I created a new esp-idf project, or opened an example, I just copied and pasted the above lines inside the project's .vscode\settings.json file to force esp-idf to use the specific version to compile this project.

I spent some time to end-up with this simple solution. I just hope to spare this time for anyone seeking a similar solution.

mtraven
Posts: 28
Joined: Thu Jul 07, 2022 3:34 am

Re: Select Different ESP-IDF framework for different Projects with Visual Code

Postby mtraven » Sun Apr 07, 2024 7:25 am

nefen1 wrote:
Mon Jan 23, 2023 7:35 am

Then, I thought it might be a more professional way and I had somewhere read that esp-idf add-on will find the different esp-idf installations when I run the "ESP-IDF: Configure ESP-IDF Extension" and will give me a choice to select one from the already installed.
I thought there might be a way to make this nice procedure to work.
found your post in the process of figuring that out on my own, thought I'd add my experience as of 2024, maybe save someone else a few hours.

You were on the right track in the config esp idf, or a least you would be with the current extension. The key was finding the "save scope" parameter and setting it to "workspace folder" (not global, or workspace). Older version versions had it @ the selection screen in (ESP-IDF:Config...), current version just reports it on that screen. the setting itself can be found in the extension settings page of vscode*.

That option will change the line directly above the "express installation" button @ (ESP-IDF:Config...).

by default (save scope = global) that line will read: "Configuration settings will be saved in User Settings"

after setting save scope = workspace, you'll see: ("Configuration settings will be saved in a Workspace Folder Settings."

now the framework you select, will only apply to your current project folder. whenever you open that workspace folder, it will be set to that framework. I able to literally compile one project on 5.2 and one on 4.4.7 in side by side vscode windows!

only messy part, to start a new project, from an example, with a particular framework, you'll need to put that setting back to global, since, before you've made a project, there is no project folder to store the configuration. Really makes me wonder why they removed that option from the config screen?!?

hope this helps someone!


this video helped me work this out, I dont even speak spanish (its in spanish)...but computers are computers!
https://www.youtube.com/watch?v=wECRvsFtfD8

*right pane->extensions->esp-idf->click the gear-->select "extension settings"

Who is online

Users browsing this forum: No registered users and 62 guests