Skip to main content
Associate III
February 2, 2020
Question

Variables in domain D2 are not initialized ... here's why

  • February 2, 2020
  • 2 replies
  • 1383 views

By default, the variables in the D2 domain (SRAM1, SRAM2 and SRAM3) are not initialized by the linker because DATA_IN_D2_SRAM is not defined in the file system_stm32h7xx.c.

DATA_IN_D2_SRAM is used by SystemInit () which is called by the STM32H7xx_Startup.s file.

It would be preferable for DATA_IN_D2_SRAM to be defined by default, which would avoid looking long hours for the reasons why variables initialized in RAM1..3 are not ... don't you think so?

Best regards

Jean-Louis

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
February 2, 2020

SystemInit() is typically called pre-initialization

The GNU/GCC startup.s usually do a very poor job of initializing memory, you need to do a lot of manual work on the linker script and startup code to manage this.

Some of the professional embedded tool-chains manage this a lot better.

Make sure also that CLOCKs for assorted SRAM's are enabled, otherwise you'll get Hard Faults.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
JVERN.18Author
Associate III
February 3, 2020

Hello

Thanks for the links. As usual, you don't know what to look for until you find it.

Currently, I am testing with the Segger / Rowley IDE and I use the Segger linker so as not to have to manage the archaism of the GNU linker. I am using STM32CubeMX.

In this configuration, the only thing necessary for the initialization of the variables in the domain D2 is that DATA_IN_D2_SRAM is defined in the file system_stm32h7xx.c generated by STM32CubeMX.

/************************* Miscellaneous Configuration ************************/
/*!< Uncomment the following line if you need to use initialized data in D2 domain SRAM (AHB SRAM) */
/* #define DATA_IN_D2_SRAM */
 
/*!< Uncomment the following line if you need to relocate your vector Table in
 Internal SRAM. */
/* #define VECT_TAB_SRAM */
#define VECT_TAB_OFFSET 0x00000000UL /*!< Vector Table base offset field.
 This value must be a multiple of 0x200. */
/******************************************************************************/

This can be done specifically by uncommenting line 3 (81 in the code), or better by adding the define DATA_IN_D2_SRAM in the compilation options.

The only things I don't understand is why it's not (better) documented and why ST favors consumption over functionality.

As much as one expects to have to put devices on standby to reduce consumption, but one does not expect that the memory is in power off at initialization (while it is power on in the main()).

Best regards

Jean-Louis