You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tools/cmake_utilities/docs/relinker.md
+44-8Lines changed: 44 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
In ESP-IDF, some functions are put in SRAM when link stage, the reason is that some functions are critical, we need to put them in SRAM to speed up the program, or the functions will be executed when the cache is disabled. But actually, some functions can be put into Flash, here, we provide a script to let the user set the functions which are located in SRAM by default to put them into Flash, in order to save more SRAM which can be used as heap region later. This happens in the linker stage, so we call it as relinker.
4
4
5
+
Some SoCs(ESP32-C2 and ESP32-C3) support hardware auto flash-suspend, meaning when reading, writing, or erasing the flash stage, the CPU hardware can switch to run code laying in the flash automatically without any software assist, so that we can link more functions from IRAM to flash.
6
+
5
7
## Use
6
8
7
9
In order to use this feature, you need to include the needed CMake file in your project's CMakeLists.txt after `project(XXXX)`.
@@ -14,28 +16,52 @@ include(relinker)
14
16
15
17
The relinker feature is disabled by default, in order to use it, you need to enable the option `CU_RELINKER_ENABLE` in menuconfig.
16
18
17
-
Here are the default configuration files in the folder `cmake_utilities/scripts/relinker/examples/esp32c2`, it's just used as a reference. If you would like to use your own configuration files, please enable option `CU_RELINKER_ENABLE_CUSTOMIZED_CONFIGURATION_FILES` and set the path of your configuration files as following, this path is evaluated relative to the project root directory:
19
+
Here are the default configuration files in the folder `cmake_utilities/scripts/relinker/examples/flash_suspend/XXX (XXX=esp32c2, esp32c3...)` for specific SoC platform when flash_suspend and relinker feature are enabled, please note that the configuration files may be slightly different for different ESP-IDF versions, it's just used as a reference. If you would like to use your own configuration files, please enable option `CU_RELINKER_ENABLE_CUSTOMIZED_CONFIGURATION_FILES` and set the path of your configuration files as following, this path is evaluated relative to the project root directory:
(path of your configuration files) Customized relinker configuration files path
22
24
```
23
25
24
-
> Note: Currently only esp32c2 is supported.
26
+
If you would like to save more RAM, you can try flash-suspend feature, enable options as following:
27
+
28
+
```
29
+
Component config --->
30
+
SPI Flash driver --->
31
+
[ ] Use esp_flash implementation in ROM
32
+
[*] Auto suspend long erase/write operations (READ DOCS FIRST)
33
+
34
+
CMake Utilities --->
35
+
[*] Enable relinker
36
+
[*] Link specific functions to IRAM regardless of ESP-IDF's behavior
37
+
```
38
+
39
+
> Note: Currently supported platform: esp32c2 and esp32c3.
40
+
> Note: Before enable flash-suspend, please check if ESP-IDF supports this flash's flash-suspend feature.
25
41
26
42
## Configuration Files
27
43
28
-
You can refer to the files in the directory of `cmake_utilities/scripts/relinker/examples/esp32c2`:
44
+
You can refer to the files in the directory of `cmake_utilities/scripts/relinker/examples/$ACTION/XXX ($ACTION=iram_strip, flash_suspend) (XXX=esp32c2, esp32c3...)`:
29
45
30
46
- library.csv
31
47
- object.csv
32
48
- function.csv
33
49
34
-
For example, if you want to link function `__getreent` from SRAM to Flash, firstly you should add it to `function.csv` file as following:
50
+
1. iram_strip
35
51
36
-
```
37
-
libfreertos.a,tasks.c.obj,__getreent,
38
-
```
52
+
For `example/iram_strip`, it includes the functions which you want to relink into Flash after enable the option `CU_RELINKER_ENABLE` and disable the option `CU_RELINKER_LINK_SPECIFIC_FUNCTIONS_TO_IRAM` in menuconfig. If you want to link function `__getreent` from SRAM to Flash, firstly you should add it to `function.csv` file as following:
53
+
54
+
```
55
+
libfreertos.a,tasks.c.obj,__getreent,
56
+
```
57
+
58
+
2. flash_suspend
59
+
60
+
For `example/flash_suspend`, it includes the functions which you want to relink into SRAM after enable the options: `SPI_FLASH_AUTO_SUSPEND`, `CU_RELINKER_ENABLE`, `CU_RELINKER_LINK_SPECIFIC_FUNCTIONS_TO_IRAM` in menuconfig. If you want to link function `__getreent` into SRAM no matter its original locations, firstly you should add it to `function.csv` file as following:
61
+
62
+
```
63
+
libfreertos.a,tasks.c.obj,__getreent,
64
+
```
39
65
40
66
This means function `__getreent` is in object file `tasks.c.obj`, and object file `tasks.c.obj` is in library `libfreertos.a`.
All of the above examples are compiled on ESP-IDF Tag/v5.3.2 and version v1.1.0 of `cmake_utilities` component, you can view the memory type usage summary by using `idf.py size`, the above data is for reference only.
0 commit comments