Set up ESP32


To get started with ESP32, read through their documentation considering that the devkit I chose uses the WROVER-E chip. The Get Started page is the best place to start. They have Visual Studio Code and Eclipse plugins, but as I use emacs, I opted to install the components separately. If you're using windows, you can follow their Toolchain from Scratch guide and install the following:

The guide also requests installation of other tools. Once again, I went the "from scratch" route to better understand the pieces in case they fall apart later. The guide mentions "ESP-IDF build system expects that all the necessary tools are installed somewhere, and made available in the PATH." Here's the list of required tools and their download links. Below is what I needed.

Then set IDF_PATH environment variable to the path of esp-idf-v4.0.4 directory.

To install the python dependencies for, use the requirements.txt file under the esp-idf-v4.0.4 directory. Make sure to fix any warning like "pyserial not in path" as idf needs those tools to do its job.

Once all the tools are downloaded and added to PATH, we can compile and run a sample project.


I prefer to work on Linux and so the setup was a bit easier. On linux I opted to use the master branch of their git repository rather than a release version.

  1. Install the required packages, download crosscompiling toolchain, binutils for esp32, openocd for esp32, and ESP-IDF (clone recursively).

  2. Add their respective paths to PATH. I added the following snippet in my $HOME/.profile.

    for d in $(find /home/armin/pkgs/esp32 -name bin -type d); do
  3. If you're using ubuntu, also install python-is-python3 to squash the error about missing python.

  4. Install python packages from esp-idf's requirements.txt.

  5. menuconfig also requires libncurses header files (libncurses-dev in ubuntu).

Once all the tools are downloaded and added to PATH, we can compile and run a sample project. Make sure to add your user to group dialout if required. Check permissions on /dev/ttyUSB# and see what permissions are required to write into it.

To use the serial port on WSL, look into device manager and make a note of the COM port. The serial port on my setup is noted as Silicon Labs CP210x USB to UART Bridge which is the chipset used on the ESP32 kit I'm using (DevKitC-VE v4). Then within WSL, you can use /dev/ttyS# where # is the COM port number.

It seems WSL has issues with accessing serial ports. I tried many times and was not able to consistently flash the esp32. I encountered odd errors and the device kept resetting in the middle of flashing.

Next steps

Now you can configure Emacs and lsp for ESP32 development. Don't forget to configure esp32 for jtag debugging. I initially opted to use ESP-Prog board to debug the ESP32-DevKitC board I had, but I eventually upgraded to a WROVER-Kit as you can't program the ESP32-DevKitC board with the programming interface available on the esp-prog board. Jtag could be used to program the board through esp-prog (or any other ft2232 kit), but WROVER kit made things simpler to setup.