mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/ulp_fixes_v3.0' into 'release/v3.0'
ULP fixes (backport v3.0) See merge request idf/esp-idf!3002
This commit is contained in:
commit
132b439359
@ -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)
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -857,7 +858,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
|
||||
*
|
||||
|
@ -1 +1,11 @@
|
||||
COMPONENT_ADD_LDFLAGS = -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||
ULP_APP_NAME = ulp_test
|
||||
|
||||
ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \
|
||||
test_jumps.S \
|
||||
)
|
||||
|
||||
ULP_EXP_DEP_OBJECTS := test_ulp_as.o
|
||||
|
||||
include $(IDF_PATH)/components/ulp/component_ulp_common.mk
|
||||
|
||||
COMPONENT_ADD_LDFLAGS += -Wl,--whole-archive -l$(COMPONENT_NAME) -Wl,--no-whole-archive
|
||||
|
25
components/ulp/test/test_ulp_as.c
Normal file
25
components/ulp/test/test_ulp_as.c
Normal file
@ -0,0 +1,25 @@
|
||||
#include <unistd.h>
|
||||
#include "unity.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "esp32/ulp.h"
|
||||
#include "ulp_test.h"
|
||||
|
||||
|
||||
extern const uint8_t ulp_test_bin_start[] asm("_binary_ulp_test_bin_start");
|
||||
extern const uint8_t ulp_test_bin_end[] asm("_binary_ulp_test_bin_end");
|
||||
|
||||
|
||||
TEST_CASE("jumps condition", "[ulp]")
|
||||
{
|
||||
esp_err_t err = ulp_load_binary(0, ulp_test_bin_start,
|
||||
(ulp_test_bin_end - ulp_test_bin_start) / sizeof(uint32_t));
|
||||
TEST_ESP_OK(err);
|
||||
|
||||
REG_CLR_BIT(RTC_CNTL_INT_RAW_REG, RTC_CNTL_ULP_CP_INT_RAW);
|
||||
TEST_ESP_OK(ulp_run(&ulp_test_jumps - RTC_SLOW_MEM));
|
||||
usleep(10000);
|
||||
|
||||
TEST_ASSERT_NOT_EQUAL(0, REG_GET_BIT(RTC_CNTL_INT_RAW_REG, RTC_CNTL_ULP_CP_INT_RAW));
|
||||
TEST_ASSERT_EQUAL(0, ulp_jumps_fail & UINT16_MAX);
|
||||
TEST_ASSERT_EQUAL(1, ulp_jumps_pass & UINT16_MAX);
|
||||
}
|
101
components/ulp/test/ulp/test_jumps.S
Normal file
101
components/ulp/test/ulp/test_jumps.S
Normal file
@ -0,0 +1,101 @@
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
#include "soc/rtc_io_reg.h"
|
||||
#include "soc/soc_ulp.h"
|
||||
|
||||
.bss
|
||||
|
||||
.global jumps_pass
|
||||
jumps_pass:
|
||||
.long 0
|
||||
|
||||
.global jumps_fail
|
||||
jumps_fail:
|
||||
.long 0
|
||||
|
||||
.text
|
||||
.global test_jumps
|
||||
test_jumps:
|
||||
|
||||
/* tests for LT (less than) condition */
|
||||
stage_rst /* cnt = 0 */
|
||||
jumps test_fail, 0, LT /* 0 < 0: false, should not jump */
|
||||
jumps 1f, 1, LT /* 0 < 1: true, should jump */
|
||||
jump test_fail
|
||||
1:
|
||||
stage_inc 2 /* cnt = 2 */
|
||||
jumps 1f, 3, LT /* 2 < 1: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps test_fail, 1, LT /* 2 < 1: false */
|
||||
jumps test_fail, 2, LT /* 2 < 2: false */
|
||||
|
||||
/* tests for LE (less or equal) condition */
|
||||
stage_rst /* cnt = 0 */
|
||||
jumps 1f, 0, LE /* 0 <= 0: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps 1f, 1, LE /* 0 <= 1: true */
|
||||
jump test_fail
|
||||
1:
|
||||
stage_inc 2 /* cnt = 2 */
|
||||
jumps test_fail, 1, LE /* 2 <= 1: false */
|
||||
|
||||
/* tests for EQ (equal) condition */
|
||||
stage_rst /* cnt = 0 */
|
||||
jumps 1f, 0, EQ /* 0 = 0: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps test_fail, 1, EQ /* 0 = 1: false */
|
||||
|
||||
stage_inc 1 /* cnt = 1 */
|
||||
jumps test_fail, 0, EQ /* 1 = 0: false */
|
||||
jumps test_fail, 2, EQ /* 1 = 2: false */
|
||||
jumps 1f, 1, EQ /* 1 = 1: true */
|
||||
1:
|
||||
|
||||
/* tests for GE (greater or equal) condition */
|
||||
stage_rst /* cnt = 0 */
|
||||
jumps 1f, 0, GE /* 0 >= 0: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps test_fail, 1, GE /* 0 >= 1: false */
|
||||
|
||||
stage_inc 1 /* cnt = 1 */
|
||||
jumps 1f, 0, GE /* 1 >= 0: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps 1f, 1, GE /* 1 >= 1: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps test_fail, 2, GE /* 1 >= 2: false */
|
||||
|
||||
/* tests for GT (greater than) condition */
|
||||
stage_rst /* cnt = 0 */
|
||||
jumps test_fail, 0, GT /* 0 > 0: false */
|
||||
jumps test_fail, 1, GE /* 0 > 1: false */
|
||||
|
||||
stage_inc 1 /* cnt = 1 */
|
||||
jumps 1f, 0, GT /* 1 > 0: true */
|
||||
jump test_fail
|
||||
1:
|
||||
jumps test_fail, 1, GT /* 1 > 1: false */
|
||||
jumps test_fail, 2, GT /* 1 > 2: false */
|
||||
|
||||
jump test_pass
|
||||
|
||||
test_fail:
|
||||
move r0, jumps_fail
|
||||
move r1, 1
|
||||
st r1, r0, 0
|
||||
jump done
|
||||
|
||||
test_pass:
|
||||
move r0, jumps_pass
|
||||
move r1, 1
|
||||
st r1, r0, 0
|
||||
jump done
|
||||
|
||||
.global done
|
||||
done:
|
||||
wake
|
||||
halt
|
@ -15,8 +15,8 @@ Installing the toolchain
|
||||
|
||||
ULP coprocessor code is written in assembly and compiled using the `binutils-esp32ulp toolchain`_.
|
||||
|
||||
1. Download the toolchain using the links listed on this page:
|
||||
https://github.com/espressif/binutils-esp32ulp/wiki#downloads
|
||||
1. Download pre-built binaries of the latest toolchain release from:
|
||||
https://github.com/espressif/binutils-esp32ulp/releases.
|
||||
|
||||
2. Extract the toolchain into a directory, and add the path to the ``bin/`` directory of the toolchain to the ``PATH`` environment variable.
|
||||
|
||||
@ -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
|
||||
|
||||
|
1830
docs/api-guides/ulp_instruction_set.rst
Executable file → Normal file
1830
docs/api-guides/ulp_instruction_set.rst
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
@ -80,7 +80,7 @@ static void init_ulp_program()
|
||||
REG_SET_FIELD(SENS_ULP_CP_SLEEP_CYC0_REG, SENS_SLEEP_CYCLES_S0, 3095);
|
||||
|
||||
/* 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);
|
||||
}
|
||||
|
||||
|
@ -87,6 +87,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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user