From 479af576ca7c7c7711a68ca5793d4b3efa6287b5 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 7 Aug 2018 16:03:23 +0300 Subject: [PATCH 1/4] ulp: fix calculation or ulp_run argument The argument to ulp_run should be expressed in 32-bit words. Both the address of ulp_entry and RTC_SLOW_MEM already are uint32_t*, so their difference is the difference in addresses divided by sizeof(uint32_t). Therefore the extra division by sizeof(uint32_t) is not needed. --- docs/en/api-guides/ulp.rst | 2 +- examples/system/ulp/main/ulp_example_main.c | 2 +- examples/system/ulp_adc/main/ulp_adc_example_main.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/en/api-guides/ulp.rst b/docs/en/api-guides/ulp.rst index 9f913ff81..a5e54d062 100644 --- a/docs/en/api-guides/ulp.rst +++ b/docs/en/api-guides/ulp.rst @@ -134,7 +134,7 @@ Each ULP program is embedded into the ESP-IDF application as a binary blob. Appl Once the program is loaded into RTC memory, application can start it, passing the address of the entry point to ``ulp_run`` function:: - ESP_ERROR_CHECK( ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t)) ); + ESP_ERROR_CHECK( ulp_run(&ulp_entry - RTC_SLOW_MEM) ); .. doxygenfunction:: ulp_run diff --git a/examples/system/ulp/main/ulp_example_main.c b/examples/system/ulp/main/ulp_example_main.c index c03ab20ee..74c4febe4 100644 --- a/examples/system/ulp/main/ulp_example_main.c +++ b/examples/system/ulp/main/ulp_example_main.c @@ -87,7 +87,7 @@ static void init_ulp_program() ulp_set_wakeup_period(0, 20000); /* Start the program */ - err = ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t)); + err = ulp_run(&ulp_entry - RTC_SLOW_MEM); ESP_ERROR_CHECK(err); } diff --git a/examples/system/ulp_adc/main/ulp_adc_example_main.c b/examples/system/ulp_adc/main/ulp_adc_example_main.c index 29d8eac9a..fd7d4ef43 100644 --- a/examples/system/ulp_adc/main/ulp_adc_example_main.c +++ b/examples/system/ulp_adc/main/ulp_adc_example_main.c @@ -89,6 +89,6 @@ static void start_ulp_program() ulp_sample_counter = 0; /* Start the program */ - esp_err_t err = ulp_run((&ulp_entry - RTC_SLOW_MEM) / sizeof(uint32_t)); + esp_err_t err = ulp_run(&ulp_entry - RTC_SLOW_MEM); ESP_ERROR_CHECK(err); } From 33153748bae7877027d716b17fc61ecbc8a9d045 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 7 Aug 2018 16:04:00 +0300 Subject: [PATCH 2/4] ulp: fix missing include in esp32/ulp.h header ulp.h uses some register base addresses, so needs to include soc.h --- components/ulp/include/esp32/ulp.h | 1 + 1 file changed, 1 insertion(+) diff --git a/components/ulp/include/esp32/ulp.h b/components/ulp/include/esp32/ulp.h index 64bfff8c4..ed1e6c90f 100644 --- a/components/ulp/include/esp32/ulp.h +++ b/components/ulp/include/esp32/ulp.h @@ -17,6 +17,7 @@ #include #include #include "esp_err.h" +#include "soc/soc.h" #ifdef __cplusplus extern "C" { From 22dfb92fe0364f58aff446061d41fdac99c4197c Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 7 Aug 2018 16:08:13 +0300 Subject: [PATCH 3/4] ulp: use += instead of := when setting component vars Component which includes component_ulp_common.mk may also need to set some of the same COMPONENT_XXX variables. Logically, we should combine the lists of files to embed, ldflags, extra include dirs, etc. Fixes https://github.com/espressif/esp-idf/issues/2157. --- components/ulp/component_ulp_common.mk | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/components/ulp/component_ulp_common.mk b/components/ulp/component_ulp_common.mk index 70e5b0205..e051af078 100644 --- a/components/ulp/component_ulp_common.mk +++ b/components/ulp/component_ulp_common.mk @@ -81,7 +81,7 @@ build: $(COMPONENT_BUILD_DIR)/$(ULP_EXPORTS_HEADER) \ $(ULP_EXP_DEP_OBJECTS) : $(ULP_EXPORTS_HEADER) $(ULP_SYM) # Finally, set all the variables processed by the build system. -COMPONENT_EXTRA_CLEAN := $(ULP_OBJECTS) \ +COMPONENT_EXTRA_CLEAN += $(ULP_OBJECTS) \ $(ULP_LD_SCRIPT) \ $(ULP_PREPROCESSED) \ $(ULP_ELF) $(ULP_BIN) \ @@ -91,6 +91,6 @@ COMPONENT_EXTRA_CLEAN := $(ULP_OBJECTS) \ $(ULP_DEP) \ $(ULP_LISTINGS) -COMPONENT_EMBED_FILES := $(COMPONENT_BUILD_DIR)/$(ULP_BIN) -COMPONENT_ADD_LDFLAGS := -l$(COMPONENT_NAME) -T $(COMPONENT_BUILD_DIR)/$(ULP_EXPORTS_LD) -COMPONENT_EXTRA_INCLUDES := $(COMPONENT_BUILD_DIR) +COMPONENT_EMBED_FILES += $(COMPONENT_BUILD_DIR)/$(ULP_BIN) +COMPONENT_ADD_LDFLAGS += -l$(COMPONENT_NAME) -T $(COMPONENT_BUILD_DIR)/$(ULP_EXPORTS_LD) +COMPONENT_EXTRA_INCLUDES += $(COMPONENT_BUILD_DIR) From 323caed83b6a6416518ee5e2feb2528d1ba74ca6 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Tue, 7 Aug 2018 16:09:54 +0300 Subject: [PATCH 4/4] ulp: fix ULP binary format documentation Fix incorrect offset value (4+2+2+2+2=12) of arbitrary data in ULP binary format. Closes https://github.com/espressif/esp-idf/issues/1705. --- components/ulp/include/esp32/ulp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ulp/include/esp32/ulp.h b/components/ulp/include/esp32/ulp.h index ed1e6c90f..8acbd7120 100644 --- a/components/ulp/include/esp32/ulp.h +++ b/components/ulp/include/esp32/ulp.h @@ -861,7 +861,7 @@ esp_err_t ulp_process_macros_and_load(uint32_t load_addr, const ulp_insn_t* prog * 3. TEXT_SIZE, size of .text section (2 bytes) * 4. DATA_SIZE, size of .data section (2 bytes) * 5. BSS_SIZE, size of .bss section (2 bytes) - * 6. (TEXT_OFFSET - 16) bytes of arbitrary data (will not be loaded into RTC memory) + * 6. (TEXT_OFFSET - 12) bytes of arbitrary data (will not be loaded into RTC memory) * 7. .text section * 8. .data section *