cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX System Clock, FMC related GPIO initialization and FMC settings order issue

Rajeev Arora
Senior

Hello @Khouloud ZEMMELI​ .

I raised two concerns on STM32CubeH7 github page

https://github.com/STMicroelectronics/STM32CubeH7/issues/133

https://github.com/STMicroelectronics/STM32CubeH7/issues/134

I am informed to share my concerns here, as parts of the code in use are generated by STM32CubeMX​

​I​ it possible to update the tool so that my concerns are resolved.

I​ am unwell and hence might take some time to respond back to any raised queries.

Please bear with me.

Thanks,

Rajeev​

9 REPLIES 9
Khouloud ZEMMELI
ST Employee

Hello @Rajeev Arora​ 

Thanks for your post,

Could you please share more details about your problem?

I'll take care of it, do not worry :)

Khouloud

Rajeev Arora
Senior

Hello @Khouloud ZEMMELI​ ,

It is easy to access the STM32H753BIT6 internal SRAM and peripherals.

In the internal SRAM, one can easily create a global variable and simultaneously assign a value to it. Similarly one can easily declare a section of internal SRAM as UNINIT / NOINIT. However, this is not easy for an EXTERNAL SRAM that is configured using the FMC.

Also when an external SRAM is configured using the STM32CubeMX tool, the tool does not add section / address range associated with the External SRAM to the SCT file (which is used by Keil compiler).

Further, in order to allow the __main (library code part) to store zero to every byte of external SRAM (like it does to internal RAM and SRAM), the System Clock configuration, FMC / External SRAM associated pins configuration and FMC settings must be executed before executing __main.

As the __main is responsible for setting up stack and heap, hence when configuring clock, FMC pins, FMC settings etc. one cannot use code pieces that use variables.

Hence tweak to the startup related file, SCT file, Project settings etc are needed. These tweaks need to be made available through STM32CubeMX.

I hope my concern is clear to you.

Thanks,

Rajeev

Hello Rajeev

Since inside "startup_stm32h753xx.s" Reset_Handler is defined as WEAK, you can define a new startup sequence with HAL like the picture below that initializes external SDRAM .

0693W00000AMFahQAH.jpg 

Rajeev Arora
Senior

Hello @Khouloud ZEMMELI​  , @Vangelis Fortounas​  ,

Is it possible for STM32CubeMX development team to provide:

1. A FMC Init code / driver (preferably LL DRIVER) which does not use variables.

2. If above is not possible then mark the FMC Init function as WEAK

3. Always update the SCT file with start address and size of EXTERNAL SRAM (connected over FMC)

Thanks,

Rajeev ​

Rajeev Arora
Senior

Hello @Rajeev Arora​ 

​ 

in startup_stm32h753xx.s line 239 Reset_Handler is weak so the programmer has the freedom to define his own Reset_Handler. (like the picture above)

Rajeev Arora
Senior

Hello @Khouloud ZEMMELI​ , @Vangelis Fortounas​ 

I've coded few functions which do not use any local or global variable (except for various Microcontroller registers)

I believe these function calls and the Reset_Handler will help declare a global variable in External SRAM which can be assigned a value during declaration itself.

Regards,

Rajeev

Rajeev Arora
Senior

Hello,

Attaching updated FMC-SRAM.C file.

Regards,

Rajeev

Rajeev Arora
Senior

#define dExternamUninitializedMRAM_Segment      __attribute__( ( section( ".bss.EXT_NO_INIT_RW_SRAM_SECTION" ) ) )

#define dExternamZeroInitializedMRAM_Segment      __attribute__( ( section( ".EXT_ZERO_INIT_RW_SRAM_SECTION" ) ) )

uint8_t au8ExternalMRAM_ZeroInitializedReadAndWriteBuffer[dExternalMRAM_TestBufferSize] dExternamZeroInitializedMRAM_Segment = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };

uint8_t au8ExternalMRAM_UninitializedReadAndWriteBuffer[dExternalMRAM_TestBufferSize] dExternamUninitializedMRAM_Segment;

SCT file attached with extension changed to TXT