Skip to main content

Working with ESP-IDF

This chapter covers:

ESP-IDF Getting Started

New to ESP32 ESP-IDF development and looking to get started quickly? We have prepared a general Getting Started Tutorial for you.

Please Note: This tutorial uses the ESP32-S3-Zero as a teaching example, and all hardware code is based on its pinout. Before you start, it is recommended that you check the pinout of your development board to ensure the pin configuration is correct.

Setting Up the ESP-IDF Development Environment

info

The ESP32-P4 Platform examples target ESP-IDF release/v5.4 and later. ESP-IDF v5.5.4 is recommended. For individual advanced UI examples, check the example directory README for specific version requirements.

note

The following guide uses Windows as an example, demonstrating development using VS Code + the ESP-IDF extension. macOS and Linux users should refer to the official documentation.

Version Selection

The screenshots in this section use ESP-IDF V5.5.2 as an example. When installing, please select the ESP-IDF version that matches your board's example.

Install the ESP-IDF Development Environment

  1. Download the installation manager from the ESP-IDF Installation Manager page. This is Espressif's latest cross-platform installer. The following steps demonstrate how to use its offline installation feature.

    Click the Offline Installer tab on the page, then select Windows as the operating system and the ESP-IDF version you need (the version shown in the screenshot is for reference only — choose the version that fits your actual needs).

    Download EIM and offline package

    After confirming your selection, click the download button. The browser will automatically download two files: the ESP-IDF Offline Package (.zst) and the ESP-IDF Installer (.exe).

    Download EIM and offline package 2

    Please wait for both files to finish downloading.

  2. Once the download is complete, double-click to run the ESP-IDF Installer (eim-gui-windows-x64.exe).

    The installer will automatically detect if the offline package exists in the same directory. Click Install from archive.

    Auto-detect offline package

    Next, select the installation path. We recommend using the default path. If you need to customize it, ensure the path does not contain Chinese characters or spaces. Click Start installation to proceed.

    Select installation path
  3. When you see the following screen, the ESP-IDF installation is successful.

    Installation successful
  4. We recommend installing the drivers as well. Click Finish installation, then select Install driver.

    Install drivers via ESP-IDF Installation Manager

Install Visual Studio Code and the ESP-IDF Extension

  1. Download and install Visual Studio Code.

  2. During installation, it is recommended to check Add "Open with Code" action to Windows Explorer file context menu to facilitate opening project folders quickly.

  3. In VS Code, click the Extensions icon Extensions Icon in the Activity Bar on the side (or use the shortcut Ctrl + Shift + X) to open the Extensions view.

  4. Enter ESP-IDF in the search box, locate the ESP-IDF extension, and click Install.

    Search and install ESP-IDF extension in VS Code

  5. For ESP-IDF extension versions ≥ 2.0, the extension will automatically detect and recognize the ESP-IDF environment installed in the previous steps, requiring no manual configuration.

ESP32-P4 Platform Example Repository

The ESP-IDF examples for ESP32-P4 series base boards are maintained in a single repository: ESP32-P4-Platform. The examples/esp-idf/ directory contains standalone ESP-IDF projects, the config/ directory provides ESP32-P4 chip revision configuration override files, and the docs/ directory includes guidance on example selection, chip revision configuration, and troubleshooting.

Examples are numbered from board verification to more integrated applications. When getting started, run 00_board_check first to verify flashing, serial monitor, PSRAM, and runtime logs are functioning correctly, then proceed to peripheral-specific examples based on your setup.

Supported Boards

The following boards use the examples from the ESP32-P4-Platform repository. Images link to the corresponding product pages.

ESP32-P4-NANOESP32-P4-Module-DEV-KITESP32-P4-WIFI6-DEV-KITESP32-P4-WIFI6
ESP32-P4-NANO
ESP32-P4-Module-DEV-KIT
ESP32-P4-WIFI6-DEV-KIT
ESP32-P4-WIFI6
Product PageProduct PageProduct PageProduct Page
ESP32-P4-ETHESP32-P4-PicoESP32-P4-WIFI6-POE-ETHESP32-P4-Core-DEV-KIT
ESP32-P4-ETH
ESP32-P4-Pico
ESP32-P4-WIFI6-POE-ETH
ESP32-P4-Core-DEV-KIT
Product PageProduct PageProduct PageProduct Page

Quick Start

The following commands use 00_board_check as an example. Replace PORT with your actual serial port — for example COM5 on Windows.

git clone https://github.com/waveshareteam/ESP32-P4-Platform.git
cd ESP32-P4-Platform/examples/esp-idf/00_board_check
idf.py set-target esp32p4
idf.py build
idf.py -p PORT flash monitor

You must build before flashing any ESP-IDF example. idf.py build generates the flashable firmware; idf.py -p PORT flash monitor flashes the firmware and opens the serial monitor. If you modify menuconfig or source files, rebuild before flashing.

Some examples require pin configuration, Wi-Fi credentials, Ethernet PHY settings, display parameters, camera setup, or other example-specific options. Before building these examples, review the example README, your board's schematic, and your actual wiring, then run:

idf.py menuconfig

ESP32-P4 Chip Revision Configuration

ESP32-P4 engineering samples from before rev v3.0 and production chips from rev v3.0 onwards use different build configurations in ESP-IDF. If you see an error like requires chip revision in range [v3.1 - v3.99] (this chip is revision v1.3) during flashing or startup, do not use --force to skip the check — rebuild with the correct chip revision configuration instead.

Run one of the following commands in the example directory:

Chip RevisionConfig FileBuild Command
rev v3.1 or later../../../config/esp32p4_rev_v3_1.defaultsidf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;../../../config/esp32p4_rev_v3_1.defaults" set-target esp32p4 build
rev v3.0 or later../../../config/esp32p4_rev_v3_0.defaultsidf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;../../../config/esp32p4_rev_v3_0.defaults" set-target esp32p4 build
rev v0.x / v1.x engineering sample../../../config/esp32p4_rev_pre_v3.defaultsidf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;../../../config/esp32p4_rev_pre_v3.defaults" set-target esp32p4 build

After switching chip revision configurations, it's recommended to delete the sdkconfig file in the example directory, or use a separate SDKCONFIG file for each chip revision. An existing sdkconfig will override the defaults in sdkconfig.defaults.

ESP-IDF Example Index

#Example DirectoryPurposeNotes
0000_board_checkBoard, flash, serial, PSRAM, and heap memory checkNo external hardware required
0101_HowToCreateProjectMinimal ESP-IDF project structureUseful for studying project layout
0202_HelloWorldBasic logging, chip info, and restart countdownBasic environment check
0303_nvs_counterPersist boot count using NVSNo external hardware required
0404_freertos_tasksFreeRTOS tasks and queuesNo external hardware required
0505_gpio_ioGPIO input and outputOptional: jumper wires or LEDs
0606_gpio_interruptGPIO interrupts and debouncingSuggested: push button or jumper wires
0707_uart_loopbackUART transmit and loopback receiveSuggested: TX/RX jumper wire
0808_i2c_toolsI2C scan and command-line debuggingUseful for checking I2C device addresses
0909_sdmmcSD card mount and read/write testRequires SD card and compatible slot/wiring
1010_wifistationWi-Fi STA connectionRequires a board with Wi-Fi support
1111_ethernetbasicEthernet link and DHCP IP acquisitionRequires Ethernet PHY and RJ45 port
1212_I2SCodecI2S Codec audio playback or echo modeRequires audio codec / speaker / microphone support
1313_DisplaycolorbarLCD color bar displayFor verifying display output
1414_lvgl_demo_v9LVGL v9 GUI demoRequires display and PSRAM
1515_eth2apEthernet-to-Wi-Fi AP bridgingRequires both Ethernet and Wi-Fi paths
1616_video_lcd_displayCamera preview on LCDRequires camera, display, and PSRAM
1717_simple_video_serverHTTP camera video streamingRequires camera and network connectivity
1818_esp_brookesia_phoneESP-Brookesia Phone UIRequires matching display, touch, and board-level config
1919_system_monitorSerial diagnostics and runtime status monitorNo external hardware required

Example Code and Configuration Entry Points

Most examples have their application logic in main/, with configurable options in main/Kconfig.projbuild, sdkconfig.defaults, or the component's Kconfig. When adjusting pins, network settings, display parameters, camera, or audio options, use idf.py menuconfig first. To persist changes in the repository, save them to the example's default config files.

ExamplePrimary Code Entry PointConfiguration EntryPre-Run Checks
00_board_checkmain/board_check_main.csdkconfig.defaultsCheck serial log for chip info, PSRAM, heap memory, and periodic alive output.
01_HowToCreateProjectmain/main.cRoot and main/CMakeLists.txtGood template for copying project structure; update CMakeLists.txt when adding components.
02_HelloWorldmain/hello_world_main.csdkconfig.defaultsVerify ESP-IDF environment, serial output, and restart flow.
03_nvs_countermain/nvs_counter_main.csdkconfig.defaultsWrites boot count to NVS; erasing flash resets the counter.
04_freertos_tasksmain/freertos_tasks_main.csdkconfig.defaultsObserve task, queue, and periodic log output; no external hardware needed.
05_gpio_iomain/gpio_io_main.cmain/Kconfig.projbuild: EXAMPLE_GPIO_OUTPUT, EXAMPLE_GPIO_INPUT, EXAMPLE_GPIO_INPUT_PULLUPConfirm GPIO pins are not used by onboard peripherals (check schematic).
06_gpio_interruptmain/gpio_interrupt_main.cmain/Kconfig.projbuild: EXAMPLE_GPIO_INPUT, EXAMPLE_GPIO_INPUT_PULLUP, EXAMPLE_DEBOUNCE_MSInput pin suggested to connect a button or jumper; set pull-up and debounce time based on button circuit.
07_uart_loopbackmain/uart_loopback_main.cmain/Kconfig.projbuild: EXAMPLE_UART_PORT_NUM, EXAMPLE_UART_TX_GPIO, EXAMPLE_UART_RX_GPIO, EXAMPLE_UART_BAUD_RATEConnect TX to RX before running; avoid occupying the download serial port.
08_i2c_toolsmain/i2ctools_example_main.c, main/cmd_i2ctools.cmain/Kconfig.projbuild: EXAMPLE_I2C_MASTER_SCL, EXAMPLE_I2C_MASTER_SDA, EXAMPLE_STORE_HISTORYESP32-P4 default SCL = GPIO8, SDA = GPIO7; verify voltage levels and pull-ups before connecting peripherals.
09_sdmmcmain/sd_card_example_main.c, components/sd_card/sd_test_io.cmain/Kconfig.projbuild: bus width, EXAMPLE_PIN_CMD, EXAMPLE_PIN_CLK, EXAMPLE_PIN_D0 through EXAMPLE_PIN_D3, format options, LDO IOESP32-P4 default CMD/CLK/D0/D1/D2/D3 = GPIO44/43/39/40/41/42; enabling format option will erase SD card data.
10_wifistationmain/station_example_main.cmain/Kconfig.projbuild: ESP_WIFI_SSID, ESP_WIFI_PASSWORD, auth threshold, retry countESP32-P4 has no integrated Wi-Fi; requires a board with ESP32-C6 or equivalent Wi-Fi companion.
11_ethernetbasicmain/ethernet_example_main.c, components/ethernet_init/ethernet_init.cmain/Kconfig.projbuild, components/ethernet_init/Kconfig.projbuild: PHY model, PHY address, MDC, MDIO, reset pin, internal EMAC or SPI EthernetESP32-P4 internal EMAC default MDC = GPIO31, MDIO = GPIO52, PHY Reset = GPIO51; adjust per board schematic.
12_I2SCodecmain/i2s_es8311_example.c, main/example_config.h, main/canon.pcmmain/Kconfig.projbuild: playback / echo mode, MIC gain, volume, EXAMPLE_BSP; BSP dependencies in main/idf_component.ymlEcho mode requires microphone input; confirm selected BSP component matches hardware before enabling.
13_Displaycolorbarmain/test_esp_lcd_jd9365.cmain/idf_component.yml, sdkconfig.defaults, sdkconfig.defaults.esp32p4First step for display bring-up; if log is normal but screen stays blank, check backlight, reset, power, and panel model.
14_lvgl_demo_v9main/main.c, components/bsp_extra/src/bsp_board_extra.cmain/idf_component.yml, components/bsp_extra/idf_component.yml, components/bsp_extra/Kconfig, sdkconfig.defaultsRun 13_Displaycolorbar first; then check LVGL buffer, resolution, touch controller, and PSRAM.
15_eth2apmain/ethernet_example_main.cmain/Kconfig.projbuild: EXAMPLE_WIFI_SSID, EXAMPLE_WIFI_PASSWORD, EXAMPLE_WIFI_CHANNEL, EXAMPLE_MAX_STA_CONNRequires both Ethernet and Wi-Fi paths; verify Ethernet link and AP parameters before running.
16_video_lcd_displaymain/main.c, main/app_video.csdkconfig.defaults: MIPI-CSI SCCB SCL/SDA, OV5647, LVGL, PSRAM, CONFIG_BSP_LCD_DPI_BUFFER_NUMS; camera sensor selected under Component configDefault SCCB SCL = GPIO8, SDA = GPIO7; requires MIPI-CSI camera and LCD connected.
17_simple_video_servermain/simple_video_server_example.c, components/example_video_common/, frontend/main/Kconfig.projbuild: video buffer, JPEG quality, mDNS; components/example_video_common/Kconfig.projbuild: network, board, camera interface, SCCB I2C, JPEG encoderRequires camera and network; after flashing, access the web interface at the IP shown in the serial log, or use http://esp-web.local on mDNS-enabled networks. Frontend source requires Node.js 20+; pre-built web assets are included, so standard firmware builds do not require building the frontend first.
18_esp_brookesia_phonemain/main.cpp, components/esp32_p4_platform/, components/brookesia_*components/esp32_p4_platform/Kconfig: Board Support Package(ESP32-P4) > Display > Select LCD type, color format, I2C, I2S, SD, SPIFFSExample README uses 1024 x 600 UI style as prototype; when porting to other Waveshare DSI displays, select the correct LCD type and color format first.
19_system_monitormain/system_monitor_main.csdkconfig.defaultsSerial console provides help, info, heap, period <ms> commands; period writes to NVS.

Compatibility Reference

indicates the example is expected to run on the corresponding board. means the board either lacks the required peripheral or the example has not yet been verified on that board path. Always adjust menuconfig based on your actual hardware before running.

#ExampleESP32-P4-NANOESP32-P4-Module-DEV-KITESP32-P4-WIFI6-DEV-KITESP32-P4-WIFI6ESP32-P4-ETHESP32-P4-PicoESP32-P4-WIFI6-POE-ETHESP32-P4-Core-DEV-KIT
00board_check
01HowToCreateProject
02HelloWorld
03nvs_counter
04freertos_tasks
05gpio_io
06gpio_interrupt
07uart_loopback
08i2c_tools
09sdmmc
10wifistation
11ethernetbasic
12I2SCodec
13Displaycolorbar
14lvgl_demo_v9
15eth2ap
16video_lcd_display
17simple_video_server✅(Ethernet)
18esp_brookesia_phone
19system_monitor

Build and Run Notes

  • The ESP32-P4 chip itself does not have integrated Wi-Fi or Bluetooth. Wi-Fi examples require an onboard ESP32-C6 or another configured Wi-Fi companion solution.
  • Ethernet examples require an onboard or external Ethernet PHY. If the RJ45 port, PHY model, PHY address, MDC/MDIO GPIO pins, or reset GPIO differ from the example defaults, adjust them in menuconfig.
  • The ESP32-P4-Core-DEV-KIT does not cover SDMMC, Wi-Fi, Ethernet, I2S Codec, eth2ap, or simple_video_server in the Platform compatibility matrix. To verify these peripherals, you'll need external hardware and must adjust the example configuration to match the board schematic.
  • Display, LVGL, camera, and ESP-Brookesia examples typically require PSRAM. Run 00_board_check first to confirm PSRAM initializes correctly.
  • Some examples download ESP-IDF managed components via idf_component.yml. If the build stalls at the component download stage, check your network, Git proxy settings, and ESP-IDF component manager configuration.
  • Basic interface examples like 05_gpio_io, 06_gpio_interrupt, and 07_uart_loopback may conflict with GPIO pins occupied by onboard peripherals. Always verify pin assignments against the schematic before running.