Undefined reference to 'xxxxx' {ULP problem}

Hi everyone,

I’ve been working with my ESP32 on a project that involves measuring ADC values from a sensor while in sleep mode. When the value exceeds a certain threshold, the ULP wakes up from the light sleep mode. I’m using PlatformIO with the Arduino framework.
Here is my platformio.ini file :

[env:esp32dev]
platform = espressif32@3.5.0
board = esp32dev
framework = arduino
lib_deps = 
    https://github.com/maxgerhardt/ulptool-pio.git
	wnatth3/WiFiManager@^2.0.16-rc.2
	ayushsharma82/ElegantOTA@^3.1.1
	me-no-dev/AsyncTCP@^1.1.1
	me-no-dev/ESP Async WebServer@^1.2.3

Since the ULP is not compatible with PlatformIO, I installed the ulptool library from GitHub - maxgerhardt/ulptool-pio: A thin wrapper of ulptool for PlatformIO. I referenced the ulpcc_adc.cpp code, but I encountered a problem where some functions were not defined.

.pio\build\esp32dev\src\main.cpp.o:(.literal._Z5setupv+0x34): undefined reference to `_binary_ulp_main_bin_end'
.pio\build\esp32dev\src\main.cpp.o:(.literal._Z5setupv+0x38): undefined reference to `_binary_ulp_main_bin_start'
.pio\build\esp32dev\src\adc.c.o:(.literal.entry+0x1c): undefined reference to `adc'
.pio\build\esp32dev\src\adc.c.o:(.literal.entry+0x20): undefined reference to `wake'
.pio\build\esp32dev\src\adc.c.o: In function `entry':
C:\Users\HP\Documents\PlatformIO\Projects\Gas detector/src/adc.c:39: undefined reference to `adc'
C:\Users\HP\Documents\PlatformIO\Projects\Gas detector/src/adc.c:55: undefined reference to `wake'

Both ‘adc’ and ‘wake’ functions are being called in adc.c, but they are not declared in any file. The same issue applies to other functions. Could this be a result of a mistake in the installation or folder placement of the esp32ulp-elf-binutils folder? I’m unsure about the correct placement; currently, it’s located in .pio\libdeps\esp32dev\ulptool-pio\src\esp32ulp-elf-binutils :smiling_face_with_tear:.
Those functions are not declared :

Any assistance in resolving this issue and locating the missing function declarations would be greatly appreciated. :blush:

Referring to the examples, the code for the ULP must not be in the src folder but in the ulp folder.

However, I have never written code for the ULP - maybe this topic will inspire me to do so in the future :slight_smile:

1 Like

Yes , it’s located in the example folder ,i’ve just copied the header file and structure of the code to the src folder . But the problem is that ulp_set_wakeup_period() is not defined even that the “ulp.h” is declared.
This is ulp_counter.cpp on the example folder :