Chapter 4. API Guides
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 assembly file (foo.S) through the C preprocessor. This step generates the preprocessed
assembly files (foo.ulp.S) in the component build directory. This step also generates dependency files
(foo.ulp.d).
2. Run preprocessed assembly sources through the assembler. This produces object (foo.ulp.o) and
listing (foo.ulp.lst) files. Listing files are generated for debugging purposes and are not used at later
stages of the build process.
3. 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).
(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.
6. Generate a list of global symbols (ulp_app_name.sym) in the ELF file using esp32ulp-elf-
nm.
7. Create an LD export script and header file (ulp_app_name.ld and ulp_app_name.h) con-
taining the symbols from ulp_app_name.sym. This is done using the esp32ulp_mapgen.py
utility.
8. Add the generated binary to the list of binary files to be embedded into the application.
4.28.5 Accessing the ULP Program Variables
Global symbols defined in the ULP program may be used inside the main program.
For example, the ULP program may define a variable measurement_count which will define the number of
ADC measurements the program needs to make before waking up the chip from deep sleep:
measurement_count:
The main program needs to initialize this variable before the ULP program is started. The build system makes this
possible by generating the ${ULP_APP_NAME}.h and ${ULP_APP_NAME}.ld files which define the global
symbols present in the ULP program. Each global symbol defined in the ULP program is included in these files and
are prefixed with ulp_.
The header file contains the declaration of the symbol:
extern uint32_t ulp_measurement_count;
Note that all symbols (variables, arrays, functions) are declared as uint32_t. For functions and arrays, take the
address of the symbol and cast it to the appropriate type.
The generated linker script file defines the locations of symbols in RTC_SLOW_MEM:
PROVIDE ( ulp_measurement_count
To access the ULP program variables from the main program, the generated header file should be included using an
include statement. This will allow the ULP program variables to be accessed as regular variables:
#include "ulp_app_name.h"
//
later
void init_ulp_vars() {
ulp_measurement_count
}
Espressif Systems
.global
measurement_count
.long
0
/*
later, use measurement_count
move r3, measurement_count
ld r3, r3,
0
=
0x50000060
=
64;
1497
Submit Document Feedback
*/
);
The Map file
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers