cancel
Showing results for 
Search instead for 
Did you mean: 

system_stm32f4xx.c wrong code (SDRAM banks, GPIO_AFR)

MRobe.1
Associate III

Hi

I find these issues with the system_stm32f4xx.c file which CubeMX "generates":

(a) CubeMX has Bank1, Bank2 enabled.  Code generated is only for Bank1.

(b) CubeMX setting of pins (e.g/ AFR, MODER) does not match CubeMX Pinout.

IOC attached.

It seems that the system_ file may be a generic file (I have seen this around for years with the same flaws) and not generated based on CubeMX settings.  This seems wrong.  Once known the workaround is easy (i.e. write your own for each project, modifying the code as you need).  If not you may (will) get Failure to Launch if your stack / heap is in the SDRAM.

Regards

Mark

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @MRobe.1 ,

As already mentioned in UM1718, the default optimal system settings that is used at startup are defined in the
system_stm32f4xx.c file. This file is copied by STM32CubeMX from the STM32CubeF4 MCU package.

The system_stm32f4xx.c contains System Init() that is called at startup just after reset and before branching to the main program. It allows relocating the vector table in internal SRAM and configuring the FSMC/FMC (when available) to use the external SRAM or SDRAM mounted on the evaluation board as data memory (UM1725).

The FMC configuration generated by STM32CubeMX can be found in main.c and in stm32f4xx_hal_msp.c.

Please make sure before generate the code to enable the generate code for FMC as shown in below figure.

 

KDJEM1_0-1694100375602.png

Thank you for your contribution in STCommunity :).

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Pavel A.
Evangelist III

It seems that the system_ file may be a generic file ... and not generated based on CubeMX settings.  

Correct.

> Once known the workaround is easy (i.e. write your own for each project, modifying the code as you need).

This is what the user is expected to do. Once the user has the code tailored per their needs, they can copy this over instead of the generic one.  

>This seems wrong.

Correct again, but there is reasoning behind this decision, which you may understand later (or not)... Unlikely that they will change this module for the aged F4 series.

 

Errrr.... that comment could be said about every single bit of code generated by CubeMX.  You may as well have said "don't use MX, write your own code".  Which I have been doing.  For some 40 years.  

ST Team: I'm happy to receive your comment as I am pretty sure you want us to use CubeMX.  Pavel: no need to comment on my posts.

KDJEM.1
ST Employee

Hello @MRobe.1 ,

As already mentioned in UM1718, the default optimal system settings that is used at startup are defined in the
system_stm32f4xx.c file. This file is copied by STM32CubeMX from the STM32CubeF4 MCU package.

The system_stm32f4xx.c contains System Init() that is called at startup just after reset and before branching to the main program. It allows relocating the vector table in internal SRAM and configuring the FSMC/FMC (when available) to use the external SRAM or SDRAM mounted on the evaluation board as data memory (UM1725).

The FMC configuration generated by STM32CubeMX can be found in main.c and in stm32f4xx_hal_msp.c.

Please make sure before generate the code to enable the generate code for FMC as shown in below figure.

 

KDJEM1_0-1694100375602.png

Thank you for your contribution in STCommunity :).

Kaouthar

 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.