Running Multiple Versions of ESP-IDF concurrently
Asked Answered
N

3

5

Just had a go at running up the most recent version of ESP-IDF on my machine. All good.

Current Version = 4.3.2 Latest Version = 5.0.1

I work in Visual Studio, but use the ESP cmd terminal directly to build etc. Haven't managed to figure out the Visual Studio plug ins properly.

But when I tried to go back to the old version, ran into an error. The error was already picked up in github: https://github.com/espressif/esp-idf/issues/9837 . So I was able to repair my working version by deleting the ~/.espressif/idf-env.json file and rerun $IDF_PATH/install.sh.

My question here is this - is it possible to run 2 versions of ESP-IDF at once on the same machine? What settings are needed to achieve this?

Cheers.

Nonego answered 23/3, 2023 at 5:28 Comment(0)
L
6

It's quite simple if you install them into separate directories using the manual installation procedure

Let's assume you wish to install ESP-IDF v4 into ~/espressif/v4 and v5 into ~/espressif/v5.

First install v4:

$ export IDF_TOOLS_PATH="$HOME/espressif/v4/bin" IDF_PATH="$HOME/espressif/v4/esp-idf"
$ mkdir -p "$HOME/espressif/v4" && cd "$HOME/espressif/v4"
$ git clone -j8 -b v4.3.2 --recursive https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ ./install.sh
$ . export.sh

Then v5:

$ export IDF_TOOLS_PATH="$HOME/espressif/v5/bin" IDF_PATH="$HOME/espressif/v5/esp-idf"
$ mkdir -p "$HOME/espressif/v5" && cd "$HOME/espressif/v5"
$ git clone -j8 -b v5.0.1 --recursive https://github.com/espressif/esp-idf.git
$ cd esp-idf
$ ./install.sh
$ . export.sh

Using the command line you can subsequently activate either one of them running the usual environment setup:

$ export IDF_TOOLS_PATH="$HOME/espressif/v4/bin" IDF_PATH="$HOME/espressif/v4/esp-idf" && . "$IDF_PATH/export.sh"

or

$ export IDF_TOOLS_PATH="$HOME/espressif/v5/bin" IDF_PATH="$HOME/espressif/v5/esp-idf" && . "$IDF_PATH/export.sh"

As for VSCode, you can tell its ESP-IDF plugin which one you want to use. Here are some instructions (sorry, I'm too lazy to adapt them to the specific example above): https://github.com/DaStoned/beegram#optional-visual-studio-code-setup

If you have different VSCode workspaces with different versions of ESP-IDF, make sure you're saving this setting on Workspace level (as opposed to global level).

Lackadaisical answered 23/3, 2023 at 15:21 Comment(3)
A few clarifications. I'm working in windows, so using the bat files - shouldn't make a difference... Why are your tool paths in a bin dir? Aren't tools in IDF_PATH/tools? Does Espressif have a standard folder structure - seems my v5 went into C:/Espressif/frameworks by default. And 4.3 went into ~/esp-idf. And I also have a ~/.espressif folder. This is so confusing?!?!Nonego
TBH I'm not entirely sure where the tools are installed by default these days. Back in 3.x they were installed into a random directory in my home (possibly ~/.espressif) so I just picked my own location which is guaranteed to be unique. I don't want them to be installed under $IDF_PATH because it makes the git repo dirty :) I don't pay much attention to their standard folder structure as I have my own plan. The point is, you can customize your installation by setting those two environment variables (IDF_PATH, IDF_TOOLS_PATH) beforehand.Lackadaisical
Got it. That seems like extremely good advice. Will follow.Nonego
A
0

You can add the following command to add environment setup as alias in ~/.zprofile or wherever it is.

alias get_idf_v5="export IDF_TOOLS_PATH=\"$HOME/espressif/v5/bin\" IDF_PATH=\"$HOME/espressif/v5/esp-idf\" && source ~/espressif/v5/esp-idf/export.sh"

Sorry for opening a new post. I cannot comment under your post because of my reputation score.Thanks for your post, it was very clear.@Tarmo

Arboriculture answered 22/11, 2023 at 9:24 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Noumenon
B
0

I have a slow 5mbs internet access and using the above process received different errors in the clone mainly in 'gitting' the sub components. One of the errors received is "RPC failed; curl 92 HTTP/2 stream 0 was not closed cleanly: CANCEL (err 8)". There are other RPC failed messages too.

Anyway after 3 or 4 days of failing attempts, much searching, finally the -j8 on the clone caught my eye. I changed it to -j1 and now I can install the IDFs. Probably this day and age few have such a slow internet connection but for those that run into the problem maybe they will find this and save them a few missing or grey hairs.

I really appreciate the instructions for multiple versions of IDF above. It does just what I was looking for as I have multiple projects deployed and don't want to upgrade the IDF unless there is a problem that requires an upgrade.

Blood answered 21/4 at 23:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.