Cheat sheet

ESP-IDF cheat sheet

idf.py commands, IDF Monitor keys and the menuconfig options you change most, checked against ESP-IDF v6.1.1 and its Docker image, with ESP32-C5 defaults.

EspressifLast verified 28 November 2026· ESP-IDF v6.1.1

This page is a one-screen reference for building ESP-IDF (the Espressif IoT Development Framework) projects from the command line. It is for anyone who already has a project and wants the exact command or Kconfig symbol without searching the full programming guide. Everything here was checked against the ESP-IDF v6.1.1 documentation and by running the commands in the espressif/idf:v6.1.1 Docker image on 28 November 2026. Defaults are the ones a fresh project gets after idf.py set-target esp32c5. Other chips differ, so check your own sdkconfig.

Set up a terminal

The v6.1.1 Get Started guide installs ESP-IDF with the ESP-IDF Installation Manager (EIM), which has a graphical and a command-line version. EIM prints an activation command after installing. Run it in every new terminal.

If you work from a Git checkout instead, source export.sh from the ESP-IDF directory. The tools guide says the variables it sets do not survive into a new terminal, and that the default tools directory is $HOME/.espressif on Linux and macOS.

. ./export.sh          # from the ESP-IDF directory, in every new terminal
idf.py --version       # prints "ESP-IDF v6.1.1" in the pinned image
idf.py --list-targets  # add --preview to include preview targets

idf.py --list-targets in v6.1.1 lists esp32, esp32s2, esp32c3, esp32s3, esp32c2, esp32c6, esp32h2, esp32p4, esp32c5, esp32c61 and esp32s31. With --preview it adds linux, esp32h21 and esp32h4.

Build in Docker

The Docker image guide gives this pattern for a build from the project directory. We pin the tag rather than relying on latest, which the guide says tracks the master branch.

docker run --rm -v $PWD:/project -w /project -u $UID -e HOME=/tmp espressif/idf:v6.1.1 idf.py build

Inside the image, IDF_PATH is /opt/esp/idf. The guide states that serial access from the container is not possible with Docker for Mac or Docker for Windows. It works on Linux with Docker’s device option. On a Mac, build in the container and flash from the host, or use the RFC2217 remote serial port route the guide describes.

Everyday commands

Command What it does
idf.py create-project NAME New project in ./NAME with CMakeLists.txt and main/NAME.c. --cpp makes NAME.cpp instead. Fails if the folder is not empty.
idf.py create-component NAME New component with the minimum files needed to build.
idf.py set-target esp32c5 Selects the chip. It deletes the build directory and regenerates sdkconfig, keeping the old one as sdkconfig.old.
idf.py menuconfig Opens the configuration menu. --style light switches the colour scheme.
idf.py build Incremental build of bootloader, partition table and app. app, bootloader and partition-table build one part.
idf.py -p PORT flash Builds if needed, then flashes. Only changed sectors are rewritten unless you add -a (--all).
idf.py -p PORT monitor Opens IDF Monitor on the port. Exit with Ctrl+].
idf.py -p PORT flash monitor Flash, then monitor. Commands can be chained and run in the right order whatever order you type them.
idf.py app-flash Flashes the app only.
idf.py -p PORT erase-flash Erases the entire flash chip, including NVS (non-volatile storage) data.
idf.py size App size summary. --format takes text, csv, json2, tree or raw.
idf.py size-components, idf.py size-files Size per component, or per source file.
idf.py partition-table Builds and prints the partition table. partition-table-flash flashes only that.
idf.py clean Deletes build output but keeps the CMake configuration.
idf.py fullclean Deletes everything in the build directory. Your sdkconfig is kept.
idf.py reconfigure Re-runs CMake. Combine with -D NAME=VALUE to set a CMake cache entry.
idf.py save-defconfig Writes sdkconfig.defaults with only the options that differ from the defaults.
idf.py add-dependency "namespace/component" Adds a component from the ESP Component Registry to the manifest.
idf.py merge-bin Merges bootloader, partition table and app into one file (raw binary, Intel HEX or UF2).
idf.py docs Opens the documentation for your target and ESP-IDF version.

Linux serial ports start with /dev/tty (for example /dev/ttyUSB0). macOS ports start with /dev/cu.. If you leave out -p, idf.py tries to find the port itself. ESPPORT and ESPBAUD set default port and baud rate, and command-line options override them.

IDF Monitor keys

Ctrl+T is the menu key. Press it, release, then press the second key.

Keys Action
Ctrl+] Exit
Ctrl+T, Ctrl+X Exit
Ctrl+T, Ctrl+R Reset the target through RTS
Ctrl+T, Ctrl+P Reset into the bootloader, pausing the app
Ctrl+T, Ctrl+F Build and flash the project, then resume monitoring
Ctrl+T, Ctrl+A Build and flash the app only
Ctrl+T, Ctrl+Y Stop or resume printing to the screen
Ctrl+T, Ctrl+L Stop or resume logging to a file in the project directory
Ctrl+T, Ctrl+I Toggle timestamps
Ctrl+T, Ctrl+H List all shortcuts

Filter output with idf.py monitor --print-filter "wifi:W *:I": each rule is tag:level with a level from N, E, W, I, D, V or *. A rule for a named tag wins over the * rule. The guide warns that *:N also hides printf output. When the chip prints a code address, the monitor looks it up in your ELF file and prints the source file and line underneath.

Menu paths are from the v6.1.1 configuration reference. The default column is what a fresh ESP32-C5 project gets in v6.1.1.

Menu path Symbol What it controls ESP32-C5 default
Serial flasher config CONFIG_ESPTOOLPY_FLASHSIZE Flash size 2 MB
Serial flasher config CONFIG_ESPTOOLPY_FLASHMODE SPI flash mode DIO
Partition Table CONFIG_PARTITION_TABLE_TYPE Built-in table (single app, two OTA) or a custom CSV Single factory app, no OTA
Partition Table CONFIG_PARTITION_TABLE_CUSTOM_FILENAME Name of your custom CSV partitions.csv
Bootloader config > Log CONFIG_BOOTLOADER_LOG_LEVEL Bootloader log verbosity Info
Bootloader config > Application Rollback CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE Roll back to the previous app if a new one is not marked valid Disabled
Compiler options CONFIG_COMPILER_OPTIMIZATION -Og (Debug), -Os (Size), -O2 (Performance) or -O0 (None) Debug (-Og)
Component config > Log > Log Level CONFIG_LOG_DEFAULT_LEVEL Default log level, and which log calls are compiled in Info
Component config > ESP-STDIO CONFIG_ESP_CONSOLE_UART Where console output goes Default UART0, with USB Serial/JTAG as secondary output
Component config > ESP System Settings CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ CPU clock at start-up 240 MHz
Component config > ESP System Settings CONFIG_ESP_MAIN_TASK_STACK_SIZE Stack for app_main 3584 bytes
Component config > ESP System Settings CONFIG_ESP_SYSTEM_PANIC What happens on a crash Print registers and reboot
Component config > ESP System Settings CONFIG_ESP_TASK_WDT_TIMEOUT_S Task watchdog timeout 5 s
Component config > ESP System Settings CONFIG_ESP_TASK_WDT_PANIC Panic instead of only printing on watchdog timeout Disabled
Component config > FreeRTOS > Kernel CONFIG_FREERTOS_HZ Tick rate, so the resolution of vTaskDelay 100 Hz (10 ms ticks)
Component config > Power Management CONFIG_PM_ENABLE Power management support (dynamic frequency scaling) Disabled

The serial monitor baud rate (CONFIG_ESPTOOLPY_MONITOR_BAUD) and the console UART baud rate both default to 115200 for this target.

Partition tables

The built-in single-app and two-OTA tables both place the factory app at 0x10000 with 1 MB. The OTA table adds ota_0 and ota_1, also 1 MB each. The table itself sits at 0x8000 by default. A custom CSV has the columns Name, Type, SubType, Offset, Size and Flags. App partitions must start on a 64 KB (0x10000) boundary. Leave the offset blank and the generator aligns it for you.

sdkconfig.defaults

sdkconfig is generated and changes every time you open menuconfig. The build system guide says it “may or may not” go into version control. A short sdkconfig.defaults that you write and commit is easier to review.

  • sdkconfig.defaults in the project root is applied when a new sdkconfig is generated, and to any option not yet set.
  • If sdkconfig.defaults exists, sdkconfig.defaults.esp32c5 is also loaded for that target. Keep an empty sdkconfig.defaults if you only need the target file.
  • SDKCONFIG_DEFAULTS="a;b" (environment or top-level CMakeLists.txt) lists several files. Later files win. Naming your own list stops the plain sdkconfig.defaults from loading.
  • idf.py save-defconfig writes the minimal file from your current configuration. To apply edited defaults to an existing project, delete sdkconfig and rebuild, or run idf.py set-target again.

An example file (the values are illustrations, not recommendations):

CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_PARTITION_TABLE_TWO_OTA=y
CONFIG_COMPILER_OPTIMIZATION_SIZE=y
CONFIG_ESP_TASK_WDT_PANIC=y

Project skeleton

The top-level CMakeLists.txt needs three lines in this order. ESP-IDF needs CMake 3.22 or newer.

cmake_minimum_required(VERSION 3.22)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(my_sensor)

Each component registers itself with idf_component_register(SRCS ... INCLUDE_DIRS ... REQUIRES ... PRIV_REQUIRES ...). Use REQUIRES for components your public headers include, and PRIV_REQUIRES for components only your source files use. The main component already depends on every other component in the build.

Moving from v5.5 or v6.0

The v6.0 migration guide moved the compiler from GCC 14.2.0 to GCC 15.1.0, and the v6.1.1 image ships GCC 15.2.0 (riscv32-esp-elf-gcc --version). Expect new warnings. CONFIG_COMPILER_DISABLE_GCC15_WARNINGS silences them, but fixing them is better. A fresh v6.1.1 ESP32-C5 configuration has CONFIG_LIBC_PICOLIBC enabled, and the guide says <sys/signal.h> is not available with picolibc: include <signal.h>. Code that includes <sys/dirent.h> for opendir now needs <dirent.h>.

The v6.1 release notes list a breaking change for MQTT: the esp-mqtt client left the ESP-IDF core for the component manager. A project that uses it needs idf.py add-dependency "espressif/mqtt".