STM32 CubeIDE - How to set values in DTCM to non zero values using the Linker Script and Startup file.
Hi
I have a variable:
/* Parameters (default storage) */
struct P_GovTrimControl_T_
{
real32_T FreqSP;
real32_T kD;
real32_T kI;
real32_T kN;
real32_T kP;
};
typedef struct P_GovTrimControl_T_ P_GovTrimControl_T;
#define USE_DTCM __attribute__((section (".DTCM_MISC")))
P_GovTrimControl_T __attribute__((__aligned__(4))) USE_DTCM GovTrimControl_P =
{
50.0F,
2.0F,
20.0F,
2.0F,
30.0F
};
The linker script memory allocation:
/* Memories definition */
MEMORY
{
DTCM_STACK (xrw) : ORIGIN = 0x20000000, LENGTH = _Min_Heap_Size + _Min_Stack_Size
DTCM_MISC (xrw) : ORIGIN = 0x20002000, LENGTH = 120K
ITCMRAM (xrw) : ORIGIN = 0x00000000, LENGTH = 64K
RAM_D1 (xrw) : ORIGIN = 0x24000000, LENGTH = 512K
RAM_D2 (xrw) : ORIGIN = 0x30000000, LENGTH = 288K
RAM_D3 (xrw) : ORIGIN = 0x38000000, LENGTH = 64K
...
}
If I use the default allocation of the variable to SRAM1, the values get set to the values assigned in the code as the default linker script and startup do the heavy lifting. If I set the allocation to the DTCM_RAM they do not get set by the startup assembler code and assume random values.
How do I set up the linker script and the startup code to set these values.
I know I could set them in my C Code on start up after "main" but I have a lot of these as filter coefficients and would like to make this process all happen in the startup. Maintenance of the code without this will be a nightmare.
I don't get how I can map the flash addresses of the variable I want in tha DTCM with the DTCM addresses and then pass these to the startup with an appropriate "fill" loop.
I have read the GCC linker docs, but have been unable to get anything to work.
Has anyone done this or know how to do it?
Kind Regards
Rob
