EmbDev.net

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


von jo p. (jrj)


Rate this post
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 :
1
    __attribute__ ((section("vectors"), used))
2
    void (* const gVectors[])(void) =
3
    {
4
       (void (*)(void))((unsigned long) 0x20000A00),
5
       start_SQC,
6
       NMI_Handler,
7
       HardFault_Handler,
8
       MemManage_Handler,
9
       BusFault_Handler,
10
       UsageFault_Handler,
11
       (void (*)(void))((unsigned long) 0),
12
       (void (*)(void))((unsigned long) 0),
13
       (void (*)(void))((unsigned long) 0),
14
       (void (*)(void))((unsigned long) 0),
15
       SVC_Handler,
16
       DebugMon_Handler,
17
       (void (*)(void))((unsigned long) 0),
18
       PendSV_Handler,
19
       SysTick_Handler,
20
       ...

where start_SQC is the beginning of the code :
1
    void start_SQC(void)
2
    {
3
      SystemInit();
4
      SysTick_Config(SystemFrequency / 100);
5
      main();
6
    }

The linker is configured with the memories offsets :
1
    MEMORY
2
    {
3
      ram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
4
      rom (rx) : ORIGIN = 0x00000000, LENGTH = 256K
5
    }
6
    SECTIONS
7
    {
8
      .  = 0x0;         /* From 0x00000000 */
9
      .text : {
10
        *(.vectors)     /* Vector table */
11
        *(.text)        /* Program code */
12
        *(.rodata)      /* Read only data */
13
      } >rom
14
15
      .  = 0x20000000;  /* From 0x20000000 */
16
      .data : {
17
        *(.data)        /* Data memory */
18
      } >ram AT > rom
19
20
      .bss : {
21
        *(.bss)         /* Zero-filled run time allocate data memory */
22
      } >ram AT > rom
23
    }


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 :
1
    00000000 <main>:
2
    int main(void)
3
    {
4
       0:  b580      push  {r7, lr}
5
       2:  af00      add  r7, sp, #0
6
    }
7
8
     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOA, ENABLE);
9
       4:       f04f 0014 mov.w  r0, #20
10
       8:       f04f 0101 mov.w  r1, #1
11
       c:       f000 fc12 bl   834 <RCC_APB2PeriphClockCmd>
12
13
    ...
14
15
    0000212c <SystemInit>:
16
    void SystemInit (void)
17
    {
18
       212c:    b580      push  {r7, lr}
19
       212e:    af00      add  r7, sp, #0
20
21
    ...
22
23
   000027f8 <start_SQC>:
24
   void start_SQC(void)
25
   {
26
      27f8:     b580       push {r7, lr}
27
      27fa:     af00       add  r7, sp, #0
28
   SystemInit();
29
      27fc:     f7ff fc96  bl  212c <SystemInit>
30
   SysTick_Config(SystemFrequency / 100);
31
      2800:     f642 03b0  movw r3, #10416  ; 0x28b0


Does anybody know what I'm doing wrong ?

Thank you
Regards

von Michael F. (mifi)


Rate this post
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

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.