EmbDev.net

Forum: ARM programming with GCC/GNU tools Problem with reset vector (Yagarto + STM32F107)


Author: jo plu (jrj)
Posted on:

Rate this post
0 useful
not useful
Hi,

I'm trying to understand how to use the yagarto tools (yagarto + eclipse 
+ openocd + TinyUSB) with a Olimex's STM32F107 board.
So far, using Olimex and yagarto examples, I have been able to compile 
the code.
But the reset vector doesn't point to the correct part of the code.

I have defined the vectors :
    __attribute__ ((section("vectors"), used))
    void (* const gVectors[])(void) =
    {
       (void (*)(void))((unsigned long) 0x20000A00),
       start_SQC,
       NMI_Handler,
       HardFault_Handler,
       MemManage_Handler,
       BusFault_Handler,
       UsageFault_Handler,
       (void (*)(void))((unsigned long) 0),
       (void (*)(void))((unsigned long) 0),
       (void (*)(void))((unsigned long) 0),
       (void (*)(void))((unsigned long) 0),
       SVC_Handler,
       DebugMon_Handler,
       (void (*)(void))((unsigned long) 0),
       PendSV_Handler,
       SysTick_Handler,
       ...

where start_SQC is the beginning of the code :
    void start_SQC(void)
    {
      SystemInit();
      SysTick_Config(SystemFrequency / 100);
      main();
    }

The linker is configured with the memories offsets :
    MEMORY
    {
      ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
      rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
    }
    SECTIONS
    {
      .  = 0x0;         /* From 0x00000000 */
      .text : {
        *(.vectors)     /* Vector table */
        *(.text)        /* Program code */
        *(.rodata)      /* Read only data */
      } >rom

      .  = 0x20000000;  /* From 0x20000000 */
      .data : {
        *(.data)        /* Data memory */
      } >ram AT > rom

      .bss : {
        *(.bss)         /* Zero-filled run time allocate data memory */
      } >ram AT > rom
    }


The problem is that the dump of the binary shows that the reset vector 
points to the main() and not to the start_SQC(), so SystemInit() is not 
executed before the user code :
    00000000 <main>:
    int main(void)
    {
       0:  b580      push  {r7, lr}
       2:  af00      add  r7, sp, #0
    }

     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA, ENABLE);
       4:       f04f 0014 mov.w  r0, #20
       8:       f04f 0101 mov.w  r1, #1
       c:       f000 fc12 bl   834 <RCC_APB2PeriphClockCmd>

    ...

    0000212c <SystemInit>:
    void SystemInit (void)
    {
       212c:    b580      push  {r7, lr}
       212e:    af00      add  r7, sp, #0

    ...

   000027f8 <start_SQC>:
   void start_SQC(void)
   {
      27f8:     b580       push {r7, lr}
      27fa:     af00       add  r7, sp, #0
   SystemInit();
      27fc:     f7ff fc96  bl  212c <SystemInit>
   SysTick_Config(SystemFrequency / 100);
      2800:     f642 03b0  movw r3, #10416  ; 0x28b0


Does anybody know what I'm doing wrong ?

Thank you
Regards

Author: Michael Fischer (mifi)
Posted on:

Rate this post
0 useful
not useful
Hello,

take a look at the STM32 examples here:
http://www.yagarto.de/examples/index.html

Perhaps this will help you.

Regards,
mifi

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.