2021-11-30 07:31 AM
Hi,
I attempt to locate information about the firmware in flash. To do so, the data are stored in a dedicated section (called CONTROL_UNIT_SECTION):
/** @brief Definition of the firmware info. */
typedef struct firmware_info_t {
uint8_t id; /**< Identifier of the control unit. */
uint8_t major; /**< Major version number. */
uint8_t minor; /**< Minor version number. */
uint8_t rc; /**< Release candidate number, 0 if production release. */
} FirmwareInfo;
/* Declare the sections in flash that stores the core configuration. */
#pragma section = "CONTROL_UNIT_SECTION"
#pragma location = "CONTROL_UNIT_SECTION"
static const FirmwareInfo firmware_info = {
CONTROL_UNIT_ID,
FIRMWARE_VERSION_MAJOR, FIRMWARE_VERSION_MINOR,
DEVELOPMENT_VERSION
};
This section is then located in ROM, using the following statements in the linker file :
define symbol _CU_INFO_REGION_START_ = 0x0803FFF0;
define symbol _CU_INFO_REGION_END_ = 0x0803FFFB;
define region CU_INFO_region = mem:[from _CU_INFO_REGION_START_ to _CU_INFO_REGION_END_ ];
place in CU_INFO_region { readonly section CONTROL_UNIT_SECTION };
This is used in 2 different projects with the same target (STM32F207VC) and with the same linker file. In one of the projects, the data are not available at the expected location. In the map file, I can find this :
No sections matched the following patterns:
ro section CONTROL_UNIT_SECTION in "P2"
Did I proceed in a wrong way ? What could be the reason of such different behaviors between the projects ?
Solved! Go to Solution.
2021-12-01 02:17 AM
OK. Found the reason : as soon as optimization is enabled, data placement does not work. Did not find which one yet.
2021-11-30 07:50 AM
For what this complicated arangement ? Your firmware loads longest way as exist, overwrite full flash ... Why
2021-11-30 11:28 PM
Could you tell me more ?
2021-12-01 02:17 AM
OK. Found the reason : as soon as optimization is enabled, data placement does not work. Did not find which one yet.
2021-12-01 07:22 AM
2021-12-01 08:20 AM
Thanks for this answer.
I already tried to the "keep" directive (in the IAR environment). No success. No error as well, but everything happens as if the section already disappeared at the linking time.
I have the feeling (and it is only a feeling ;) ) that optimization at compile time removes the data that are expected for the section.