2017-08-03 01:36 AM
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:
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:
) 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.Solved! Go to Solution.
2017-10-16 03:25 AM
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
2017-10-16 10:46 AM
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.
2018-01-14 10:00 AM
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.