How to develop for ESP-IDF (ESP32) on VSCode Windows
A step by step tutorial on setting up Espressif’s IDE (the IDF) on Windows 10.
You can code in ESP-IDF in any IDEs. Personally I’ve used Visual Studio 2017 and 2019 with an always on terminal with IDF monitor for years. Recently Espressif released their own Visual Studio Code extension, I thought I’d give it a try.
Unfortunately, when trying to install the extension to my Visual Studio Code as in official docs, this issue happens:
‘xtensa-esp32s2-elf-gcc’ is not recognized as an internal or external command,
The popular solution is a clean install, but I don’t want to loose my VSCode configuration.
My solution for a working ESP32 IDE in VSCode⌗
First, create a second, portable instance of VSCode.
To do this:
- Download .zip variant of vscode.
- Extract it.
- Add
data
andtmp
directories next toCode.exe
.
Then install official Espressif IDF VSCode Extension. Docs say to also install Visual Studio C++ build tools, not verified as I had them allready installed with Visual Studio 2019. Do not install CMake Tools when prompted, you will not use them with ESP-IDF - it has its own build system.
Run command “ESP-IDF: Configure ESP-IDF extension”, apply defaults.
Run command “ESP-IDF: Create project from extension template”
Run command “ESP-IDF: Select port to use” (or plug button on bottom bar)
Run command “ESP-IDF: Build, flash and start a monitor on your device” (or fire button on bottom bar; or control + e
d
chord)
It might be a good idea to change theme and shortcut icon.
Don’t forget to install drivers for UART. My boards use
- CP2102 (select downloads tab, install CP210x Windows Drivers; direct link to driver)
- RS232-HS, best to follow the official Espressif guide.
For UART from ftdi-drivers: find Windows in table, then in the comments column download setup executable; direct link.
Failure running OpenOCD⌗
But who knows, perhaps it’ll be a missing puzzle piece for someone that has this issue in the future.
Not everything worked correctly. I was not able to run OpenOCD (gdb debugging).
I am using an early revision of ESP-WROVER-KIT.
First install UART:
(as per manual) Install zadig, in zadig -> options -> list all devices, select RS232-HS (Interface 0), replace (reinstall) driver
This causes a Microsoft Serial BallPoint in device manager instead of proper device.
In VSCode OpenOCD, error pointing to switch to boards/esp32-wrover-kit-1.8v.cfg
.
After switching got an error:
embedded:st❌ artup.tcl:26: Error: Can’t find boards/esp32-wrover-kit-1.8v.cfg
(yes, with this cross emoji in the middle of log)
fix in settings.json
, change:
"idf.openOcdConfigs": [
"interface/ftdi/esp32_devkitj_v1.cfg",
"target/esp32.cfg"
]
to
"idf.openOcdConfigs": [
"C:/Users/chanibal/.espressif/tools/openocd-esp32/v0.10.0-esp32-20210401/\
openocd-esp32/share/openocd/scripts/interface/ftdi/esp32_devkitj_v1.cfg",
"target/esp32.cfg"
]
get error:
❌ Error: JTAG❌ scan chain interrogation failed: all ones
Error: Check JTAG interface, timings, target power, etc.
Error: Trying to use configured scan chain anyway…
❌ Error: esp32.cpu0: IR capture error; saw 0x1f not 0x01
Warn : Bypassing JTAG setup events due to errors
Info : Listening on port 3333 for gdb connections
This is the place I’m currently stuck.
Changelog⌗
- 2021-08-31 Initial document
- 2022-01-11 Cleanup and publish