EasyManuals Logo

Espressif ESP32-S2 User Manual

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #1511 background imageLoading...
Page #1511 background image
Chapter 4. API Guides
To disable the timer (effectively preventing the ULP program from running again), clear the
RTC_CNTL_ULP_CP_SLP_TIMER_EN bit in the RTC_CNTL_STATE0_REG register.This can be done
both from ULP code and from the main program.
4.29 ULP-RISC-V Coprocessor programming
The ULP-RISC-V coprocessor is a variant of the ULP, present in ESP32-S2. Similar to ULP, ULP RISC-V copro-
cessor can perform tasks such as sensor readings while the main CPU stays in low power modes. The main difference
from the FSM ULP is this variant can be programmed in C using standard GNU tools. The ULP-RISC-V copro-
cessor can access the RTC_SLOW_MEM memory region, and registers in RTC_CNTL, RTC_IO, and SARADC
peripherals. The RISC-V processor is a 32-bit, fixed point machine. Its instruction set is based on RV32IMC which
includes hardware multiplication and division, and compressed code.
4.29.1 Installing the ULP-RISC-V Toolchain
The ULP-RISC-V coprocessor code is written in C (assembly is also possible) and compiled using RISC-V toolchain
based on GCC.
If you have already set up ESP-IDF with CMake build system according to the Getting Started Guide, then the toolchain
should already be installed.
4.29.2 Compiling the ULP-RISC-V Code
To compile the ULP-RISC-V code as part of the component, the following steps must be taken:
1. The ULP-RISC-V code, written in C or assembly (must use the .S extension), must be placed into a separate
directory inside the component directory, for instance ulp/.
2. Call ulp_embed_binary from the component CMakeLists.txt after registration. For example:
...
idf_component_register()
set(ulp_app_name ulp_${COMPONENT_NAME})
set(ulp_sources "ulp/ulp_c_source_file.c" "ulp/ulp_assembly_source_file.S")
set(ulp_exp_dep_srcs "ulp_c_source_file.c")
ulp_embed_binary(${ulp_app_name} "${ulp_sources}" "${ulp_exp_dep_srcs}")
The first argument to ulp_embed_binary specifies the ULP binary name. The name specified here
will also be used by other generated artifacts such as the ELF file, map file, header file and linker export
file. The second argument specifies the ULP source files. Finally, the third argument specifies the list
of component source files which include the header file to be generated. This list is needed to build the
dependencies correctly and ensure that the generated header file will be created before any of these files
are compiled. See section below for the concept of generated header files for ULP applications.
3. Build the application as usual (e.g. idf.py app)
Inside, the build system will take the following steps to build ULP program:
1. Run each source file through the C compiler and assembler. This step generates the object files
(.obj.c or .obj.S depending of source file processed) in the component build directory.
2. Run the linker script template through the C preprocessor. The template is located in compo-
nents/ulp/ld directory.
4. Link the object files into an output ELF file (ulp_app_name.elf). The Map file
(ulp_app_name.map) generated at this stage may be useful for debugging purposes.
5. Dump the contents of the ELF file into a binary (ulp_app_name.bin) which can then be em-
bedded into the application.
Espressif Systems 1500
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish