2025-05-07 7:19 AM
I am working with a dual core STM32H755 and attempting to create a shared memory location for the two cores to access. I am attempting to do this by modifying the linker script. I have added the following lines to the M7 core linker script, in the SECTIONS block:
/* Shared Memory section for inter core comms */
.sharedRAMsection 0x30040000 :
{
.= ALIGN(4);
KEEP(*(.sharedRAMsection))
. = ALIGN(4);
} > RAM_D2
Then in one of my .c files, I have declared the following global variable:
RegisterMap_t __attribute__((section(".sharedRAMsection"))) g_RegisterMap;
However, when I debug I can see the address of this variable has been assigned to memory location 0x24000064, as seen in the watch window:
I am using visual studio and visual GDB, and I am debugging with 2 separate VS instances for the two cores.
Is there something else that I need to do in order to get this variable into the correct memory location?
Thanks
Solved! Go to Solution.
2025-05-08 1:48 AM
Found the solution. The problem was my stupidity.
The initial project generation in STM32CubeIDE generates two linker files, one RAM and one Flash, but only one linker file gets used. I have my project set to use the Flash linker script, but I'm modifying the RAM linker script. Both of these can be used to assign both Flash and RAM sections. I guess it gives you both so that you can decide whether to run your program mainly from Flash or from RAM. I'm sticking with the Flash defaults, except that I've added the RAM section as in my original post.
If anyone in future is looking for a concise example of how to share memory in between cores, my original post has the correct code.
2025-05-07 7:38 AM
How is RAM_D2 define in the memory section?
Use the .MAP or objdump to see how the symbol is defined
KEEP(*(.sharedRAMsection))
KEEP(*(.sharedRAMsection*)) /* check if it needs to pull suffix variants ie .sharedRAMsection.data */
2025-05-07 7:53 AM
RAM_D2 is defined as starting at 0x30000000 and having a size of 288K, which I think has it running up to 0x30048000.
/* Memories definition */
MEMORY
{
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 1024K /* Memory is divided. Actual start is 0x8000000 and actual length is 2048K */
DTCMRAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
}
Adding the wildcard to sharedRAMsection has no effect.
2025-05-07 8:27 AM
doesn't the attribute go after the variable name?
hth
KnarfB
2025-05-08 1:21 AM
I think it works either way.
In any event I tried switching it round and nothing changed.
2025-05-08 1:48 AM
Found the solution. The problem was my stupidity.
The initial project generation in STM32CubeIDE generates two linker files, one RAM and one Flash, but only one linker file gets used. I have my project set to use the Flash linker script, but I'm modifying the RAM linker script. Both of these can be used to assign both Flash and RAM sections. I guess it gives you both so that you can decide whether to run your program mainly from Flash or from RAM. I'm sticking with the Flash defaults, except that I've added the RAM section as in my original post.
If anyone in future is looking for a concise example of how to share memory in between cores, my original post has the correct code.