Skip to content

Commit a0e3d48

Browse files
sudeep-mohantyESP-Marius
authored andcommitted
ulp: Added support for ULP FSM on esp32s3 and fixed bugs for esp32s2
This commit enables ULP FSM support for esp32s3 and updates ULP FSM code flow for other chips. It adds C Macro support for the ULP FSM instruction set on esp32s2 and esp32s3. The unit tests are also updated to test ULP FSM on ep32s2 and esp32s3.
1 parent 74d745a commit a0e3d48

22 files changed

+1651
-711
lines changed

components/ulp/Makefile.projbuild

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ export ULP_AS := $(ULP_BINUTILS_PREFIX)as
44
export ULP_LD := $(ULP_BINUTILS_PREFIX)ld
55
export ULP_OBJCOPY := $(ULP_BINUTILS_PREFIX)objcopy
66
export ULP_OBJDUMP := $(ULP_BINUTILS_PREFIX)objdump
7-
export ULP_LD_TEMPLATE := $(IDF_PATH)/components/ulp/ld/esp32.ulp.ld
7+
export ULP_LD_TEMPLATE := $(IDF_PATH)/components/ulp/ld/ulp_fsm.ld
88
export ULP_NM := $(ULP_BINUTILS_PREFIX)nm
99
export ULP_MAP_GEN := $(IDF_PATH)/components/ulp/esp32ulp_mapgen.py
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# CMake toolchain file for ULP
2+
3+
set(CMAKE_SYSTEM_NAME Generic)
4+
5+
# Compiler is only used for preprocessing
6+
# The S2 and S3 ULP are the same, so we use the same toolchain
7+
set(CMAKE_C_COMPILER "xtensa-esp32s2-elf-gcc")
8+
9+
set(CMAKE_ASM_COMPILER "esp32s2ulp-elf-as")
10+
set(CMAKE_LINKER "esp32s2ulp-elf-ld")
11+
12+
set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "${CMAKE_ASM${ASM_DIALECT}_COMPILER} \
13+
<DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
14+
set(CMAKE_EXE_LINKER_FLAGS "-A elf32-esp32s2ulp -nostdlib" CACHE STRING "ULP Linker Base Flags")
15+
set(CMAKE_ASM_LINK_EXECUTABLE "${CMAKE_LINKER} <FLAGS> <CMAKE_ASM_LINK_FLAGS> \
16+
<LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")

components/ulp/include/esp32/ulp.h

+2
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,8 @@ union ulp_insn {
289289

290290
};
291291

292+
_Static_assert(sizeof(ulp_insn_t) == 4, "ULP coprocessor instruction size should be 4 bytes");
293+
292294
/**
293295
* Delay (nop) for a given number of cycles
294296
*/

components/ulp/include/esp32s2/ulp.h

+422-105
Large diffs are not rendered by default.

components/ulp/include/esp32s3/ulp.h

+418-103
Large diffs are not rendered by default.

components/ulp/include/ulp_common.h

+16
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@ esp_err_t ulp_run(uint32_t entry_point);
103103
*/
104104
esp_err_t ulp_set_wakeup_period(size_t period_index, uint32_t period_us);
105105

106+
/**
107+
* @brief Stop the ULP timer
108+
*
109+
* @note This will stop the ULP from waking up if halted, but will not abort any program
110+
* currently executing on the ULP.
111+
*/
112+
void ulp_timer_stop(void);
113+
114+
/**
115+
* @brief Resume the ULP timer
116+
*
117+
* @note This will resume an already configured timer, but does no other configuration
118+
*
119+
*/
120+
void ulp_timer_resume(void);
121+
106122
#ifdef __cplusplus
107123
}
108124
#endif

components/ulp/test/CMakeLists.txt

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
if(IDF_TARGET STREQUAL "esp32")
2-
set(src_dirs ${IDF_TARGET})
3-
set(ulp_sources "ulp/test_jumps_esp32.S")
2+
set(src_dirs "ulp_fsm")
3+
set(ulp_sources "ulp_fsm/ulp/test_jumps.S")
44
elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
5-
if(CONFIG_ESP32S2_ULP_COPROC_RISCV STREQUAL "y" OR CONFIG_ESP32S3_ULP_COPROC_RISCV STREQUAL "y")
5+
if(CONFIG_ESP32S2_ULP_COPROC_RISCV OR CONFIG_ESP32S3_ULP_COPROC_RISCV)
66
set(src_dirs "ulp_riscv")
77
set(ulp_sources "ulp_riscv/ulp/test_main.c")
8+
else()
9+
set(src_dirs "ulp_fsm")
10+
set(ulp_sources "ulp_fsm/ulp/test_jumps.S")
811
endif()
9-
#TODO: Add ULP-FSM Test case for esp32s2 and esp32s3
1012
endif()
1113

1214
idf_component_register(SRC_DIRS ${src_dirs}

0 commit comments

Comments
 (0)