cancel
Showing results for 
Search instead for 
Did you mean: 

flash example can't not run on STM32L4R5QG

fema
Associate III
Posted on March 15, 2018 at 12:10

I have two customer boards as below :

A board : Mount with STM32L4R5QII (2MB internal flash)

B board : Mount with STM32L4R5QGI (1MB internal flash)

A board run well on the STM32L4R5ZI-Nucleo\examples\flash many times.

B board will stop a error (program error) as attached file.

If i do a chip erase before run the example on B board it will work on first time.

So i guess the program can't erase the sector correctly .

Any comment , Thanks 

#flash-example-can't-not-run-on-stm32l4r5qg
3 REPLIES 3
fema
Associate III
Posted on March 15, 2018 at 13:33

I found the problem is because the bank size different .

The bank size of STM32L4R5QII is the 0x00100000 but the bank size of the 

STM32L4R5QGI is the 0x0080000.

It cause the Flase_Erase did not erase the enough sectors for program .

I assume the example will work on all STM32L4R5xx series but it did not .

What is the correct bank size of the 

STM32L4R5QGI ??

Thanks .

Posted on March 15, 2018 at 13:56

I'd presume you'd need to pass the specific part as a define

But more generally you'd look to read the Flash Size parameter programmed in the system space, and look at the option settings or flash configurations settings and make a run time determination about what mode/state the banking is running in.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on March 16, 2018 at 03:38

The FLASH_BANK_SIZE return from file stm32l4xx_hal_flash.h is

0x0080000 (512KB) on the 

STM32L4R5QGI .

If i want to erase 1 sector at address 0x08080000 so i call the HAL_FLASHEx_Erase() with below parameters :

Banks=2 , Page = 0 , NbPages = 1 

But it did not erase this sector.

I need to pass the below parameters :

Banks= 1 , Page = 128 , 

NbPages = 1 

I need to set the Banks to 1 even the address over the 512KB .

Any comment !