Skip to content

Commit

Permalink
ulp: Added support for ULP FSM on esp32s3 and fixed bugs for esp32s2
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sudeep-mohanty committed Feb 22, 2022
1 parent 159bce3 commit 4d8a0cc
Show file tree
Hide file tree
Showing 25 changed files with 1,685 additions and 721 deletions.
3 changes: 2 additions & 1 deletion components/ulp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ if(CONFIG_SOC_ULP_SUPPORTED OR CONFIG_SOC_RISCV_COPROC_SUPPORTED)
"ulp_fsm/ulp_macro.c")

list(APPEND includes
ulp_fsm/include)
ulp_fsm/include
ulp_fsm/include/${target})

elseif(CONFIG_ULP_COPROC_TYPE_RISCV)
list(APPEND srcs
Expand Down
43 changes: 39 additions & 4 deletions components/ulp/README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Programming ULP FSM coprocessor using C macros (legacy)
=======================================================

In addition to the existing binutils port for the ESP32 ULP coprocessor, it is possible to generate programs for the ULP by embedding assembly-like macros into an ESP32 application. Here is an example how this can be done::
In addition to the existing binutils port for the {IDF_TARGET_NAME} ULP coprocessor, it is possible to generate programs for the ULP by embedding assembly-like macros into an {IDF_TARGET_NAME} application. Here is an example how this can be done::

const ulp_insn_t program[] = {
I_MOVI(R3, 16), // R3 <- 16
Expand Down Expand Up @@ -65,7 +65,6 @@ Header File

.. list::

:component_file:`ulp/ulp_fsm/include/ulp_fsm_common.h`
:esp32: - :component_file:`ulp/ulp_fsm/include/esp32/ulp.h`
:esp32s2: - :component_file:`ulp/ulp_fsm/include/esp32s2/ulp.h`
:esp32s3: - :component_file:`ulp/ulp_fsm/include/esp32s3/ulp.h`
Expand Down Expand Up @@ -103,11 +102,39 @@ ULP coprocessor instruction defines
.. doxygendefine:: I_HALT
.. doxygendefine:: I_END
.. doxygendefine:: I_ST
.. only:: esp32s2 or esp32s3

.. doxygendefine:: I_ST_MANUAL
.. doxygendefine:: I_STL
.. doxygendefine:: I_STH
.. doxygendefine:: I_ST32
.. doxygendefine:: I_STL_LABEL
.. doxygendefine:: I_STH_LABEL
.. doxygendefine:: I_ST_AUTO
.. doxygendefine:: I_STO
.. doxygendefine:: I_STI
.. doxygendefine:: I_STI_LABEL
.. doxygendefine:: I_STI32

.. doxygendefine:: I_LD
.. only:: esp32s2 or esp32s3

.. doxygendefine:: I_LD_MANUAL
.. doxygendefine:: I_LDL
.. doxygendefine:: I_LDH

.. doxygendefine:: I_WR_REG
.. doxygendefine:: I_RD_REG
.. doxygendefine:: I_BL
.. doxygendefine:: I_BGE
.. only:: esp32

.. doxygendefine:: I_BGE

.. only:: esp32s2 or esp32s3

.. doxygendefine:: I_BG
.. doxygendefine:: I_BE

.. doxygendefine:: I_BXR
.. doxygendefine:: I_BXI
.. doxygendefine:: I_BXZR
Expand All @@ -130,7 +157,15 @@ ULP coprocessor instruction defines
.. doxygendefine:: I_RSHI
.. doxygendefine:: M_LABEL
.. doxygendefine:: M_BL
.. doxygendefine:: M_BGE
.. only:: esp32

.. doxygendefine:: M_BGE

.. only:: esp32s2 or esp32s3

.. doxygendefine:: M_BG
.. doxygendefine:: M_BE

.. doxygendefine:: M_BX
.. doxygendefine:: M_BXZ
.. doxygendefine:: M_BXF
Expand Down
16 changes: 16 additions & 0 deletions components/ulp/cmake/toolchain-esp32s3-ulp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CMake toolchain file for ULP

set(CMAKE_SYSTEM_NAME Generic)

# Compiler is only used for preprocessing
#TODO: Update toolchain to be used once esp32s3 support is added to binutils
set(CMAKE_C_COMPILER "xtensa-esp32s2-elf-gcc")

set(CMAKE_ASM_COMPILER "esp32s2ulp-elf-as")
set(CMAKE_LINKER "esp32s2ulp-elf-ld")

set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "${CMAKE_ASM${ASM_DIALECT}_COMPILER} \
<DEFINES> <INCLUDES> -o <OBJECT> -c <SOURCE>")
set(CMAKE_EXE_LINKER_FLAGS "-A elf32-esp32s2ulp -nostdlib" CACHE STRING "ULP Linker Base Flags")
set(CMAKE_ASM_LINK_EXECUTABLE "${CMAKE_LINKER} <FLAGS> <CMAKE_ASM_LINK_FLAGS> \
<LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>")
19 changes: 10 additions & 9 deletions components/ulp/test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
if(IDF_TARGET STREQUAL "esp32")
set(src_dirs ${IDF_TARGET})
set(ulp_sources "ulp/test_jumps_esp32.S")
elseif(IDF_TARGET STREQUAL "esp32s2" OR IDF_TARGET STREQUAL "esp32s3")
if(CONFIG_ULP_COPROC_TYPE_RISCV)
set(src_dirs "ulp_riscv")
set(ulp_sources "ulp_riscv/ulp/test_main.c")
endif()
#TODO: Add ULP-FSM Test case for esp32s2 and esp32s3
if(CONFIG_ULP_COPROC_TYPE_FSM)

set(src_dirs "ulp_fsm")
set(ulp_sources "ulp_fsm/ulp/test_jumps.S")

elseif(CONFIG_ULP_COPROC_TYPE_RISCV)

set(src_dirs "ulp_riscv")
set(ulp_sources "ulp_riscv/ulp/test_main.c")

endif()

idf_component_register(SRC_DIRS ${src_dirs}
Expand Down
Loading

0 comments on commit 4d8a0cc

Please sign in to comment.