diff --git a/include/zephyr/linker/common-rom.ld b/include/zephyr/linker/common-rom.ld index 6856315a9cb87..a9243e9a07e70 100644 --- a/include/zephyr/linker/common-rom.ld +++ b/include/zephyr/linker/common-rom.ld @@ -1,228 +1,15 @@ /* SPDX-License-Identifier: Apache-2.0 */ - SECTION_PROLOGUE(initlevel,,) - { - /* - * link in initialization objects for all objects that are - * automatically initialized by the kernel; the objects are - * sorted in the order they will be initialized (i.e. ordered - * by level, sorted by priority within a level) - */ - __init_start = .; - CREATE_OBJ_LEVEL(init, PRE_KERNEL_1) - CREATE_OBJ_LEVEL(init, PRE_KERNEL_2) - CREATE_OBJ_LEVEL(init, POST_KERNEL) - CREATE_OBJ_LEVEL(init, APPLICATION) - CREATE_OBJ_LEVEL(init, SMP) - __init_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#include "common-rom/common-rom-kernel-devices.ld" - SECTION_PROLOGUE(devices,,) - { - /* Link in devices objects, which are tied to the init ones; - * the objects are thus sorted the same way as their init - * object parent. See above and include/device.h. - */ - __device_start = .; - CREATE_OBJ_LEVEL(device, PRE_KERNEL_1) - CREATE_OBJ_LEVEL(device, PRE_KERNEL_2) - CREATE_OBJ_LEVEL(device, POST_KERNEL) - CREATE_OBJ_LEVEL(device, APPLICATION) - CREATE_OBJ_LEVEL(device, SMP) - __device_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#include "common-rom/common-rom-cpp.ld" -#if defined(CONFIG_GEN_SW_ISR_TABLE) && !defined(CONFIG_DYNAMIC_INTERRUPTS) - SECTION_PROLOGUE(sw_isr_table,,) - { - /* - * Some arch requires an entry to be aligned to arch - * specific boundary for using double word load - * instruction. See include/sw_isr_table.h. - */ - . = ALIGN(CONFIG_ARCH_SW_ISR_TABLE_ALIGN); - *(_SW_ISR_TABLE_SECTION_SYMS) - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) -#endif +#include "common-rom/common-rom-net.ld" - /* verify we don't have rogue .z_init_ initlevel sections */ - SECTION_PROLOGUE(initlevel_error,,) - { - KEEP(*(SORT(.z_init_[_A-Z0-9]*))) - } - ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.") +#include "common-rom/common-rom-bt.ld" -#ifdef CONFIG_CPP_STATIC_INIT_GNU - SECTION_PROLOGUE(_CTOR_SECTION_NAME,,) - { - /* - * The compiler fills the constructor pointers table below, - * hence symbol __CTOR_LIST__ must be aligned on word - * boundary. To align with the C++ standard, the first element - * of the array contains the number of actual constructors. The - * last element is NULL. - */ -#ifdef CONFIG_64BIT - . = ALIGN(8); - __CTOR_LIST__ = .; - QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) - KEEP(*(SORT_BY_NAME(".ctors*"))) - QUAD(0) - __CTOR_END__ = .; -#else - . = ALIGN(4); - __CTOR_LIST__ = .; - LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) - KEEP(*(SORT_BY_NAME(".ctors*"))) - LONG(0) - __CTOR_END__ = .; -#endif - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#include "common-rom/common-rom-logging.ld" - SECTION_PROLOGUE(init_array,,) - { - . = ALIGN(4); - __init_array_start = .; - KEEP(*(SORT_BY_NAME(".init_array*"))) - __init_array_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) -#endif -#ifdef CONFIG_USERSPACE - /* Build-time assignment of permissions to kernel objects to - * threads declared with K_THREAD_DEFINE() - */ - ITERABLE_SECTION_ROM(z_object_assignment, 4) -#endif +#include "common-rom/common-rom-debug.ld" - SECTION_DATA_PROLOGUE(app_shmem_regions,,) - { - __app_shmem_regions_start = .; - KEEP(*(SORT(.app_regions.*))); - __app_shmem_regions_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - -#if defined(CONFIG_NET_SOCKETS) - ITERABLE_SECTION_ROM(net_socket_register, 4) -#endif - -#if defined(CONFIG_NET_L2_PPP) - ITERABLE_SECTION_ROM(ppp_protocol_handler, 4) -#endif - - ITERABLE_SECTION_ROM(bt_l2cap_fixed_chan, 4) - -#if defined(CONFIG_BT_BREDR) - ITERABLE_SECTION_ROM(bt_l2cap_br_fixed_chan, 4) -#endif - -#if defined(CONFIG_BT_CONN) - ITERABLE_SECTION_ROM(bt_conn_cb, 4) -#endif - - ITERABLE_SECTION_ROM(bt_gatt_service_static, 4) - -#if defined(CONFIG_BT_MESH) - ITERABLE_SECTION_ROM(bt_mesh_subnet_cb, 4) - ITERABLE_SECTION_ROM(bt_mesh_app_key_cb, 4) - - ITERABLE_SECTION_ROM(bt_mesh_hb_cb, 4) -#endif - -#if defined(CONFIG_BT_MESH_FRIEND) - ITERABLE_SECTION_ROM(bt_mesh_friend_cb, 4) -#endif - -#if defined(CONFIG_BT_MESH_LOW_POWER) - ITERABLE_SECTION_ROM(bt_mesh_lpn_cb, 4) -#endif - -#if defined(CONFIG_BT_IAS) - ITERABLE_SECTION_ROM(bt_ias_cb, 4) -#endif - -#if defined(CONFIG_BT_MESH_GATT_PROXY) - ITERABLE_SECTION_ROM(bt_mesh_proxy_cb, 4) -#endif - -#if defined(CONFIG_EC_HOST_CMD) - ITERABLE_SECTION_ROM(ec_host_cmd_handler, 4) -#endif - -#if defined(CONFIG_SETTINGS) - ITERABLE_SECTION_ROM(settings_handler_static, 4) -#endif - - ITERABLE_SECTION_ROM(k_p4wq_initparam, 4) - -#if defined(CONFIG_EMUL) - SECTION_DATA_PROLOGUE(emulators_section,,) - { - __emul_list_start = .; - KEEP(*(SORT_BY_NAME(".emulators"))); - __emul_list_end = .; - } GROUP_LINK_IN(ROMABLE_REGION) -#endif /* CONFIG_EMUL */ - -#if defined(CONFIG_DNS_SD) - ITERABLE_SECTION_ROM(dns_sd_rec, 4) -#endif - -#if defined(CONFIG_PCIE) - SECTION_DATA_PROLOGUE(irq_alloc,,) - { - __irq_alloc_start = .; - KEEP(*(SORT_BY_NAME("._irq_alloc*"))); - __irq_alloc_end = .; - } GROUP_LINK_IN(ROMABLE_REGION) -#endif /* CONFIG_PCIE */ - - SECTION_DATA_PROLOGUE(log_strings_sections,,) - { - __log_strings_start = .; - KEEP(*(SORT(.log_strings*))); - __log_strings_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - - SECTION_DATA_PROLOGUE(log_const_sections,,) - { - __log_const_start = .; - KEEP(*(SORT(.log_const_*))); - __log_const_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - - SECTION_DATA_PROLOGUE(log_backends_sections,,) - { - __log_backends_start = .; - KEEP(*("._log_backend.*")); - __log_backends_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - - ITERABLE_SECTION_ROM(shell, 4) - - SECTION_DATA_PROLOGUE(shell_root_cmds_sections,,) - { - __shell_root_cmds_start = .; - KEEP(*(SORT(.shell_root_cmd_*))); - __shell_root_cmds_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - - SECTION_DATA_PROLOGUE(font_entry_sections,,) - { - __font_entry_start = .; - KEEP(*(SORT_BY_NAME("._cfb_font.*"))) - __font_entry_end = .; - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - - ITERABLE_SECTION_ROM(tracing_backend, 4) - - SECTION_DATA_PROLOGUE(zephyr_dbg_info,,) - { - KEEP(*(".dbg_thread_info")); - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - -#if !defined(CONFIG_HAS_DYNAMIC_DEVICE_HANDLES) - SECTION_DATA_PROLOGUE(device_handles,,) - { -#include "device-handles.ld" - } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) -#endif /* !CONFIG_HAS_DYNAMIC_DEVICE_HANDLES */ +#include "common-rom/common-rom-misc.ld" diff --git a/include/zephyr/linker/common-rom/common-rom-bt.ld b/include/zephyr/linker/common-rom/common-rom-bt.ld new file mode 100644 index 0000000000000..1d6c55c0afe02 --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-bt.ld @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + + ITERABLE_SECTION_ROM(bt_l2cap_fixed_chan, 4) + +#if defined(CONFIG_BT_BREDR) + ITERABLE_SECTION_ROM(bt_l2cap_br_fixed_chan, 4) +#endif + +#if defined(CONFIG_BT_CONN) + ITERABLE_SECTION_ROM(bt_conn_cb, 4) +#endif + + ITERABLE_SECTION_ROM(bt_gatt_service_static, 4) + +#if defined(CONFIG_BT_MESH) + ITERABLE_SECTION_ROM(bt_mesh_subnet_cb, 4) + ITERABLE_SECTION_ROM(bt_mesh_app_key_cb, 4) + + ITERABLE_SECTION_ROM(bt_mesh_hb_cb, 4) +#endif + +#if defined(CONFIG_BT_MESH_FRIEND) + ITERABLE_SECTION_ROM(bt_mesh_friend_cb, 4) +#endif + +#if defined(CONFIG_BT_MESH_LOW_POWER) + ITERABLE_SECTION_ROM(bt_mesh_lpn_cb, 4) +#endif + +#if defined(CONFIG_BT_IAS) + ITERABLE_SECTION_ROM(bt_ias_cb, 4) +#endif + +#if defined(CONFIG_BT_MESH_GATT_PROXY) + ITERABLE_SECTION_ROM(bt_mesh_proxy_cb, 4) +#endif diff --git a/include/zephyr/linker/common-rom/common-rom-cpp.ld b/include/zephyr/linker/common-rom/common-rom-cpp.ld new file mode 100644 index 0000000000000..3f302c254680d --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-cpp.ld @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#ifdef CONFIG_CPP_STATIC_INIT_GNU + SECTION_PROLOGUE(_CTOR_SECTION_NAME,,) + { + /* + * The compiler fills the constructor pointers table below, + * hence symbol __CTOR_LIST__ must be aligned on word + * boundary. To align with the C++ standard, the first element + * of the array contains the number of actual constructors. The + * last element is NULL. + */ +#ifdef CONFIG_64BIT + . = ALIGN(8); + __CTOR_LIST__ = .; + QUAD((__CTOR_END__ - __CTOR_LIST__) / 8 - 2) + KEEP(*(SORT_BY_NAME(".ctors*"))) + QUAD(0) + __CTOR_END__ = .; +#else + . = ALIGN(4); + __CTOR_LIST__ = .; + LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) + KEEP(*(SORT_BY_NAME(".ctors*"))) + LONG(0) + __CTOR_END__ = .; +#endif + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_PROLOGUE(init_array,,) + { + . = ALIGN(4); + __init_array_start = .; + KEEP(*(SORT_BY_NAME(".init_array*"))) + __init_array_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#endif diff --git a/include/zephyr/linker/common-rom/common-rom-debug.ld b/include/zephyr/linker/common-rom/common-rom-debug.ld new file mode 100644 index 0000000000000..1dd9af263df41 --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-debug.ld @@ -0,0 +1,8 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + + ITERABLE_SECTION_ROM(tracing_backend, 4) + + SECTION_DATA_PROLOGUE(zephyr_dbg_info,,) + { + KEEP(*(".dbg_thread_info")); + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) diff --git a/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld b/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld new file mode 100644 index 0000000000000..fc848c5120152 --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-kernel-devices.ld @@ -0,0 +1,85 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + + SECTION_PROLOGUE(initlevel,,) + { + /* + * link in initialization objects for all objects that are + * automatically initialized by the kernel; the objects are + * sorted in the order they will be initialized (i.e. ordered + * by level, sorted by priority within a level) + */ + __init_start = .; + CREATE_OBJ_LEVEL(init, PRE_KERNEL_1) + CREATE_OBJ_LEVEL(init, PRE_KERNEL_2) + CREATE_OBJ_LEVEL(init, POST_KERNEL) + CREATE_OBJ_LEVEL(init, APPLICATION) + CREATE_OBJ_LEVEL(init, SMP) + __init_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_PROLOGUE(devices,,) + { + /* Link in devices objects, which are tied to the init ones; + * the objects are thus sorted the same way as their init + * object parent. See above and include/device.h. + */ + __device_start = .; + CREATE_OBJ_LEVEL(device, PRE_KERNEL_1) + CREATE_OBJ_LEVEL(device, PRE_KERNEL_2) + CREATE_OBJ_LEVEL(device, POST_KERNEL) + CREATE_OBJ_LEVEL(device, APPLICATION) + CREATE_OBJ_LEVEL(device, SMP) + __device_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + +#if defined(CONFIG_GEN_SW_ISR_TABLE) && !defined(CONFIG_DYNAMIC_INTERRUPTS) + SECTION_PROLOGUE(sw_isr_table,,) + { + /* + * Some arch requires an entry to be aligned to arch + * specific boundary for using double word load + * instruction. See include/sw_isr_table.h. + */ + . = ALIGN(CONFIG_ARCH_SW_ISR_TABLE_ALIGN); + *(_SW_ISR_TABLE_SECTION_SYMS) + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#endif + + /* verify we don't have rogue .z_init_ initlevel sections */ + SECTION_PROLOGUE(initlevel_error,,) + { + KEEP(*(SORT(.z_init_[_A-Z0-9]*))) + } + ASSERT(SIZEOF(initlevel_error) == 0, "Undefined initialization levels used.") + +#ifdef CONFIG_USERSPACE + /* Build-time assignment of permissions to kernel objects to + * threads declared with K_THREAD_DEFINE() + */ + ITERABLE_SECTION_ROM(z_object_assignment, 4) +#endif + + SECTION_DATA_PROLOGUE(app_shmem_regions,,) + { + __app_shmem_regions_start = .; + KEEP(*(SORT(.app_regions.*))); + __app_shmem_regions_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + ITERABLE_SECTION_ROM(k_p4wq_initparam, 4) + +#if defined(CONFIG_PCIE) + SECTION_DATA_PROLOGUE(irq_alloc,,) + { + __irq_alloc_start = .; + KEEP(*(SORT_BY_NAME("._irq_alloc*"))); + __irq_alloc_end = .; + } GROUP_LINK_IN(ROMABLE_REGION) +#endif /* CONFIG_PCIE */ + +#if !defined(CONFIG_HAS_DYNAMIC_DEVICE_HANDLES) + SECTION_DATA_PROLOGUE(device_handles,,) + { +#include "linker/device-handles.ld" + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) +#endif /* !CONFIG_HAS_DYNAMIC_DEVICE_HANDLES */ diff --git a/include/zephyr/linker/common-rom/common-rom-logging.ld b/include/zephyr/linker/common-rom/common-rom-logging.ld new file mode 100644 index 0000000000000..48b5a772e5416 --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-logging.ld @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + + SECTION_DATA_PROLOGUE(log_strings_sections,,) + { + __log_strings_start = .; + KEEP(*(SORT(.log_strings*))); + __log_strings_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_DATA_PROLOGUE(log_const_sections,,) + { + __log_const_start = .; + KEEP(*(SORT(.log_const_*))); + __log_const_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_DATA_PROLOGUE(log_backends_sections,,) + { + __log_backends_start = .; + KEEP(*("._log_backend.*")); + __log_backends_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) diff --git a/include/zephyr/linker/common-rom/common-rom-misc.ld b/include/zephyr/linker/common-rom/common-rom-misc.ld new file mode 100644 index 0000000000000..1f74730c830ec --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-misc.ld @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#if defined(CONFIG_EC_HOST_CMD) + ITERABLE_SECTION_ROM(ec_host_cmd_handler, 4) +#endif + +#if defined(CONFIG_SETTINGS) + ITERABLE_SECTION_ROM(settings_handler_static, 4) +#endif + +#if defined(CONFIG_EMUL) + SECTION_DATA_PROLOGUE(emulators_section,,) + { + __emul_list_start = .; + KEEP(*(SORT_BY_NAME(".emulators"))); + __emul_list_end = .; + } GROUP_LINK_IN(ROMABLE_REGION) +#endif /* CONFIG_EMUL */ + + ITERABLE_SECTION_ROM(shell, 4) + + SECTION_DATA_PROLOGUE(shell_root_cmds_sections,,) + { + __shell_root_cmds_start = .; + KEEP(*(SORT(.shell_root_cmd_*))); + __shell_root_cmds_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) + + SECTION_DATA_PROLOGUE(font_entry_sections,,) + { + __font_entry_start = .; + KEEP(*(SORT_BY_NAME("._cfb_font.*"))) + __font_entry_end = .; + } GROUP_ROM_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) diff --git a/include/zephyr/linker/common-rom/common-rom-net.ld b/include/zephyr/linker/common-rom/common-rom-net.ld new file mode 100644 index 0000000000000..7876196d2d9d4 --- /dev/null +++ b/include/zephyr/linker/common-rom/common-rom-net.ld @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#if defined(CONFIG_NET_SOCKETS) + ITERABLE_SECTION_ROM(net_socket_register, 4) +#endif + +#if defined(CONFIG_NET_L2_PPP) + ITERABLE_SECTION_ROM(ppp_protocol_handler, 4) +#endif + +#if defined(CONFIG_DNS_SD) + ITERABLE_SECTION_ROM(dns_sd_rec, 4) +#endif diff --git a/soc/riscv/esp32c3/Kconfig.defconfig b/soc/riscv/esp32c3/Kconfig.defconfig index 59de6f3988fb1..e028c7737cf59 100644 --- a/soc/riscv/esp32c3/Kconfig.defconfig +++ b/soc/riscv/esp32c3/Kconfig.defconfig @@ -10,9 +10,6 @@ if BOOTLOADER_MCUBOOT config HAS_FLASH_LOAD_OFFSET default y -config XIP - default y - config MCUBOOT_GENERATE_UNSIGNED_IMAGE default y diff --git a/soc/riscv/esp32c3/Kconfig.soc b/soc/riscv/esp32c3/Kconfig.soc index ca53d0f672e3d..331a614949683 100644 --- a/soc/riscv/esp32c3/Kconfig.soc +++ b/soc/riscv/esp32c3/Kconfig.soc @@ -9,6 +9,7 @@ config SOC_ESP32C3 select CLOCK_CONTROL select CLOCK_CONTROL_ESP32 select PINCTRL + select XIP if SOC_ESP32C3 diff --git a/soc/riscv/esp32c3/linker.ld b/soc/riscv/esp32c3/linker.ld index a94777e597526..611e7843d56bc 100644 --- a/soc/riscv/esp32c3/linker.ld +++ b/soc/riscv/esp32c3/linker.ld @@ -121,66 +121,7 @@ SECTIONS *(.rodata_desc .rodata_desc.*) *(.rodata_custom_desc .rodata_custom_desc.*) -#ifdef CONFIG_USERSPACE - Z_LINK_ITERABLE_ALIGNED(z_object_assignment, 4); -#endif - -#if defined(CONFIG_NET_SOCKETS) - Z_LINK_ITERABLE_ALIGNED(net_socket_register, 4); -#endif - -#if defined(CONFIG_NET_L2_PPP) - Z_LINK_ITERABLE_ALIGNED(ppp_protocol_handler, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_fixed_chan, 4); - -#if defined(CONFIG_BT_BREDR) - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_br_fixed_chan, 4); -#endif - -#if defined(CONFIG_BT_CONN) - Z_LINK_ITERABLE_ALIGNED(bt_conn_cb, 4) -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_gatt_service_static, 4); - -#if defined(CONFIG_BT_MESH) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_subnet_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_app_key_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_hb_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_FRIEND) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_friend_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_LOW_POWER) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_lpn_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_PROXY) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_proxy_cb, 4); -#endif - -#if defined(CONFIG_EC_HOST_CMD) - Z_LINK_ITERABLE_ALIGNED(ec_host_cmd_handler, 4); -#endif - -#if defined(CONFIG_SETTINGS) - Z_LINK_ITERABLE_ALIGNED(settings_handler_static, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(k_p4wq_initparam, 4); - - Z_LINK_ITERABLE_ALIGNED(shell, 4); - - Z_LINK_ITERABLE_ALIGNED(tracing_backend, 4) - __rodata_region_start = .; - __esp_shell_root_cmds_start = .; - KEEP(*(SORT(.shell_root_cmd_*))); - __esp_shell_root_cmds_end = .; . = ALIGN(4); #include @@ -254,6 +195,19 @@ SECTIONS . = ALIGN(4); } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) + /* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA. + * Executing directly from LMA is not possible. */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion + #include "linker/common-rom/common-rom-kernel-devices.ld" + #include "linker/common-rom/common-rom-cpp.ld" + #include "linker/common-rom/common-rom-net.ld" + #include "linker/common-rom/common-rom-bt.ld" + #include "linker/common-rom/common-rom-debug.ld" + #include "linker/common-rom/common-rom-misc.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") + .iram0.text : ALIGN(4) { /* Vectors go to IRAM */ @@ -393,22 +347,16 @@ SECTIONS . = ALIGN(4); } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - #pragma push_macro("GROUP_ROM_LINK_IN") - #pragma push_macro("ITERABLE_SECTION_ROM") - #undef GROUP_ROM_LINK_IN - #undef ITERABLE_SECTION_ROM - #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN - #define ITERABLE_SECTION_ROM(x,y) - #include - #pragma pop_macro("GROUP_ROM_LINK_IN") - #pragma pop_macro("ITERABLE_SECTION_ROM") - #include #include #include - __shell_root_cmds_start = __esp_shell_root_cmds_start; - __shell_root_cmds_end = __esp_shell_root_cmds_end; + /* logging sections should be placed in RAM area to avoid flash cache disabled issues */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN + #include "linker/common-rom/common-rom-logging.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") .dummy.dram.data : { diff --git a/soc/xtensa/esp32/Kconfig.defconfig b/soc/xtensa/esp32/Kconfig.defconfig index 41f43788977dc..9827fa5cda8a5 100644 --- a/soc/xtensa/esp32/Kconfig.defconfig +++ b/soc/xtensa/esp32/Kconfig.defconfig @@ -9,9 +9,6 @@ if BOOTLOADER_MCUBOOT config HAS_FLASH_LOAD_OFFSET default y - config XIP - default y - config MCUBOOT_GENERATE_UNSIGNED_IMAGE default y diff --git a/soc/xtensa/esp32/Kconfig.soc b/soc/xtensa/esp32/Kconfig.soc index e20029064dda7..870173b01b78a 100644 --- a/soc/xtensa/esp32/Kconfig.soc +++ b/soc/xtensa/esp32/Kconfig.soc @@ -10,6 +10,7 @@ config SOC_ESP32 select ARCH_HAS_GDBSTUB select ARCH_SUPPORTS_COREDUMP select PINCTRL + select XIP if SOC_ESP32 diff --git a/soc/xtensa/esp32/linker.ld b/soc/xtensa/esp32/linker.ld index 066c6e946eb7f..538cd0d2ae298 100644 --- a/soc/xtensa/esp32/linker.ld +++ b/soc/xtensa/esp32/linker.ld @@ -142,66 +142,6 @@ SECTIONS { _rodata_start = ABSOLUTE(.); -#ifdef CONFIG_USERSPACE - Z_LINK_ITERABLE_ALIGNED(z_object_assignment, 4); -#endif - -#if defined(CONFIG_NET_SOCKETS) - Z_LINK_ITERABLE_ALIGNED(net_socket_register, 4); -#endif - -#if defined(CONFIG_NET_L2_PPP) - Z_LINK_ITERABLE_ALIGNED(ppp_protocol_handler, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_fixed_chan, 4); - -#if defined(CONFIG_BT_BREDR) - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_br_fixed_chan, 4); -#endif - -#if defined(CONFIG_BT_CONN) - Z_LINK_ITERABLE_ALIGNED(bt_conn_cb, 4) -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_gatt_service_static, 4); - -#if defined(CONFIG_BT_MESH) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_subnet_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_app_key_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_hb_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_FRIEND) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_friend_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_LOW_POWER) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_lpn_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_PROXY) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_proxy_cb, 4); -#endif - -#if defined(CONFIG_EC_HOST_CMD) - Z_LINK_ITERABLE_ALIGNED(ec_host_cmd_handler, 4); -#endif - -#if defined(CONFIG_SETTINGS) - Z_LINK_ITERABLE_ALIGNED(settings_handler_static, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(k_p4wq_initparam, 4); - - Z_LINK_ITERABLE_ALIGNED(shell, 4); - - Z_LINK_ITERABLE_ALIGNED(tracing_backend, 4) - - __esp_shell_root_cmds_start = .; - KEEP(*(SORT(.shell_root_cmd_*))); - __esp_shell_root_cmds_end = .; - . = ALIGN(4); #include @@ -238,6 +178,19 @@ SECTIONS _rodata_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) + /* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA. + * Executing directly from LMA is not possible. */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion + #include "linker/common-rom/common-rom-kernel-devices.ld" + #include "linker/common-rom/common-rom-cpp.ld" + #include "linker/common-rom/common-rom-net.ld" + #include "linker/common-rom/common-rom-bt.ld" + #include "linker/common-rom/common-rom-debug.ld" + #include "linker/common-rom/common-rom-misc.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") + _image_dram_start = LOADADDR(".dram0.data"); _image_dram_size = LOADADDR(".dummy.dram.data") + SIZEOF(".dummy.dram.data") - _image_dram_start; _image_dram_vaddr = ADDR(".dram0.data"); @@ -283,22 +236,16 @@ SECTIONS _dram_data_end = ABSOLUTE(.); } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - #pragma push_macro("GROUP_ROM_LINK_IN") - #pragma push_macro("ITERABLE_SECTION_ROM") - #undef GROUP_ROM_LINK_IN - #undef ITERABLE_SECTION_ROM - #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN - #define ITERABLE_SECTION_ROM(x,y) - #include - #pragma pop_macro("GROUP_ROM_LINK_IN") - #pragma pop_macro("ITERABLE_SECTION_ROM") - #include #include #include - __shell_root_cmds_start = __esp_shell_root_cmds_start; - __shell_root_cmds_end = __esp_shell_root_cmds_end; + /* logging sections should be placed in RAM area to avoid flash cache disabled issues */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN + #include "linker/common-rom/common-rom-logging.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") .dummy.dram.data : { diff --git a/soc/xtensa/esp32s2/Kconfig.defconfig b/soc/xtensa/esp32s2/Kconfig.defconfig index 4c1cb3df21337..649b67134ae7d 100644 --- a/soc/xtensa/esp32s2/Kconfig.defconfig +++ b/soc/xtensa/esp32s2/Kconfig.defconfig @@ -10,9 +10,6 @@ if BOOTLOADER_MCUBOOT config HAS_FLASH_LOAD_OFFSET default y -config XIP - default y - config MCUBOOT_GENERATE_UNSIGNED_IMAGE default y diff --git a/soc/xtensa/esp32s2/Kconfig.soc b/soc/xtensa/esp32s2/Kconfig.soc index c11f13aff7302..8676c681cab69 100644 --- a/soc/xtensa/esp32s2/Kconfig.soc +++ b/soc/xtensa/esp32s2/Kconfig.soc @@ -9,6 +9,7 @@ config SOC_ESP32S2 select CLOCK_CONTROL select CLOCK_CONTROL_ESP32 select PINCTRL + select XIP if SOC_ESP32S2 diff --git a/soc/xtensa/esp32s2/linker.ld b/soc/xtensa/esp32s2/linker.ld index 1cf5e17760bae..819d3e9bf28af 100644 --- a/soc/xtensa/esp32s2/linker.ld +++ b/soc/xtensa/esp32s2/linker.ld @@ -134,66 +134,6 @@ SECTIONS *(.rodata_desc .rodata_desc.*) *(.rodata_custom_desc .rodata_custom_desc.*) -#ifdef CONFIG_USERSPACE - Z_LINK_ITERABLE_ALIGNED(z_object_assignment, 4); -#endif - -#if defined(CONFIG_NET_SOCKETS) - Z_LINK_ITERABLE_ALIGNED(net_socket_register, 4); -#endif - -#if defined(CONFIG_NET_L2_PPP) - Z_LINK_ITERABLE_ALIGNED(ppp_protocol_handler, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_fixed_chan, 4); - -#if defined(CONFIG_BT_BREDR) - Z_LINK_ITERABLE_ALIGNED(bt_l2cap_br_fixed_chan, 4); -#endif - -#if defined(CONFIG_BT_CONN) - Z_LINK_ITERABLE_ALIGNED(bt_conn_cb, 4) -#endif - - Z_LINK_ITERABLE_ALIGNED(bt_gatt_service_static, 4); - -#if defined(CONFIG_BT_MESH) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_subnet_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_app_key_cb, 4); - Z_LINK_ITERABLE_ALIGNED(bt_mesh_hb_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_FRIEND) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_friend_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_LOW_POWER) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_lpn_cb, 4); -#endif - -#if defined(CONFIG_BT_MESH_PROXY) - Z_LINK_ITERABLE_ALIGNED(bt_mesh_proxy_cb, 4); -#endif - -#if defined(CONFIG_EC_HOST_CMD) - Z_LINK_ITERABLE_ALIGNED(ec_host_cmd_handler, 4); -#endif - -#if defined(CONFIG_SETTINGS) - Z_LINK_ITERABLE_ALIGNED(settings_handler_static, 4); -#endif - - Z_LINK_ITERABLE_ALIGNED(k_p4wq_initparam, 4); - - Z_LINK_ITERABLE_ALIGNED(shell, 4); - - Z_LINK_ITERABLE_ALIGNED(tracing_backend, 4) - - __esp_shell_root_cmds_start = .; - KEEP(*(SORT(.shell_root_cmd_*))); - __esp_shell_root_cmds_end = .; - . = ALIGN(4); #include @@ -248,6 +188,19 @@ SECTIONS . = ALIGN(4); } GROUP_DATA_LINK_IN(RODATA_REGION, ROMABLE_REGION) + /* Flash segments (rodata and text) should be mapped in virtual address space by providing VMA. + * Executing directly from LMA is not possible. */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN(vregion, lregion) > RODATA_REGION AT > lregion + #include "linker/common-rom/common-rom-kernel-devices.ld" + #include "linker/common-rom/common-rom-cpp.ld" + #include "linker/common-rom/common-rom-net.ld" + #include "linker/common-rom/common-rom-bt.ld" + #include "linker/common-rom/common-rom-debug.ld" + #include "linker/common-rom/common-rom-misc.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") + /* Send .iram0 code to iram */ .iram0.vectors : ALIGN(4) { @@ -412,22 +365,16 @@ SECTIONS . = ALIGN(4); } GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION) - #pragma push_macro("GROUP_ROM_LINK_IN") - #pragma push_macro("ITERABLE_SECTION_ROM") - #undef GROUP_ROM_LINK_IN - #undef ITERABLE_SECTION_ROM - #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN - #define ITERABLE_SECTION_ROM(x,y) - #include - #pragma pop_macro("GROUP_ROM_LINK_IN") - #pragma pop_macro("ITERABLE_SECTION_ROM") - #include #include #include - __shell_root_cmds_start = __esp_shell_root_cmds_start; - __shell_root_cmds_end = __esp_shell_root_cmds_end; + /* logging sections should be placed in RAM area to avoid flash cache disabled issues */ + #pragma push_macro("GROUP_ROM_LINK_IN") + #undef GROUP_ROM_LINK_IN + #define GROUP_ROM_LINK_IN GROUP_DATA_LINK_IN + #include "linker/common-rom/common-rom-logging.ld" + #pragma pop_macro("GROUP_ROM_LINK_IN") .dummy.dram.data : {