ULP pulse example does not compile

Have been trying compile the example ULP pulse example without any luck. It seems that the “ulp_main.h” is no where to be found - compiler message:

[1/4] Linking ASM executable ulp_main.elf
FAILED: ulp_main.elf
cmd.exe /C “cd . && esp32ulp-elf-ld -A elf32-esp32ulp -nostdlib -T C:/Users/niels/Documents/PlatformIO/Projects/espidf-ulp-pulse-test/.pio/build/nodemcu-32s/esp-idf/main/ulp_main/ulp_fsm.ld -Map=C:/Users/niels/Documents/PlatformIO/Projects/espidf-ulp-pulse-test/.pio/build/nodemcu-32s/esp-idf/main/ulp_main/ulp_main.map CMakeFiles/ulp_main.dir/pulse_cnt.ulp.S.obj CMakeFiles/ulp_main.dir/wake_up.ulp.S.obj -o ulp_main.elf && cd .”
esp32ulp-elf-ld: cannot open map file C:/Users/niels/Documents/PlatformIO/Projects/espidf-ulp-pulse-test/.pio/build/nodemcu-32s/esp-idf/main/ulp_main/ulp_main.map: No such file or directory
ninja: build stopped: subcommand failed.
Archiving .pio\build\nodemcu-32s\esp-idf\esp-tls\libesp-tls.a
*** [.pio\build\nodemcu-32s\esp-idf\main\ulp_main\ulp_main.h] Error 1

As I understand it ulp_main.h is auto generated but is no where to be found on my system.

Platformio.ini:

[platformio]
src_dir = main

[env:nodemcu-32s]
platform = espressif32
framework = espidf
board = nodemcu-32s
;board_build.partitions = ESP32_OTA_4M.csv
;upload_port = COM[5]
monitor_speed = 115200
;monitor_port = COM[5]
monitor_filters = esp32_exception_decoder

I have seen others havening the same issue but have never seen a solution, has anyone solved this?

Weird, I copied the example from https://github.com/platformio/platform-espressif32/tree/v6.9.0/examples/espidf-ulp-pulse and it compiled just fine.

Generating ULP project files .pio\build\esp32dev\esp-idf\src\ulp_main\ulp_main.h .pio\build\esp32dev\esp-idf\src\ulp_main\ulp_main.ld .pio\build\esp32dev\esp-idf\src\ulp_main\ulp_main.bin
[1/9] Generating ulp_fsm.ld linker script...
[2/9] Generating wake_up.ulp.S
[3/9] Generating pulse_cnt.ulp.S
[4/9] Building ASM object CMakeFiles/ulp_main.dir/pulse_cnt.ulp.S.obj
[5/9] Building ASM object CMakeFiles/ulp_main.dir/wake_up.ulp.S.obj
[6/9] Linking ASM executable ulp_main.elf
[7/9] Generating ulp_main.bin
[8/9] Generating ulp_main.sym
[9/9] Generating ulp_main.ld, ulp_main.h
Generating ULP assembly file .pio\build\esp32dev\ulp_main.bin.S
[..]

Can you make sure to copy https://github.com/platformio/platform-espressif32/tree/develop/examples/espidf-ulp-pulse exactly? Your platformio.ini and folder structure are different. Easiest to just duplicate the C:\Users\<user>\.platformio\platforms\espressif32\examples\espidf-ulp-pulse folder, open that in VSCode, and hit build.

@maxgerhardt thanks for the reply (as usual :wink:) - I cloned the repository from your link compiling and linking works as expected now, thanks!
So the learning for me is that, not to use the examples in:

C:….platformio\packages\framework-espidf\examples ??

I copied the example from there to a new project. But I guess I am missing some files when doing that?

A example made for PlatformIO directly will always be more suitable than the raw ESP-IDF example. I haven’t yet dug into why it was failing in your configuration, but some differences are the naming of the source folder ( src/ vs main/). Also for ULP, files have to be in the ulp folder in the root of the project.

I will definitely use that repository for examples in the future, now that I know it exists. :upside_down_face:
Thanks once again!