ESP-IDF and VSCode Plugin Installation and Configuration in WSL
Preface
As we all know, installing ESP-IDF on Windows is quite difficult with extremely slow compilation speed. Usually, compiling a HelloWorld program takes 5 minutes or more.
However, in practice, ESP-IDF on Linux (WSL) has extremely fast compilation speed. The same HelloWorld program can be compiled in just 10 seconds.
This article mainly introduces the steps for installing ESP-IDF and its VSCode plugin on WSL.
Setting Up Windows Environment
Install Required Software
Required software on Windows:
- Visual Studio Code
- WSL 2
- WSL Ubuntu Distribution (Microsoft Store)
- Python 3.9
Note
- WSL is only available on Windows 10+, users on older Windows versions should use a virtual machine!
- WSL Ubuntu version should be 20.04+, this article uses version 22.04.
Configure WSL
Open a WSL window and execute the following commands to install required packages:
sudo apt update
sudo apt-get install git wget flex bison gperf python3-pip python3-venv python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-utilConfigure VSCode
Manually install
Remote - WSLfrom the VSCode Extensions interface (Extension ID:ms-vscode-remote.remote-wsl);Click the green icon in the bottom left corner of VSCode to bring up a similar page, select
New WSL Window. A new VSCode window should open, and the green icon in the bottom left should change toWSL:Ubuntu-22.04;
In the newly opened window, find the Extensions page, search for
Espressif IDF, and click theInstall in WSL:Ubuntu-22.04button as shown in the image, then wait for installation to complete;
After installation is complete, follow the instructions shown in the images to select the download source, change the installation path, click [Install], and continue waiting;

Patch ESP-IDF
In practice, at this point we can compile at ultra-fast speed, but we still cannot flash the program. According to the official documentation, we need to install usbipd to map the serial port, but this will encounter permission issues.
Here we utilize a magical feature (bug) of IDF: when flashing, the local PowerShell.exe is called, and naturally, the Python called is also local.
Therefore, we only need to install the corresponding dependencies locally to perfectly solve the problem. Steps:
- Copy the corresponding files from WSL Ubuntu or download
- ${IDF_PATH}/requirements.txt
- ${IDF_PATH}/tools/kconfig_new/esp-windows-curses
Tip
Place the copied requirements.txt and esp-windows-curses folder in the same directory.
Modify requirements.txt, change the following line (usually at the end)
file://${IDF_PATH}/tools/kconfig_new/esp-windows-curses; sys_platform == 'win32'to
./esp-windows-curses; sys_platform == 'win32'Then open Windows Terminal (whichever you prefer), navigate to the saved file directory, and execute
pip install -r requirements.txtWait a moment for the installation to complete. (If unsuccessful, try changing the package source)
Testing ESP-IDF Functionality
Open a folder in the VSCode window connected to WSL.
Press Ctrl + E, then press C, select Use current directory, and you can create an IDF project using a template.
Next, connect your development board, select the serial port in the bottom bar at [/dev/ttyUSB1]; then compile and flash (click the 🔥 icon to do both in one step)
After a moment, you will be able to see logs from the serial port monitor!
All Done!
Now you can enjoy blazingly fast 10-second compilation and flashing!