Página 1 de 1

GNU ARM Cross-toolchain - STM32F4-Discovery

MensagemEnviado: 30 Dez 2013 17:00
por uCTato
Pessoal,

Estou escrevendo uma série de artigos no Embarcados sobre como usar ferramentas GNU em projetos que façam uso de microcontroladores ARM Cortex-M. Em específico, estamos usando a placa STM32F4-Discovery. Muitos outros estão a caminho.

http://www.embarcados.com.br/gnu-arm-cr ... -e-openocd
http://www.embarcados.com.br/gnu-arm-cr ... ack-e-heap

Sugestões são muito bem-vindas!!

Espero que gostem! Abraços

Re: GNU ARM Cross-toolchain - STM32F4-Discovery

MensagemEnviado: 19 Mar 2014 21:45
por Jozias del Rios
eu uso as seguintes linhas de comando (Cortex-M3) para assemblar, linkar, gerar listing, dumping e programar (STLINK V2):

Aquivo mk.bat:
Código: Selecionar todos
IF EXIST %1.bin DEL %1.bin
IF EXIST %1.elf DEL %1.elf
IF EXIST %1.lst DEL %1.lst
IF EXIST %1.o DEL %1.o

arm-none-eabi-as -aglms=%1.lst -EL -mthumb -mcpu=cortex-m3 -mimplicit-it=always -I lib --defsym VERSION=M3 -o %1.o %1.s
IF EXIST %1.o arm-none-eabi-ld -t -static -T linker.ld -Map=%1.map -o %1.elf %1.o
IF EXIST %1.elf arm-none-eabi-objcopy -O binary %1.elf %1.bin
IF EXIST %1.elf arm-none-eabi-nm -n %1.elf > %1.dump
IF EXIST %1.elf arm-none-eabi-objdump -s -d -S -t %1.elf >> %1.dump
IF EXIST %1.bin cli -c SWD UR -HardRst -P "%1.bin" 0x08000000 -V -Run


Arquivo linker.ld:
Código: Selecionar todos
/* Entry Point */
ENTRY(reset.handler)
 
/* Specify the memory areas */
MEMORY
{
   FLASH   (rx)         :   ORIGIN = 0x08000000, LENGTH   =   64K
   RAM      (rwx)         :   ORIGIN = 0x20000000, LENGTH   =   20K
}
 
/* define stack   */
_stack_size   =   1024;
_stack_top = ORIGIN(RAM) + LENGTH(RAM);
_stack_end = _stack_top;
_stack_start = _stack_end - _stack_size;

heap_size   =   256;
 
/* Define   output sections   */
SECTIONS
{
   /* The startup code   goes first into   FLASH   */
   .isr_vector   :
   {
      .   =   ALIGN(4);
      KEEP(   *(.isr_vector) )
      .   =   ALIGN(4);
   }   >FLASH
 
   /* The program code   and   other   data goes   into FLASH */
   .text   :
   {
      .   =   ALIGN(4);
      *(.text)                /*   .text   sections (code)   */
      *(.text*)                /*   .text* sections   (code) */
      *(.rodata)             /*   .rodata   sections (constants, strings,   etc.)   */
      *(.rodata*)             /*   .rodata* sections   (constants,   strings, etc.) */
      .   =   ALIGN(4);
      _text_end   =   .;            /* define   a   global symbols at   end   of code   */
   }   >FLASH
 
   /* used   by the startup to   initialize data   */
   _init_data = .;
 
   /* Initialized data   sections goes   into RAM,   load LMA copy   after   code */
   .data   :   AT ( _init_data   )
   {
      .   =   ALIGN(4);
      _data_start   =   .;    /*   create a global   symbol at   data start */
      *(.data)                /*   .data   sections */
      *(.data*)                /*   .data* sections   */
      .   =   ALIGN(4);
      _data_end   =   .;       /*   define a global   symbol at   data end */
   }   >RAM
 
    _data_size = _data_end - _data_start;
 
   /* Uninitialized data   section   */
   .   =   ALIGN(4);
   .bss :
   {
      /*   Used by   the   startup   in order to   initialize the .bss   secion */
      _bss_start = .;               /* define   a   global symbol   at bss start */
      *(.bss)
      *(.bss*)
      *(COMMON)
      .   =   ALIGN(4);
      _bss_end = .;                  /* define   a   global symbol   at bss end */
   }   >RAM
   
   _bss_size = _bss_end - _bss_start;
 
   .   =   ALIGN(4);
   .heap   :
   {
         _heap_start   =   .;
         .   =   .   +   heap_size;
   }   >   RAM
 
   .   =   ALIGN(4);
   .   =   _stack_start;
   .stack :
   {
         .   =   .   +   _stack_size;
   }   >   RAM

   /* Remove   information   from the standard   libraries   */
   /DISCARD/   :
   {
   }

   .ARM.attributes   0   :   {   *(.ARM.attributes) }
}