Codesourcery startup and link file for STM32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-09-02 12:48 PM
Codesourcery startup and link file for STM32
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
Don't know which linker script files or device you are using, but you need to make very sure that the RAM, FLASH and STACK are correctly described for the device you are using. If you say the RAM is 20K and the stack is at 0x20005000 you're going to get a fault on a 16K RAM STM32.
Check the .MAP files also to see where the code/data/stack end upUp vote any posts that you find helpful, it shows what's working..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
Thanks for your answer clive1.
I'm using an STM32F102R8. Here is my linker script : [quote] /** * <b>File:</b> stm32_flash.ld * * <b>Project:</b> FreeRTOS.org STM32 demo using Eclipse * * <b>Description:</b> Linker script to load the application in the STM32 internal flash. * It works with the startup_stm32f10x.c startup file. * * <b>Cereated:</b> 24/06/2008 * * <dl> * <dt><b>Autor</b>:</dt> * <dd>Stefano Oliveri</dd> * <dt><b>E-mail:</b></dt> * <dd>software@stf12.net</dd> * </dl> */ MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 128K SRAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K } SECTIONS { .text : { KEEP(*(.isr_vector)) *(.text .text.* .gnu.linkonce.t.*) *(.rodata .rodata.* .gnu.linkonce.r.*) *(.eh_frame_hdr) *(.eh_frame) *(.ARM.extab* .gnu.linkonce.armextab.*) *(.gcc_except_table) *(.eh_frame_hdr) *(.eh_frame) . = ALIGN(4); KEEP(*(.init)) . = ALIGN(4); __preinit_array_start = .; KEEP (*(.preinit_array)) __preinit_array_end = .; . = ALIGN(4); __init_array_start = .; KEEP (*(SORT(.init_array.*))) KEEP (*(.init_array)) __init_array_end = .; . = ALIGN(0x4); KEEP (*crtbegin.o(.ctors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .ctors)) KEEP (*(SORT(.ctors.*))) KEEP (*crtend.o(.ctors)) . = ALIGN(4); KEEP(*(.fini)) . = ALIGN(4); __fini_array_start = .; KEEP (*(.fini_array)) KEEP (*(SORT(.fini_array.*))) __fini_array_end = .; KEEP (*crtbegin.o(.dtors)) KEEP (*(EXCLUDE_FILE (*crtend.o) .dtors)) KEEP (*(SORT(.dtors.*))) KEEP (*crtend.o(.dtors)) . = ALIGN(8); _etext = .; } >FLASH /* .ARM.exidx is sorted, so has to go in its own output section. */ __exidx_start = .; .ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) } >FLASH __exidx_end = .; _flash_data = .; .data : AT (_flash_data) { _data = .; *(vtable) *(.data*) _edata = .; } > SRAM .bss : { _bss = .; *(.bss*) *(COMMON) _ebss = .; _end = .; __end = .; } > SRAM } /* end of allocated ram _end */ PROVIDE( _heap = _end ); /* end of the heap -> align 8 byte */ PROVIDE ( _eheap = ALIGN(ORIGIN(SRAM) + LENGTH(SRAM) - 8 ,8) ); [/quote] But I can't see any definition of the stack address ..- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
That looks like a C++ linker script.
Just do what I did. Grab one from the STM32 Standard Peripheral library. The ones from TrueStudio looks all like C++ ones (those that do the call to __libc_init_array, etc). The RIDE one seems to be only for a XL density device, but it is all that is needed for a C app. Just modify the memory section to match yours, and it should be good.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
And what about the startup code ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
The startup files are in the CMSIS library under the DeviceSupport directory.
The linker scripts work with those files.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
Yes, but none of these startup files are dedicated to codesourcery's toolchain.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
I would try startup from gcc_ride7 afterall codesourcery its gcc or great startup files from crossworks (if its legal).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
I have no problem using them with CodeSourcery.
It's the only decent GCC toolchain I found in fact and the only one I use. Edit: I did have to change 1 thing to make it compile via Eclipse. Change the file extension of the startup assembler file to uppercase (from 's' to 'S'), but that is an Eclipse issue of course :)- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2011-05-17 5:05 AM
How about you do what clive1 said and fix the linker script so RAM and FLASH sizes match?
