← index #8041PR #18457
Likely Duplicate · medium · value 5.540
QUERY · ISSUE

ESP32: "user C modules" should be able to add components to the build

openby aguavivaopened 2021-11-28updated 2023-12-18
port-esp32

Right now the list of components is hard coded in

https://github.com/micropython/micropython/blob/97a7cc243b028833bdcb8ce0bc19b2bce7545851/ports/esp32/main/CMakeLists.txt#L96

USer C modules should be able to add new components without having to modify the above file

My current use case is a user module that adds support for the esp32-camera

Fixing this will help others extend micropython with minimal modifications in the core files

CANDIDATE · PULL REQUEST

esp32: register user C modules with IDF component manager and handle relative usermod paths

openby cnadler86opened 2025-11-21updated 2026-01-28
port-esp32

Summary

This change adds the possibility to define usermod specific IDF manifests and improves how user-provided C modules with relative paths are handled when building the ESP32 port:

  • Register user module directories with the ESP-IDF Component Manager when the user module directory contains both idf_component.yml and CMakeLists.txt and append those directories to EXTRA_COMPONENT_DIRS so the IDF can locate them correctly.
  • Convert configured USER_C_MODULES entries to absolute paths and replace the original variable with those absolute paths for later CMake stages. This makes relative module paths safe and reliable across the build.

Testing

Built MicroPython locally for BOARD=ESP32_GENERIC_S3 and BOARD_VARIANT=SPIRAM_OCT with a user module passed as absolute and relative path. The build contained the needed files.
The build completed successfully.

Trade-offs and Alternatives

The code size of the main CMakeLists.txt is 20 lines longer. On the other hand, you don't need to touch the micropython code to build with custom user modules with ESP components integrated.
Also, providing relative paths to the build changes behavior. This should be documented. On the other hand, this will prevent such issues like https://github.com/micropython/micropython/issues/14352.

(Maintainer edit: Closes #14352 )

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied