2012-11-22 06:16 PM
Hi all,
Bit of a strange one... When i include this line in one of my C source files, my software no longer starts up after reset correctly (jumps off into no-mans land).const
unsigned
char
settings[0x4800] __attribute__((__section__(
''.settings''
), used));
With this line commented out, everything works just fine.
Anyone know why this would be the case?
Relevantsections of the linker scripts:
MEMORY
{
/* main program ram (48Kb) */
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0xC000
/* startup boot jump (20 bytes) */
MINI_BOOT (rx) : ORIGIN = 0x8000000, LENGTH = 0x14
/* manufacturing data (2028 bytes) */
MANUF_DATA (rw) : ORIGIN = 0x8000014, LENGTH = 0x2048 - 0x16
/* settings data storage (18Kb) */
SETTINGS (rw) : ORIGIN = 0x8000800, LENGTH = 0x4800
/* user data storage (2Kb) */
USER_DATA (rw) : ORIGIN = 0x8005000, LENGTH = 0x800
/* extra boot loader code (22Kb) */
BOOT_LOADER (rx) : ORIGIN = 0x8005800, LENGTH = 0x5800
/* main program flash (216Kb) */
FLASH (rwx) : ORIGIN = 0x800B000, LENGTH = 0x35000
/* end at 0x8040000 */
}
SECTIONS
{
/* FLASH **************************/
.settings :
{
. = ALIGN(4);
KEEP(*(.settings))
. = ALIGN(4);
} > SETTINGS
.user_data :
{
. = ALIGN(4);
KEEP(*(.user_data))
. = ALIGN(4);
} > USER_DATA
.isr_vector :
{
. = ALIGN(4);
KEEP(*(.isr_vector))
/* Startup code */
. = ALIGN(4);
} > FLASH
.text :
{
. = ALIGN(4);
*(.text)
/* remaining code */
*(.text.*)
/* remaining code */
*(.rodata)
/* read-only data (constants) */
*(.rodata.*)
*(.glue_7)
*(.glue_7t)
*(.vfp11_veneer)
*(.gcc_except_table)
. = ALIGN(4);
/* These are for static initializers, constructors, and destructors */
KEEP(*(.init))
KEEP(*(.fini))
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT(.init_array.*)))
KEEP (*(.init_array))
PROVIDE_HIDDEN (__init_array_end = .);
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(.fini_array))
KEEP (*(SORT(.fini_array.*)))
PROVIDE_HIDDEN (__fini_array_end = .);
} > FLASH
.ARM.extab :
{
*(.ARM.extab* .gnu.linkonce.armextab.*)
} > FLASH
.ARM.exidx :
{
__exidx_start = .;
*(.ARM.exidx* .gnu.linkonce.armexidx.*)
__exidx_end = .;
} > FLASH
. = ALIGN(4);
_etext = .;
_sidata = _etext;
........................
Thanks in advance!
2012-11-22 07:25 PM
Take a look at the .MAP file to see where things are placed, and how that differs in working vs non-working scenarios. Look at the listings to see what the code flow looks like.
2012-11-23 03:02 AM
Ok, ive found the issue.
Im writing the .bin to the device rather than the .elf.With the problem line included, the .settings region is included in the .bin which throws off the .text location.Ill have to do it another way...2013-02-27 12:09 PM
I'm having the same problem but since this is my first STM32 project, I can't seem to come to a solution. But here's the core problem, if I don't use the _attibute_ then things run fine but I can only save data to a flash location once. So I was thinking the _attibute_ command would allow me to write multiple times. Maybe they are two unrelated things?
Basically I need to save runtime data to flash to be retrieved after power cycle. I've tried all sorts of things and just can't get it.2013-02-27 12:49 PM
You can't architect a flash writing solution in your application with the linker.
You need to erase memory before it can be written too a second time. If you want to write more things to the same page you need to advance the pointer beyond the data already committed. You need to look at the FLASH_xxx functions and review the PM (Programming Manual) for the part you are utilizing.2013-02-27 12:53 PM
Thanks will do some reading. I was wondering about the linker script because it seemed I could write once when using the default script. But some reading I did pointed me that way. With the STM8, you can just write and rewrite as much as you want so that was getting me.
2013-02-27 01:08 PM
Heh. Just erasing the page before writing again was all there was too it! Jeesh!