2016-07-14 07:49 AM
Hi,
I use a STM32F205RG6 chip and splitted the flash into 2 parts, 512K for the program and 512K for user's data:MEMORY
{
FLASH (rx) : ORIGIN = 0x8000000, LENGTH = 512K
DATA (rwx) : ORIGIN = 0x8080000, LENGTH = 512K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
}
#in SECTIONS
.user_data :
{
. = ALIGN(4);
*(.user_data)
. = ALIGN(4);
} > DATA
It works like a charm and I can use the .user_data part in my code without worrying about messing the other part.
The only issue that I have is that when I start the application (in debug or normal mode) via ST-link /v2 (through the IDE System workbench here but it shouldn't make any difference), The full flash is always erased.
I modified the openocd flashing script for stm32f2 family (stm32f2x.cfg) to specify a flash bank size of 512K
#flash bank $_FLASHNAME stm32f2x 0 0 0 0 $_TARGETNAME
flash bank $_FLASHNAME stm32f2x 0 0x80000 0 0 $_TARGETNAME
but than, the flashing algorithm complain about a checksum mismatch (indeed the second half still has my data, as I want)
Does someone know how to cope with such a situation, is there something to do to completely ignore the DATA part when flashing or should I just create a helper method to reload/reconfigure the second part of the flash everytime I start/debug the application via the ST-link?
Thanks and regards,
Zoyhar.
#flash-stm32-st-link-openocd
2016-07-14 08:19 AM
Most commercial tools have a check box to do an sector/block level erase as required, Keil certainly does, using the ST-LINK, and others.
2016-07-14 01:20 PM
NOLOAD.
Search linker manual for this.2016-07-15 12:04 AM
Thanks dembek, it was exactly what I was looking for and even with no need to hack the flashing scripts :)
So for the ones who reach this post with the same needs, adding a NOLAD in the section that you want to keep untouched, will force the linker not to initialize that section and therefore keep it as is.user_data (NOLOAD) :
{
. = ALIGN(4);
KEEP (*(.user_data))
. = ALIGN(4);
} > DATA
Thanks again dembek and thanks as well Clive1, I was thinking to get in touch with AC6 to know if such a functionnality exist in system workbench but whenever possible, I prefer to know how it works underneath.
Many thanks,
Zoyhar.
2016-07-15 12:24 AM
This is GCC linker feature. Becose AC6 is based on GCC, everything will work exacly this same.