From 07a71529decef2230543831a4081cded688932eb Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Tue, 3 Mar 2020 16:03:59 +0800 Subject: [PATCH 1/2] ulp: fix ulp external project args Closes https://github.com/espressif/esp-idf/issues/4713 --- components/ulp/project_include.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/ulp/project_include.cmake b/components/ulp/project_include.cmake index aae8218971..a4bfd4c37a 100644 --- a/components/ulp/project_include.cmake +++ b/components/ulp/project_include.cmake @@ -47,10 +47,9 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) INSTALL_COMMAND "" CMAKE_ARGS -DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_TOOLCHAIN_FILE=${TOOLCHAIN_FLAG} - -DULP_S_SOURCES=${sources} -DULP_APP_NAME=${app_name} + -DULP_S_SOURCES=$ + -DULP_APP_NAME=${app_name} -DCOMPONENT_DIR=${COMPONENT_DIR} - # Even though this resolves to a ';' separated list, this is fine. This must be special behavior - # for generator expressions. -DCOMPONENT_INCLUDES=$ -DIDF_PATH=${idf_path} -DSDKCONFIG=${SDKCONFIG_HEADER} @@ -60,9 +59,10 @@ function(ulp_embed_binary app_name s_sources exp_dep_srcs) BUILD_BYPRODUCTS ${ulp_artifacts} ${ulp_artifacts_extras} ${ulp_ps_sources} ${CMAKE_CURRENT_BINARY_DIR}/${app_name}/${app_name} BUILD_ALWAYS 1 - LIST_SEPARATOR | ) + set_property(TARGET ${app_name} PROPERTY ULP_SOURCES "${sources}") + spaces2list(exp_dep_srcs) set_source_files_properties(${exp_dep_srcs} PROPERTIES OBJECT_DEPENDS ${ulp_artifacts}) From 7dbd77cefc5c6d13b7ac2101589cf332b3233fe3 Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Tue, 3 Mar 2020 16:15:29 +0800 Subject: [PATCH 2/2] examples: split source files for one of the ulp examples --- examples/system/ulp/README.md | 2 +- examples/system/ulp/main/CMakeLists.txt | 2 +- examples/system/ulp/main/component.mk | 2 +- examples/system/ulp/main/ulp/pulse_cnt.S | 11 ----------- examples/system/ulp/main/ulp/wake_up.S | 16 ++++++++++++++++ 5 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 examples/system/ulp/main/ulp/wake_up.S diff --git a/examples/system/ulp/README.md b/examples/system/ulp/README.md index 3c854043ed..d76506a5d4 100644 --- a/examples/system/ulp/README.md +++ b/examples/system/ulp/README.md @@ -2,7 +2,7 @@ This example demonstrates how to program the ULP coprocessor to count pulses on an IO while the main CPUs are either running some other code or are in deep sleep. See the README.md file in the upper level 'examples' directory for more information about examples. -ULP program written in assembly can be found in `ulp/pulse_cnt.S`. The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application. +ULP program written in assembly can be found across `ulp/pulse_cnt.S` and `ulp/wake_up.S` (demonstrating multiple ULP source files). The build system assembles and links this program, converts it into binary format, and embeds it into the .rodata section of the ESP-IDF application. At runtime, the main code running on the ESP32 (found in main.c) loads ULP program into the `RTC_SLOW_MEM` memory region using `ulp_load_binary` function. Main code configures the ULP program by setting up values of some variables and then starts it using `ulp_run`. Once the ULP program is started, it runs periodically, with the period set by the main program. The main program enables ULP wakeup source and puts the chip into deep sleep mode. diff --git a/examples/system/ulp/main/CMakeLists.txt b/examples/system/ulp/main/CMakeLists.txt index 98925d11a2..1ac5db2578 100644 --- a/examples/system/ulp/main/CMakeLists.txt +++ b/examples/system/ulp/main/CMakeLists.txt @@ -10,7 +10,7 @@ set(ulp_app_name ulp_${COMPONENT_NAME}) # 2. Specify all assembly source files. # Files should be placed into a separate directory (in this case, ulp/), # which should not be added to COMPONENT_SRCS. -set(ulp_s_sources "ulp/pulse_cnt.S") +set(ulp_s_sources "ulp/pulse_cnt.S" "ulp/wake_up.S") # # 3. List all the component source files which include automatically # generated ULP export file, ${ulp_app_name}.h: diff --git a/examples/system/ulp/main/component.mk b/examples/system/ulp/main/component.mk index 566757a56b..55c5ba352b 100644 --- a/examples/system/ulp/main/component.mk +++ b/examples/system/ulp/main/component.mk @@ -11,7 +11,7 @@ ULP_APP_NAME ?= ulp_$(COMPONENT_NAME) # Files should be placed into a separate directory (in this case, ulp/), # which should not be added to COMPONENT_SRCDIRS. ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \ - pulse_cnt.S \ + pulse_cnt.S wake_up.S\ ) # # 3. List all the component object files which include automatically diff --git a/examples/system/ulp/main/ulp/pulse_cnt.S b/examples/system/ulp/main/ulp/pulse_cnt.S index 774375e2a1..33e6ef6867 100644 --- a/examples/system/ulp/main/ulp/pulse_cnt.S +++ b/examples/system/ulp/main/ulp/pulse_cnt.S @@ -144,14 +144,3 @@ edge_detected: jump wake_up, eq /* Not yet. End program */ halt - - .global wake_up -wake_up: - /* Check if the system can be woken up */ - READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP) - and r0, r0, 1 - jump wake_up, eq - - /* Wake up the SoC, end program */ - wake - halt diff --git a/examples/system/ulp/main/ulp/wake_up.S b/examples/system/ulp/main/ulp/wake_up.S new file mode 100644 index 0000000000..ec2e05da4e --- /dev/null +++ b/examples/system/ulp/main/ulp/wake_up.S @@ -0,0 +1,16 @@ +/* ULP assembly files are passed through C preprocessor first, so include directives + and C macros may be used in these files + */ +#include "soc/rtc_cntl_reg.h" +#include "soc/soc_ulp.h" + + .global wake_up +wake_up: + /* Check if the system can be woken up */ + READ_RTC_FIELD(RTC_CNTL_LOW_POWER_ST_REG, RTC_CNTL_RDY_FOR_WAKEUP) + and r0, r0, 1 + jump wake_up, eq + + /* Wake up the SoC, end program */ + wake + halt