The IAR Linker Configuration File (ICF) has its own syntax, which is detached from the C Language. Although, it is possible to export linker symbols so that they can used from within the C application. Assuming that all the .icf
files are located in the same directory as the .ewp
project. The easiest way might be this one.
Define your memory map in mmap.icf
using define exported symbol
like this:
define exported symbol __region_FLASH_start__ = 0x08000000;
define exported symbol __region_FLASH_end__ = 0x080FFFFF;
define exported symbol __region_SRAM1_start__ = 0x20000000;
define exported symbol __region_SRAM1_end__ = 0x2001BFFF;
define exported symbol __region_SRAM2_start__ = 0x2001C000;
define exported symbol __region_SRAM2_end__ = 0x2001FFFF;
/* Remaining of the Memory Map... */
Then include mmap.icf
at the top of your $PROJ_DIR$/STM32Fxxxxxx.icf
which is used by the linker's configuration page (equivalent to the --config
option) like this:
include "mmap.icf";
/* Remaining of the top-level ICF... */
From the application, use mmap.h
to bind the linker symbols to the application as extern
als, like this:
#pragma once
extern unsigned int __region_FLASH_start__;
extern unsigned int __region_FLASH_end__;
extern unsigned int __region_SRAM1_start__;
extern unsigned int __region_SRAM1_end__;
extern unsigned int __region_SRAM2_start__;
extern unsigned int __region_SRAM2_end__;
/* Remaining of the external symbols... */
This approach for a custom linker configuration that exports defined symbols (via define exported symbol
) simplifies spanning the same configuration across multiple projects within the same workspace/scope.