Skip to content

Commit 650ea4f

Browse files
committed
arch: common: Make nocache region loadable
The `nocache` is not loadable, thus data stored therein cannot be initialized by the startup code. This might be needed in special cases. E.g. One might have a buffer which one wants to DMA into, and which is a member of a struct. Other members of the struct one may want to have initialized by the startup code. The buffer thus should be placed in the `nocache` region, but for the other members of the buffer to be initialized by the startup code, the `nocache` region needs to be loadable. Fix it by making the `nocache` region loadable. Adding a KConfig symbol to do this optionally was considered, but deemed unnecessary during the PR. Signed-off-by: Julian Achatzi <[email protected]>
1 parent 9b79584 commit 650ea4f

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

arch/common/nocache.ld

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/* Copied from linker.ld */
99

1010
/* Non-cached region of RAM */
11-
SECTION_DATA_PROLOGUE(_NOCACHE_SECTION_NAME,(NOLOAD),)
11+
SECTION_DATA_PROLOGUE(_NOCACHE_SECTION_NAME,,)
1212
{
1313
#if defined(CONFIG_MMU)
1414
MMU_ALIGN;
@@ -27,5 +27,6 @@ SECTION_DATA_PROLOGUE(_NOCACHE_SECTION_NAME,(NOLOAD),)
2727
MPU_ALIGN(_nocache_ram_size);
2828
#endif
2929
_nocache_ram_end = .;
30-
} GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION)
30+
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)
3131
_nocache_ram_size = _nocache_ram_end - _nocache_ram_start;
32+
_nocache_load_start = LOADADDR(_NOCACHE_SECTION_NAME);

include/zephyr/linker/linker-defs.h

+1
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ extern char __sg_size[];
225225
extern char _nocache_ram_start[];
226226
extern char _nocache_ram_end[];
227227
extern char _nocache_ram_size[];
228+
extern char _nocache_load_start[];
228229
#endif /* CONFIG_NOCACHE_MEMORY */
229230

230231
/* Memory owned by the kernel. Start and end will be aligned for memory

kernel/xip.c

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ void z_data_copy(void)
3131
z_early_memcpy(&__ramfunc_region_start, &__ramfunc_load_start,
3232
__ramfunc_end - __ramfunc_region_start);
3333
#endif /* CONFIG_ARCH_HAS_RAMFUNC_SUPPORT */
34+
#ifdef CONFIG_ARCH_HAS_NOCACHE_MEMORY_SUPPORT
35+
#if CONFIG_NOCACHE_MEMORY
36+
z_early_memcpy(&_nocache_ram_start, &_nocache_load_start,
37+
(uintptr_t) &_nocache_ram_size);
38+
#endif /* CONFIG_NOCACHE_MEMORY */
39+
#endif /* CONFIG_ARCH_HAS_NOCACHE_MEMORY_SUPPORT */
3440
#if DT_NODE_HAS_STATUS_OKAY(DT_CHOSEN(zephyr_ccm))
3541
z_early_memcpy(&__ccm_data_start, &__ccm_data_load_start,
3642
__ccm_data_end - __ccm_data_start);

0 commit comments

Comments
 (0)