ulp code as an esp-idf project component not compiling

akotowski
Posts: 16
Joined: Sat Sep 01, 2018 2:54 pm

ulp code as an esp-idf project component not compiling

Postby akotowski » Fri Jan 17, 2020 1:25 am

I have adapted the ulp_i2c_bitbang code from the "esp-iot-solution" github directory. It compiles and runs when all the files are in the "main" directory of the project. When I create a separate component directory for the ulp associated files the project does not compile. The assembly (*.S) files are compiled and *.lst files are generated, the ulp_mag.h file is not generated. I get the following errors:
  1. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:45: warning: overriding recipe for target 'ulp_mag'
  2. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:29: warning: ignoring old recipe for target 'ulp_mag'
  3. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:50: warning: overriding recipe for target 'ulp_mag'
  4. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:45: warning: ignoring old recipe for target 'ulp_mag'
  5. /home/Andreas/esp/WM/ulp2/components/mag/component.mk:30: warning: overriding recipe for target 'ulp_mag'
  6. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:50: warning: ignoring old recipe for target 'ulp_mag'
  7. /home/Andreas/esp/WM/ulp2/components/mag/component.mk:30: warning: overriding recipe for target '.elf'
  8. /home/Andreas/esp/esp-idf/components/ulp/component_ulp_common.mk:45: warning: ignoring old recipe for target '.elf'
  9. make[1]: Circular ulp_mag <- ulp_mag dependency dropped.
  10. make[1]: Circular ulp_mag <- ulp_mag dependency dropped.
  11. make[1]: Circular .elf <- ulp_mag dependency dropped.
  12. make[1]: Circular .elf <- ulp_mag dependency dropped.
  13. make[1]: Circular ulp_mag <- ulp_mag dependency dropped.
  14. make[1]: Circular /home/Andreas/esp/WM/ulp2/build/mag/ulp_mag <- ulp_mag dependency dropped.
  15. make[1]: Circular mag_ulp_mapgen_intermediate <- ulp_mag dependency dropped.
  16. make[1]: Circular .sym <- ulp_mag dependency dropped.
  17. make[1]: Circular .h <- .h dependency dropped.
  18. xtensa-esp32-elf-gcc -DESP_PLATFORM -D IDF_VER=\"v3.2-dirty\" -MMD -MP   -DGCC_NOT_5_2_0=0 -DWITH_POSIX -DMBEDTLS_CONFIG_FILE='"mbedtls/esp_config.h"' -DHAVE_CONFIG_H -MT ulp_mag .common.ld -E -P -xc -o .common.ld -I /home/Andreas/esp/esp-idf/components/app_trace/include -I /home/Andreas/esp/esp-idf/components/app_update/include -I /home/Andreas/esp/esp-idf/components/asio/asio/asio/include -I /home/Andreas/esp/esp-idf/components/asio/port/include -I /home/Andreas/esp/esp-idf/components/bootloader_support/include -I /home/Andreas/esp/esp-idf/components/bt/include -I /home/Andreas/esp/esp-idf/components/coap/port/include -I /home/Andreas/esp/esp-idf/components/coap/port/include/coap -I /home/Andreas/esp/esp-idf/components/coap/libcoap/include -I /home/Andreas/esp/esp-idf/components/coap/libcoap/include/coap -I /home/Andreas/esp/esp-idf/components/console -I /home/Andreas/esp/esp-idf/components/driver/include -I /home/Andreas/esp/esp-idf/components/esp-tls -I /home/Andreas/esp/esp-idf/components/esp32/include -I /home/Andreas/esp/esp-idf/components/esp_adc_cal/include -I /home/Andreas/esp/esp-idf/components/esp_event/include -I /home/Andreas/esp/esp-idf/components/esp_http_client/include -I /home/Andreas/esp/esp-idf/components/esp_http_server/include -I /home/Andreas/esp/esp-idf/components/esp_https_ota/include -I /home/Andreas/esp/esp-idf/components/esp_ringbuf/include -I /home/Andreas/esp/esp-idf/components/ethernet/include -I /home/Andreas/esp/esp-idf/components/expat/expat/expat/lib -I /home/Andreas/esp/esp-idf/components/expat/port/include -I /home/Andreas/esp/esp-idf/components/fatfs/src -I /home/Andreas/esp/esp-idf/components/freemodbus/modbus/include -I /home/Andreas/esp/esp-idf/components/freemodbus/modbus_controller -I /home/Andreas/esp/esp-idf/components/freertos/include -I /home/Andreas/esp/esp-idf/components/heap/include -I /home/Andreas/esp/esp-idf/components/idf_test/include -I /home/Andreas/esp/esp-idf/components/jsmn/include -I /home/Andreas/esp/esp-idf/components/json/cJSON -I /home/Andreas/esp/esp-idf/components/libsodium/libsodium/src/libsodium/include -I /home/Andreas/esp/esp-idf/components/libsodium/port_include -I /home/Andreas/esp/esp-idf/components/log/include -I /home/Andreas/esp/esp-idf/components/lwip/include/apps -I /home/Andreas/esp/esp-idf/components/lwip/lwip/src/include -I /home/Andreas/esp/esp-idf/components/lwip/port/esp32/include -I /home/Andreas/esp/esp-idf/components/lwip/port/esp32/include/arch -I /home/Andreas/esp/esp-idf/components/lwip/include_compat -I /home/Andreas/esp/WM/ulp2/components/mag -I /home/Andreas/esp/WM/ulp2/main/include -I /home/Andreas/esp/esp-idf/components/mbedtls/port/include -I /home/Andreas/esp/esp-idf/components/mbedtls/mbedtls/include -I /home/Andreas/esp/esp-idf/components/mdns/include -I /home/Andreas/esp/esp-idf/components/micro-ecc/micro-ecc -I /home/Andreas/esp/esp-idf/components/mqtt/esp-mqtt/include -I /home/Andreas/esp/esp-idf/components/newlib/platform_include -I /home/Andreas/esp/esp-idf/components/newlib/include -I /home/Andreas/esp/esp-idf/components/nghttp/port/include -I /home/Andreas/esp/esp-idf/components/nghttp/nghttp2/lib/includes -I /home/Andreas/esp/esp-idf/components/nvs_flash/include -I /home/Andreas/esp/esp-idf/components/openssl/include -I /home/Andreas/esp/esp-idf/components/protobuf-c/protobuf-c -I /home/Andreas/esp/esp-idf/components/protocomm/include/common -I /home/Andreas/esp/esp-idf/components/protocomm/include/security -I /home/Andreas/esp/esp-idf/components/protocomm/include/transports -I /home/Andreas/esp/esp-idf/components/pthread/include -I /home/Andreas/esp/esp-idf/components/sdmmc/include -I /home/Andreas/esp/esp-idf/components/smartconfig_ack/include -I /home/Andreas/esp/esp-idf/components/soc/esp32/include -I /home/Andreas/esp/esp-idf/components/soc/include -I /home/Andreas/esp/esp-idf/components/spi_flash/include -I /home/Andreas/esp/esp-idf/components/spiffs/include -I /home/Andreas/esp/esp-idf/components/tcp_transport/include -I /home/Andreas/esp/esp-idf/components/tcpip_adapter/include -I /home/Andreas/esp/esp-idf/components/ulp/include -I /home/Andreas/esp/esp-idf/components/vfs/include -I /home/Andreas/esp/esp-idf/components/wear_levelling/include -I /home/Andreas/esp/esp-idf/components/wifi_provisioning/include -I /home/Andreas/esp/esp-idf/components/wpa_supplicant/include -I /home/Andreas/esp/esp-idf/components/wpa_supplicant/port/include -I /home/Andreas/esp/esp-idf/components/xtensa-debug-module/include -I /home/Andreas/esp/WM/ulp2/build/include  -I/home/Andreas/esp/WM/ulp2/components/mag -D__ASSEMBLER__ /home/Andreas/esp/esp-idf/components/ulp/ld/esp32.ulp.ld
  19. make[1]: Entering directory '/home/Andreas/esp/WM/ulp2/build/libsodium'
  20. make[1]: Nothing to be done for 'build'.
  21. make[1]: Leaving directory '/home/Andreas/esp/WM/ulp2/build/libsodium'
  22. /usr/bin/make -C /home/Andreas/esp/WM/ulp2/build/main -f /home/Andreas/esp/esp-idf/make/component_wrapper.mk COMPONENT_MAKEFILE=/home/Andreas/esp/WM/ulp2/main/component.mk COMPONENT_NAME=main build
  23. xtensa-esp32-elf-gcc.exe: error: .common.ld: No such file or directory
  24. make[1]: Entering directory '/home/Andreas/esp/WM/ulp2/build/lwip'
  25. make[1]: Nothing to be done for 'build'.
  26. make[1]: Leaving directory '/home/Andreas/esp/WM/ulp2/build/lwip'
  27. make[1]: *** No rule to make target '.common.ld', needed by '.elf'.  Stop.
  28. make[1]: Leaving directory '/home/Andreas/esp/WM/ulp2/build/mag'
  29. /usr/bin/make -C /home/Andreas/esp/WM/ulp2/build/mbedtls -f /home/Andreas/esp/esp-idf/make/component_wrapper.mk COMPONENT_MAKEFILE=/home/Andreas/esp/esp-idf/components/mbedtls/component.mk COMPONENT_NAME=mbedtls build
  30. make: *** [C:\msys32\home\Andreas\esp\esp-idf/make/project.mk:535: component-mag-build] Error 2
  31. make: *** Waiting for unfinished jobs....
I can not find any circular dependency in my *.cpp or *.h files.
I suspect that I have a problem with the makefiles. I moved the "ulp makefile" into the component directory. Here is the makefile:
  1. #
  2. # ULP support additions to component makefile.
  3. #
  4. # 1. ULP_APP_NAME must be unique (if multiple components use ULP)
  5. #    Default value, override if necessary:
  6. ULP_APP_NAME ?= ulp_$(COMPONENT_NAME)
  7. #
  8. # 2. Specify all assembly source files here.
  9. #    Files should be placed into a separate directory (in this case, ulp/),
  10. #    which should not be added to COMPONENT_SRCDIRS.
  11. ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \
  12.     i2c_dev.S \
  13.     i2c.S \
  14.     stack.S \
  15.     )
  16. #
  17. # 3. List all the component object files which include automatically
  18. #    generated ULP export file, $(ULP_APP_NAME).h:
  19. #ULP_EXP_DEP_OBJECTS := main.o
  20. #ULP_EXP_DEP_OBJECTS := mag.o main.o
  21. ULP_EXP_DEP_OBJECTS := mag.o
  22. #ULP_EXP_DEP_OBJECTS := mag.o main.o ulp3.o  
  23. #
  24. # 4. Include build rules for ULP program
  25. include $(IDF_PATH)/components/ulp/component_ulp_common.mk
  26. #
  27. # Link object files and generate map file
  28. $(ULP_ELF): $(ULP_OBJECTS) $(ULP_LD_SCRIPT)
  29.     $(summary) ULP_LD $(patsubst $(PWD)/%,%,$(CURDIR))/$@
  30.     $(ULP_LD) -o $@ -A elf32-esp32ulp -Map=$(ULP_MAP) -T $(ULP_LD_SCRIPT) $(ULP_OBJECTS)
  31. #
  32. # End of ULP support additions to component makefile.
  33. #
  34. #COMPONENT_ADD_INCLUDEDIRS := .
  35. #COMPONENT_SRCDIRS := .
The directory structure is:
ulp3
.....main: main.cpp, component.mk
.....components
..........mag: component.mk, mag.cpp, mag.h
...............ulp: i2c.S, i2c_dev.S, stack.S

This is on a Windows 10 system with esp-idf 3.2

Any help appreciated

wevets
Posts: 112
Joined: Sat Mar 09, 2019 2:56 am

Re: ulp code as an esp-idf project component not compiling

Postby wevets » Mon Jan 20, 2020 3:20 am

I have not experimented with any directory structure other than that explicitly supported by the esp idf, but I have a project using ULP code in which a directory appears in main called ULP. The .S files in that directory both assemble and are linked into the program of which the .cpp file is in main.

Code: Select all

build
main
\ something.cpp
     CMakeLists.txt
     component.mk
     etc.
     ULP
       \ something.S
sdkconfig
etc.
This works. Good luck.

akotowski
Posts: 16
Joined: Sat Sep 01, 2018 2:54 pm

Re: ulp code as an esp-idf project component not compiling

Postby akotowski » Mon Jan 20, 2020 7:13 pm

This works for me as well, but not when I move the ulp files to a component subdirectory. I'm trying to create a component so that the user is insulated from the ulp code.
Thanks

ESP_igrr
Posts: 2071
Joined: Tue Dec 01, 2015 8:37 am

Re: ulp code as an esp-idf project component not compiling

Postby ESP_igrr » Mon Jan 20, 2020 8:12 pm

Comparing your file to https://github.com/espressif/esp-idf/bl ... mponent.mk, it seems that lines 28-30 are not present in the template. Can you please try removing these?

akotowski
Posts: 16
Joined: Sat Sep 01, 2018 2:54 pm

Re: ulp code as an esp-idf project component not compiling

Postby akotowski » Sat Jan 25, 2020 3:42 pm

Thanks for the suggestion, but the results are still the same.

Who is online

Users browsing this forum: Google [Bot] and 255 guests