Need help with building Arduino as ESP-IDF component in PlatformIO

Hi,

I’m trying to build an ESP32-S3 code. I need to use Arduino as ESP-IDF component in PlatformIO because I need to set some TCP LWIP params. I’m struggling with errors during building the code:

Processing esp32s3 (board: ESP32-S3-DevKitC-1-N16R8; framework: arduino, espidf; platform: https://github.com/pioarduino/platform-espressif32.git#develop)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/ESP32-S3-DevKitC-1-N16R8.html
PLATFORM: Espressif 32 (54.3.20+develop.sha.f17b2d1) > Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.2.0
 - framework-arduinoespressif32-libs @ 5.4.0+sha.f0f2980d05
 - framework-espidf @ 3.50401.0 (5.4.1)
 - tool-cmake @ 3.30.2
 - tool-esp-rom-elfs @ 2024.10.11
 - tool-esptoolpy @ 5.0.0
 - tool-mklittlefs @ 3.2.0
 - tool-ninja @ 1.10.2
 - tool-scons @ 4.40801.0 (4.8.1)
 - toolchain-xtensa-esp-elf @ 14.2.0+20241119
*** "custom_component" is used to (de)select managed idf components ***
Warning! Arduino framework as an ESP-IDF component doesn't handle the `variant` field! The default `esp32` variant will be used.
Reading CMake configuration...
-- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.50.0.windows.1")
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- The C compiler identification is GNU 14.2.0
-- The CXX compiler identification is GNU 14.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/Czarek/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/Czarek/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32s3-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/Czarek/.platformio/packages/toolchain-xtensa-esp-elf/bin/xtensa-esp32s3-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Could not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32s3
Processing 11 dependencies:

[1/11] chmorgan/esp-libhelix-mp3 (1.0.3)

[2/11] espressif/cbor (0.6.0~1)

[3/11] espressif/esp-dsp (1.4.12)

[4/11] espressif/esp-sr (1.9.5)

[5/11] espressif/esp-zboss-lib (1.6.3)

[6/11] espressif/esp-zigbee-lib (1.6.3)

[7/11] espressif/esp_modem (1.4.0)

[8/11] espressif/mdns (1.8.2)

[9/11] espressif/network_provisioning (1.0.2)

[10/11] joltwallet/littlefs (1.20.0)

[11/11] idf (5.4.1)

-- Project sdkconfig file C:/Users/Czarek/Documents/PlatformIO/Projects/RadioTEST/sdkconfig.esp32s3
-- Configuring incomplete, errors occurred!

fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main

  File "<frozen runpy>", line 88, in _run_code

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfgen\__main__.py", line 5, in <module>

    from .core import main

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfgen\core.py", line 29, in <module>

    import esp_idf_kconfig.gen_kconfig_doc as gen_kconfig_doc

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\esp_idf_kconfig\gen_kconfig_doc.py", line 14, in <module>

    import kconfiglib.core as kconfiglib

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfiglib\__init__.py", line 3, in <module>

    from .core import Kconfig  # noqa F401

    ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfiglib\core.py", line 27, in <module>

    from kconfiglib.report import PRAGMA_PREFIX

  File "C:\Users\Czarek\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfiglib\report.py", line 29, in <module>

    from rich import print as rprint

ModuleNotFoundError: No module named 'rich'

CMake Error at C:/Users/Czarek/.platformio/packages/framework-espidf/tools/cmake/kconfig.cmake:209 (message):
  Failed to run kconfgen
  (C:/Users/Czarek/.platformio/penv/.espidf-5.4.1/Scripts/python.exe;-m;kconfgen;--list-separator=semicolon;--kconfig;C:/Users/Czarek/.platformio/packages/framework-espidf/Kconfig;--sdkconfig-rename;C:/Users/Czarek/.platformio/packages/framework-espidf/sdkconfig.rename;--config;C:/Users/Czarek/Documents/PlatformIO/Projects/RadioTEST/sdkconfig.esp32s3;--env-file;C:/Users/Czarek/Documents/PlatformIO/Projects/RadioTEST/.pio/build/esp32s3/config.env).
  Error 1
Call Stack (most recent call first):
  C:/Users/Czarek/.platformio/packages/framework-espidf/tools/cmake/build.cmake:691 (__kconfig_generate_config)
  C:/Users/Czarek/.platformio/packages/framework-espidf/tools/cmake/project.cmake:718 (idf_build_process)
  CMakeLists.txt:3 (project)



======================================================================================= [FAILED] Took 7.13 seconds =======================================================================================

Environment    Status    Duration
-------------  --------  ------------
esp32s3        FAILED    00:00:07.135
================================================================================== 1 failed, 0 succeeded in 00:00:07.135 ==================================================================================

 *  The terminal process "C:\Users\Czarek\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'esp32s3'" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 


My platformio.ini looks like:

[esp32s3]
    board_build.partitions = boards/default_16MB.csv   ; 16MB Flash
    board = ESP32-S3-DevKitC-1-N16R8 ; 16 MB Flash, 8MB octo PSRAM

[env]
    platform = https://github.com/pioarduino/platform-espressif32.git#develop

    build_flags     = ${common.build_flags}
    monitor_speed   = ${common.monitor_speed}
    upload_speed    = 921600

    custom_component_remove = espressif/esp_hosted
                              espressif/esp_wifi_remote
                              espressif/esp-dsp
                              espressif/esp32-camera
                              espressif/libsodium
                              espressif/esp-modbus
                              espressif/qrcode
                              espressif/esp_insights
                              espressif/esp_diag_data_store
                              espressif/esp_diagnostics
                              espressif/esp_rainmaker
                              espressif/rmaker_common

    lib_deps =
        https://github.com/schreibfaul1/ESP32-audioI2S.git
        adafruit/Adafruit GFX Library
        adafruit/Adafruit ILI9341
        https://github.com/tzapu/WiFiManager
        ESP32Async/AsyncTCP
    	ESP32Async/ESpAsyncWebServer

[env:esp32s3]
    board = ${esp32s3.board}
    board_build.partitions = ${esp32s3.board_build.partitions}
    framework = arduino, espidf

I tried almost everything - deleting .platformio folder, reinstaling PlatformIO and VSCode - no success.

Could someone experienced help me to overcome this issue, please?

Sounds like

Especially NameError: name 'config' is not defined when PIO pulled the Expressif files from Git - #18 by maxgerhardt

Use develop branch, it is fixed there already or install rich in the Platformio pyenv

Thanks @maxgerhardt and @jason2866

Blockquote
install rich in the Platformio pyenv

@jason2866 This sadly doesn’t solve the issue for me because rich is already installed. When I try

PS C:\Python313> python.exe -m pip install rich

I got

Requirement already satisfied: rich in c:\users\thomas\appdata\roaming\python\python313\site-packages (14.0.0)
Requirement already satisfied: markdown-it-py>=2.2.0 in c:\users\thomas\appdata\roaming\python\python313\site-packages (from rich) (3.0.0)
Requirement already satisfied: pygments<3.0.0,>=2.13.0 in c:\users\thomas\appdata\roaming\python\python313\site-packages (from rich) (2.19.2)
Requirement already satisfied: mdurl~=0.1 in c:\users\thomas\appdata\roaming\python\python313\site-packages (from markdown-it-py>=2.2.0->rich) (0.1.2)

and in pioarduinio I will still get

  File "C:\Users\Thomas\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfiglib\core.py", line 27, in <module>

    from kconfiglib.report import PRAGMA_PREFIX

  File "C:\Users\Thomas\.platformio\penv\.espidf-5.4.1\Lib\site-packages\kconfiglib\report.py", line 29, in <module>

    from rich import print as rprint

ModuleNotFoundError: No module named 'rich'

Okay, my problem was that in post NameError: name 'config' is not defined when PIO pulled the Expressif files from Git - #18 by maxgerhardt the folder bin is mentioned but in my case I had to run in Scripts folder like this:

~/.platformio/penv/.espidf-5.4.1/Scripts/activate
~/.platformio/penv/.espidf-5.4.1/Scripts/python -m pip install rich