Skip to content

Commit b9ba894

Browse files
sylvioalvesnashif
authored andcommitted
soc: esp32c3: linker script clean up
This PR removes common-rom.ld section so that logging sections can now be mapped into RAM area. Signed-off-by: Sylvio Alves <[email protected]>
1 parent cb8c2d7 commit b9ba894

File tree

3 files changed

+20
-74
lines changed

3 files changed

+20
-74
lines changed

soc/riscv/esp32c3/Kconfig.defconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ if BOOTLOADER_MCUBOOT
1010
config HAS_FLASH_LOAD_OFFSET
1111
default y
1212

13-
config XIP
14-
default y
15-
1613
config MCUBOOT_GENERATE_UNSIGNED_IMAGE
1714
default y
1815

soc/riscv/esp32c3/Kconfig.soc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config SOC_ESP32C3
99
select CLOCK_CONTROL
1010
select CLOCK_CONTROL_ESP32
1111
select PINCTRL
12+
select XIP
1213

1314
if SOC_ESP32C3
1415

soc/riscv/esp32c3/linker.ld

Lines changed: 19 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -121,66 +121,7 @@ SECTIONS
121121
*(.rodata_desc .rodata_desc.*)
122122
*(.rodata_custom_desc .rodata_custom_desc.*)
123123

124-
#ifdef CONFIG_USERSPACE
125-
Z_LINK_ITERABLE_ALIGNED(z_object_assignment, 4);
126-
#endif
127-
128-
#if defined(CONFIG_NET_SOCKETS)
129-
Z_LINK_ITERABLE_ALIGNED(net_socket_register, 4);
130-
#endif
131-
132-
#if defined(CONFIG_NET_L2_PPP)
133-
Z_LINK_ITERABLE_ALIGNED(ppp_protocol_handler, 4);
134-
#endif
135-
136-
Z_LINK_ITERABLE_ALIGNED(bt_l2cap_fixed_chan, 4);
137-
138-
#if defined(CONFIG_BT_BREDR)
139-
Z_LINK_ITERABLE_ALIGNED(bt_l2cap_br_fixed_chan, 4);
140-
#endif
141-
142-
#if defined(CONFIG_BT_CONN)
143-
Z_LINK_ITERABLE_ALIGNED(bt_conn_cb, 4)
144-
#endif
145-
146-
Z_LINK_ITERABLE_ALIGNED(bt_gatt_service_static, 4);
147-
148-
#if defined(CONFIG_BT_MESH)
149-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_subnet_cb, 4);
150-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_app_key_cb, 4);
151-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_hb_cb, 4);
152-
#endif
153-
154-
#if defined(CONFIG_BT_MESH_FRIEND)
155-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_friend_cb, 4);
156-
#endif
157-
158-
#if defined(CONFIG_BT_MESH_LOW_POWER)
159-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_lpn_cb, 4);
160-
#endif
161-
162-
#if defined(CONFIG_BT_MESH_PROXY)
163-
Z_LINK_ITERABLE_ALIGNED(bt_mesh_proxy_cb, 4);
164-
#endif
165-
166-
#if defined(CONFIG_EC_HOST_CMD)
167-
Z_LINK_ITERABLE_ALIGNED(ec_host_cmd_handler, 4);
168-
#endif
169-
170-
#if defined(CONFIG_SETTINGS)
171-
Z_LINK_ITERABLE_ALIGNED(settings_handler_static, 4);
172-
#endif
173-
174-
Z_LINK_ITERABLE_ALIGNED(k_p4wq_initparam, 4);
175-
176-
Z_LINK_ITERABLE_ALIGNED(shell, 4);
177-
178-
Z_LINK_ITERABLE_ALIGNED(tracing_backend, 4)
179-
180124
__rodata_region_start = .;
181-
__esp_shell_root_cmds_start = .;
182-
KEEP(*(SORT(.shell_root_cmd_*)));
183-
__esp_shell_root_cmds_end = .;
184125

185126
. = ALIGN(4);
186127
#include <snippets-rodata.ld>
@@ -254,6 +195,19 @@ SECTIONS
254195
. = ALIGN(4);
255196
} GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION)
256197

198+
/* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA.
199+
* Executing directly from LMA is not possible. */
200+
#pragma push_macro("GROUP_ROM_LINK_IN")
201+
#undef GROUP_ROM_LINK_IN
202+
#define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion
203+
#include "linker/common-rom/common-rom-kernel-devices.ld"
204+
#include "linker/common-rom/common-rom-cpp.ld"
205+
#include "linker/common-rom/common-rom-net.ld"
206+
#include "linker/common-rom/common-rom-bt.ld"
207+
#include "linker/common-rom/common-rom-debug.ld"
208+
#include "linker/common-rom/common-rom-misc.ld"
209+
#pragma pop_macro("GROUP_ROM_LINK_IN")
210+
257211
.iram0.text : ALIGN(4)
258212
{
259213
/* Vectors go to IRAM */
@@ -393,22 +347,16 @@ SECTIONS
393347
. = ALIGN(4);
394348
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
395349

396-
#pragma push_macro("GROUP_ROM_LINK_IN")
397-
#pragma push_macro("ITERABLE_SECTION_ROM")
398-
#undef GROUP_ROM_LINK_IN
399-
#undef ITERABLE_SECTION_ROM
400-
#define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN
401-
#define ITERABLE_SECTION_ROM(x,y)
402-
#include <linker/common-rom.ld>
403-
#pragma pop_macro("GROUP_ROM_LINK_IN")
404-
#pragma pop_macro("ITERABLE_SECTION_ROM")
405-
406350
#include <snippets-data-sections.ld>
407351
#include <linker/common-ram.ld>
408352
#include <snippets-ram-sections.ld>
409353

410-
__shell_root_cmds_start = __esp_shell_root_cmds_start;
411-
__shell_root_cmds_end = __esp_shell_root_cmds_end;
354+
/* logging sections should be placed in RAM area to avoid flash cache disabled issues */
355+
#pragma push_macro("GROUP_ROM_LINK_IN")
356+
#undef GROUP_ROM_LINK_IN
357+
#define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN
358+
#include "linker/common-rom/common-rom-logging.ld"
359+
#pragma pop_macro("GROUP_ROM_LINK_IN")
412360

413361
.dummy.dram.data :
414362
{

0 commit comments

Comments
 (0)