OpenOCD
|
API defined below allows executing pieces of code on target without breaking the execution of the running program. More...
Data Fields | |
uint32_t | bss_size |
BSS section size. More... | |
uint32_t | dram_len |
Total reserved DRAM size. More... | |
uint32_t | dram_org |
DRAM start address in the linker script. More... | |
struct image | image |
Image. More... | |
uint32_t | iram_len |
Total reserved IRAM size. More... | |
uint32_t | iram_org |
IRAM start address in the linker script. More... | |
bool | reverse |
IRAM DRAM address range reversed or not. More... | |
API defined below allows executing pieces of code on target without breaking the execution of the running program.
This functionality can be useful for various debugging and maintenance procedures.
int stub_entry([uint32_t a1 [, uint32_t a2 [, uint32_t a3 [, uint32_t a4 [, uint32_t a5]]]]]);
The general scheme of stub code execution is shown below.
----— --------— (initial frame) -— | | ----—(registers, stub entry, stub args)---—> |trampoline | —(stub args)—> | | | | | | | | |OpenOCD| <-------—(stub-specific communications)------------------------------------—> |stub| | | | | | | | | <------—(target halted event, ret code)----— |tramp break| <—(ret code)-— | |
Procedure of executing stub on target includes: 1) User prepares struct esp_algorithm_run_data and calls one of algorithm_run_xxx() functions. 2) Routine allocates all necessary stub code and data sections. 3) If a user specifies an initializer func esp_algorithm_usr_func_init_t it is called just before the stub starts. 4) If user specifies stub communication func esp_algorithm_usr_func_t (
There are two options to run code on target under OpenOCD control:
To run external code on the target user should use esp_algorithm_run_func_image(). In this case all necessary memory (code/data) is allocated in working areas that have fixed configuration defined in target TCL file. Stub code is actually a standalone program, so all its segments must have known addresses due to position-dependent code nature. So stub must be linked in such a way that its code segment starts at the beginning of the working area for code space defined in TCL. The same restriction must be applied to stub's data segment and base addresses of working area for data space.
data space working area start |
---|
<stub .data segment> |
___________________________________________ |
stub .bss start |
<stub .bss segment of size 'bss_size'> |
___________________________________________ |
stub stack base |
<stub stack> |
___________________________________________ |
<stub mem arg1> |
___________________________________________ |
<stub mem arg2> |
___________________________________________ |
code space working area start |
---|
<stub .text segment> |
___________________________________________ |
<stub trampoline with exit breakpoint> |
___________________________________________ |
For example on how to execute external code with memory arguments
To run on-board code on the target user should use esp_algorithm_run_onboard_func(). On-board code execution process does not need to allocate target memory for stub code and data, Because the stub is pre-compiled to the code running on the target. But it still needs memory for stub trampoline, stack, and memory arguments. Working areas can not be used due to possible memory layout conflicts with on-board stub code and data. Debug stubs functionality provided by ESP IDF allows OpenOCD to overcome the above problem. It provides a special descriptor which provides info necessary to safely allocate memory on target.
Definition at line 117 of file esp_algorithm.h.
uint32_t esp_algorithm_image::bss_size |
BSS section size.
Definition at line 121 of file esp_algorithm.h.
Referenced by esp_algorithm_load_func_image().
uint32_t esp_algorithm_image::dram_len |
Total reserved DRAM size.
Definition at line 129 of file esp_algorithm.h.
uint32_t esp_algorithm_image::dram_org |
DRAM start address in the linker script.
Definition at line 127 of file esp_algorithm.h.
Referenced by esp_algorithm_load_func_image(), and load_section_from_image().
struct image esp_algorithm_image::image |
Image.
Definition at line 409 of file esp_algorithm.h.
Referenced by esp_algorithm_exec_func_image_va(), esp_algorithm_load_func_image(), and load_section_from_image().
uint32_t esp_algorithm_image::iram_len |
Total reserved IRAM size.
Definition at line 125 of file esp_algorithm.h.
Referenced by esp_algorithm_load_func_image().
uint32_t esp_algorithm_image::iram_org |
IRAM start address in the linker script.
Definition at line 123 of file esp_algorithm.h.
Referenced by esp_algorithm_load_func_image().
bool esp_algorithm_image::reverse |
IRAM DRAM address range reversed or not.
Definition at line 131 of file esp_algorithm.h.
Referenced by esp_algorithm_load_func_image().