2020-10-05 06:43 AM
Hey,
Is it possible to use preprocessor commands in linker script file (***.ld) and how it can be done if possible. I want to have diffrent memory definitions depending on the macro.
I tried this but it's not working:
/* Memories definition */
MEMORY
{
/* IF BOATLOADER IS ENABLED USE THIS MEMORY CONFIG*/
#ifdef ENABLE_BOOTLOADER
SHARED (xrw) : ORIGIN =0x20000000 , LENGTH = 64K
RAM (xrw) : ORIGIN =0x20000040 , LENGTH = (512K - 64K)
FLASH (rx) : ORIGIN =0x08008000 , LENGTH = (2048K-32K)*/
#else
/* IF BOATLOADER IS DISABLED USE THIS MEMORY CONFIG*/
RAM (xrw) : ORIGIN =0x20000000 , LENGTH = 512K
FLASH (rx) : ORIGIN =0x08000000 , LENGTH = 2048K
#endif
QUADSPI (r) : ORIGIN =0x90000000 , LENGTH = 16M
}
2020-10-05 08:21 AM
Sort of. You need to do the legwork manually.
https://stackoverflow.com/questions/28837199/can-i-use-preprocessor-directives-in-ld-file
2020-10-06 11:11 PM
@TDK thank you for your anwser. I managed to preprocess linker script file in pre-build steps with command:
arm-none-eabi-gcc -E -x c -Iinclude ../STM32F767IITX_FLASH_in.ld | grep -v '^#' > ../STM32F767IITX_FLASH.ld
But there is a problem that global MACROS are not taken into account when preprocessing. Do you have any idea how to do that ?
With global macros i mean Symbols of project in Project->Properties->C/C++ General->Path and Symbols->Symbols