ESP32 — ESP-IDF v6

ESP-IDF v6 — Ubuntu / Linux Setup

Install ESP-IDF v6 on Ubuntu (or any Debian-based Linux) using EIM. This guide covers everything from system dependencies to flashing your first ESP32 project.


Prerequisites

  • Ubuntu 22.04 LTS or 24.04 LTS (64-bit)
  • sudo access
  • At least 4 GB of free disk space
  • Stable internet connection

Step 1 — Install System Dependencies

Open a terminal and run:

shell
sudo apt update
sudo apt install -y \
  git \
  cmake \
  ninja-build \
  python3 \
  python3-pip \
  python3-venv \
  libffi-dev \
  libssl-dev \
  dfu-util \
  libusb-1.0-0

Step 2 — Add User to dialout Group

This allows your user to access serial ports without sudo:

shell
sudo usermod -aG dialout $USER

Log out and log back in

The group change does not take effect until you log out and log back in (or restart your system). If you skip this, you'll see "Permission denied" when trying to flash.

Verify after logging back in:

shell
groups
# Expected: ... dialout ...

Step 3 — Install EIM

shell
# Download the latest EIM release for Linux
curl -LO https://dl.espressif.com/dl/eim/eim-linux-x86_64.tar.gz

# Extract
tar -xzf eim-linux-x86_64.tar.gz

# Move to a directory in your PATH
sudo mv eim /usr/local/bin/

# Verify
eim --version

Option B: Using snap (Ubuntu 22.04+)

shell
sudo snap install eim

Step 4 — Install ESP-IDF v6 via EIM

shell
# Install ESP-IDF v6.0 for ESP32
eim install --version v6.0 --target esp32

# For ESP32-S3
eim install --version v6.0 --target esp32s3

# For ESP32-C6
eim install --version v6.0 --target esp32c6

# Install for multiple targets at once
eim install --version v6.0 --target esp32,esp32s3,esp32c6

EIM will download the framework, toolchain, and all required Python packages into ~/.espressif/.

GUI Installation (optional)

If EIM has a GUI available on your system, launch it with:

shell
eim &

Follow the same wizard steps as the Windows GUI guide.


Step 5 — Activate the ESP-IDF Environment

shell
# Source the environment activation script
. $HOME/.espressif/esp-idf-v6.0/export.sh

Verify:

shell
idf.py --version
# ESP-IDF v6.0.x

Make Activation Automatic

Add the export line to your ~/.bashrc (or ~/.zshrc if using Zsh):

shell
echo '. $HOME/.espressif/esp-idf-v6.0/export.sh' >> ~/.bashrc
source ~/.bashrc

This will activate ESP-IDF in every new terminal

Adding to .bashrc is convenient but will add a few seconds to every new terminal startup. For a cleaner setup, create an alias instead:

shell
echo "alias get_idf='. \$HOME/.espressif/esp-idf-v6.0/export.sh'" >> ~/.bashrc
source ~/.bashrc
# Then run: get_idf

Step 6 — Install USB Drivers (Usually Pre-installed)

Linux generally includes drivers for CP210x and CH340 out of the box. Verify your board is detected:

shell
# Connect your ESP32 board via USB, then:
ls /dev/ttyUSB* /dev/ttyACM*

Expected output: /dev/ttyUSB0 or /dev/ttyACM0

If the device is not listed:

shell
# Check kernel messages for USB device
dmesg | grep -i "tty\|usb\|ch34\|cp21" | tail -20

For CH340-based boards on some systems:

shell
# Check if driver is loaded
lsmod | grep ch341

# Load manually if not loaded
sudo modprobe ch341

Step 7 — Build and Flash the Hello World Project

shell
# Activate ESP-IDF
. $HOME/.espressif/esp-idf-v6.0/export.sh

# Create the hello_world project
idf.py create-project-from-example "esp_system:hello_world"
cd hello_world

# Set your chip target
idf.py set-target esp32

# Build
idf.py build

Flash and monitor (replace /dev/ttyUSB0 with your actual port):

shell
idf.py -p /dev/ttyUSB0 flash monitor

Exit the monitor with Ctrl + ].

Expected output:

text
Hello world!
This is esp32 chip with 2 CPU core(s), WiFi/BT/BLE, silicon revision v3.1, 4MB external flash
Restarting in 10 seconds...

🎉 Your ESP-IDF v6 Ubuntu environment is ready!


Troubleshooting

/dev/ttyUSB0: Permission denied

You haven't logged out and back in after adding yourself to the dialout group. Do that, or temporarily use:

shell
sudo chmod 666 /dev/ttyUSB0

EIM download fails or is slow

Set an alternative mirror in EIM:

shell
eim install --version v6.0 --target esp32 --mirror https://dl.espressif.cn/

Python package installation errors

Make sure you have python3-venv installed, as EIM creates a virtual environment:

shell
sudo apt install python3-venv

Next Steps

Previous
Windows Setup