cancel
Showing results for 
Search instead for 
Did you mean: 

does dual-bank read-while-write work properly in stm32l071?

Maciej Suchinski
Associate II
Posted on August 03, 2017 at 10:36

I'm trying to reprogram the NVM (flash bank 2) while running code from flash bank 1 in STM32L071CB microcontroller.

As AN4808 and AN4767 stand, 'the memory interface is capable of reading both banks in parallel, or reading one bank while writing to the other...' but I'm experiencing some problems:

  1. Debugging shows that FWWERR bit goes high in the flash status register during flash bank 2 half-page write operation. It means that writting flash bank 2 has been stopped because of code fetching.
  2. Erasing bank 2 by code in bank 1 works properly.
  3. Writting by words bank 2 by code in bank 1 seems to work properly (but I'm having doubts if its only coincidence).
  4. Half-page writting ends with FWWERR bit set in FLASH_SR and zeros in the memory I'm trying to write.

I know I'm missing something but I can't find out what it is. Maybe someone had similar problem? I'm starting to think that there's something is wrong with the uC (errata sheet points out some problems with dual-bank switching mechanism, but it shouldn't be a problem in my case, because I'm not switching banks right now).

My function works properly when executed from RAM memory, but I'd rather want it to run from flash bank 1.

(you can take a look at the code here:

https://electronics.stackexchange.com/questions/321863/does-dual-bank-read-while-write-work-properly-in-stm32l071

)

SYSCLK is 16 MHz, checked on MCO with oscilloscope. PWR is in range 1 (the highest applicable).

Thanks for any help.

#flash-read-and-write #stm32l071 #dual-bank #firmware-update

Note: this post was migrated and contained many threaded conversations, some content may be missing.
12 REPLIES 12
Posted on October 16, 2017 at 10:25

Hi Adrian,

your issue is similar to the one described in

https://community.st.com/0D50X00009XkgOoSAJ

. Basically, when using GCC (System Workbench),

__RAM_FUNC

is defined as

__attribute__((section('.RamFunc')))

. This

.RamFunc

section needs to be placed in the

.data

block in your linker script:

/* Initialized data sections goes into RAM, load LMA copy after code */

.data :

{

.

=

ALIGN(4);

_sdata

=

.;

/*

create

a

global

symbol

at

data

start

*/

*(.data)

/*

.data

sections

*/

*(.data*)

/*

.data*

sections

*/

*(.RamFunc)

/*

.RamFunc

sections

*/

.

=

ALIGN(4);

_edata

=

.;

/*

define

a

global

symbol

at

data

end

*/

}

>RAM AT> FLASH

I've checked on my side using NUCLEO-L073RZ and it works fine. It should be ok as well for STM32L

Regards

Bruno

In order 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.
Posted on October 16, 2017 at 17:46

Thanks for the quick response, Bruno. The linker command is what I needed to get that code executing properly out of flash. It's all working correctly now. I suspect that that linker script could be useful for other users like me who have never had to modify a linker script before.

Posted on January 14, 2018 at 18:00

A million thanks - this one had me!!! I thought the problem was in HAL STM32L0XX_HAL_FLASH_RAMFUNC.C

This code just did not look correct to me...

while(count < 16U)

{

/* Address2 doesn't need to be increased */

*(__IO uint32_t*) Address2 = *pBuffer2;

pBuffer2++;

count ++;

}

it looked as though the Address SHOULD BE INCREMENTED to point to the word - even though the comment said other wise. I have no idea why this works (without increment), but either way it is working. Very thankful for your reply.