cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble to locate data section in flash (STM32F207)

TPier
Associate III

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 ?

1 ACCEPTED SOLUTION

Accepted Solutions
TPier
Associate III

OK. Found the reason : as soon as optimization is enabled, data placement does not work. Did not find which one yet.

View solution in original post

5 REPLIES 5
MM..1
Chief II

For what this complicated arangement ? Your firmware loads longest way as exist, overwrite full flash ... Why

TPier
Associate III

Could you tell me more ?

TPier
Associate III

OK. Found the reason : as soon as optimization is enabled, data placement does not work. Did not find which one yet.

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.