← index #14352PR #18457
Duplicate · high · value 5.323
QUERY · ISSUE

ESP32 micropython port build with relative path to external user C-modules was failed

openby aso-copened 2024-04-22updated 2025-03-03
bugport-esp32

Checks

  • I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.

  • I've searched for existing issues matching this bug, and didn't find any.

Port, board and/or hardware

esp32 port, ESP32-boards of any kind, I guess

MicroPython version

MicroPython v1.22.2-dirty on 2024-04-18; Generic ESP32 module with ESP32

Reproduction

make USER_C_MODULES=../../examples/usercmodule/micropython.cmake

Expected behaviour

Make process failed with error message like a:
modules not found in the path <specified_path>

Observed behaviour

During the build, make changed current directory and relative path to micropython.cmake file turns out to be incorrect

Additional Information

Need expand relative path of USER_C_MODULES variable, to absolute path before passed it to the ./py/usermod.cmake as described below:
In the file ./ports/esp32/Makefile , line 41:

ifdef USER_C_MODULES
       CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
endif

change it to a:

ifdef USER_C_MODULES
        CMAKE_ARGS += -DUSER_C_MODULES=$(abspath ${USER_C_MODULES})
endif

Thnx!

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