Search code examples
esp32esp-idfespressif-idf

Running Multiple Versions of ESP-IDF concurrently


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.


Solution

  • 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).