Skip to content

Commit c823e52

Browse files
author
Nikolay Agishev
committed
boards: qemu_arc: fix of MPU regions setup for !XIP config
Add some changes to ARC linker script. They make correct alignment for ROMable region. Now regions borders are aligned with respect to MPU settings. Signed-off-by: Nikolay Agishev <[email protected]>
1 parent 53ab862 commit c823e52

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

boards/arc/qemu_arc/arc_mpu_regions.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,35 @@ static struct arc_mpu_region mpu_regions[] = {
2323
#endif /* CONFIG_COVERAGE_GCOV && CONFIG_USERSPACE */
2424

2525
#if DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) > 0
26+
27+
/*
28+
* In case if Zephyr is configured with CONFIG_XIP=n it linked into
29+
* SRAM. So RAM region should have EXECUTE permission.
30+
*/
31+
#ifdef CONFIG_XIP
2632
/* Region RAM */
2733
MPU_REGION_ENTRY("RAM",
2834
DT_REG_ADDR(DT_CHOSEN(zephyr_sram)),
2935
DT_REG_SIZE(DT_CHOSEN(zephyr_sram)),
3036
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
37+
#else
38+
/* Region RAM */
39+
MPU_REGION_ENTRY("RAM_RX",
40+
(uintptr_t)__rom_region_start,
41+
(uintptr_t)__rom_region_size,
42+
REGION_ROM_ATTR),
43+
44+
MPU_REGION_ENTRY("RAM_RW",
45+
#ifdef CONFIG_USERSPACE
46+
(uintptr_t)_app_smem_start,
47+
#else
48+
(uintptr_t)__kernel_ram_start,
3149
#endif
50+
(uintptr_t)__kernel_ram_size,
51+
REGION_RAM_ATTR),
52+
#endif /* CONFIG_XIP */
53+
54+
#endif /* zephyr_sram > 0 */
3255

3356
#if DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) > 0
3457
/* Region DCCM */

include/zephyr/arch/arc/v2/linker.ld

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ SECTIONS {
9393

9494
#include <zephyr/linker/common-rom.ld>
9595
#include <zephyr/linker/thread-local-storage.ld>
96+
#ifdef __MWDT_LINKER_CMD__
97+
/* TODO: add mwdt specific ROM C++ sections */
98+
#else
99+
#include <zephyr/linker/cplusplus-rom.ld>
100+
#endif /* __MWDT_LINKER_CMD__ */
96101

97102
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,) {
98103
*(".rodata")
@@ -103,7 +108,6 @@ SECTIONS {
103108
* zephyr_linker_sources() Cmake function.
104109
*/
105110
#include <snippets-rodata.ld>
106-
107111
#include <zephyr/linker/kobject-rom.ld>
108112

109113
#if defined(CONFIG_CPLUSPLUS) && !defined(CONFIG_CPP_STATIC_INIT_GNU) && defined(__MWDT_LINKER_CMD__)
@@ -112,16 +116,13 @@ SECTIONS {
112116
KEEP(*(.ctors*))
113117
_ectors = .;
114118
#endif /* CONFIG_CPLUSPLUS && !CONFIG_CPP_STATIC_INIT_GNU && __MWDT_LINKER_CMD__ */
115-
} GROUP_LINK_IN(ROMABLE_REGION)
116119

117-
#ifdef __MWDT_LINKER_CMD__
118-
/* TODO: add mwdt specific ROM C++ sections */
119-
#else
120-
#include <zephyr/linker/cplusplus-rom.ld>
121-
#endif /* __MWDT_LINKER_CMD__ */
120+
MPU_ALIGN(ABSOLUTE(.) - __rom_region_start);
121+
} GROUP_LINK_IN(ROMABLE_REGION)
122122

123123
__rodata_region_end = .;
124-
MPU_ALIGN(__rodata_region_end - __rom_region_start);
124+
125+
MPU_ALIGN(__rodata_region_end - __rom_region_start);
125126
__rom_region_end = .;
126127
__rom_region_size = __rom_region_end - __rom_region_start;
127128

0 commit comments

Comments
 (0)