Why program switches from thumb to ARM

Note: This was originally posted on 24th November 2011 at http://forums.arm.com

Hi Everyone

I've got beginner question (hope this is right place to do it, if not please direct me). I 've prepared whole environment for my STM32F103VCT6 Cortex-M3 processor using Sourcery G++ Lite, Eclipse and Segger GBD Server. I have problem with debugging, for simplest possible program it is available and working, but for more "complicated" like new function it stops. My compilation flags are:

C_FLAGS := -c -ggdb -mcpu=cortex-m3 -mthumb

my script linker:


MEMORY
{
   FLASH : ORIGIN = 0x08000000, LENGTH = 256K
   RAM  : ORIGIN = 0x20000000, LENGTH = 48K
}

SECTIONS
{
   .text :
   {
      KEEP(*(.interrupt_vector))
      *(.text)
   } > FLASH
   
   .data :
   {
      _data_begin_ = .;
      *(.data)
      _data_end_ = .;
   } > FLASH
   
   .bss :
   {
      _bss_begin_ = .;
      *(.bss)
      _bss_end_ = .;
   } > RAM
   
   _stack_size_ = 1024;
   _stack_end_ = ORIGIN(RAM) + LENGTH(RAM);
   _stack_begin_ = _stack_end_ - _stack_size_;
   
   ._stack :
   {
      . = . + _stack_size_;
   } > RAM
}

ENTRY(handler_reset)


my startup code:

extern unsigned long _stack_end_;

typedef void (*interrupt_routine)( void );
void handler_reset( void );
void handler_default( void );

// vector interrupt table
__attribute__ ( ( section( ".interrupt_vector" ) ) )
interrupt_routine routines[] =
{
(void*) &_stack_end_,
handler_reset,
handler_default,
// ... itd...
};


void handler_reset( void )
{
main();
}

void handler_default( void )
{
while ( 1 )
{
}
}


and my program (working):

int main( void )
{
int  a = 3;
int  b = 2;
int  c = 3 + 2;

a = c;

while( 1 )
{
  // infinite loop
}

return 0;
}


and my program (no working, added aa() function):

void aa()
{
}

int main( void )
{
int  a = 3;
int  b = 2;
int  c = 3 + 2;

a = c;
aa();

while( 1 )
{
  // infinite loop
}

return 0;
}


I've got message from Segger debugger:

Setting breakpoint @ address 0x08000034, Size = 2, BPHandle = 0x0023
Starting target CPU... WARNING: T-bit of XPSR is 0 but should be 1. Changed to 1. ...Target halted (PC = 0xF04FAF00)
Reading all registers
Removing breakpoint @ address 0x08000034, Size = 2


Does it mean that my program switches from thumb to arm? If so, why it is done?
Parents
  • Note: This was originally posted on 26th November 2011 at http://forums.arm.com

    Please dump the elf file using arm-none-eabi-objdum -d elf_file.elf > dump.txt

    Take additional attention to the main function when it call the a() function, the "bl" instruction or "blx" instruction used.   If the "blx", that is too bad.
Reply
  • Note: This was originally posted on 26th November 2011 at http://forums.arm.com

    Please dump the elf file using arm-none-eabi-objdum -d elf_file.elf > dump.txt

    Take additional attention to the main function when it call the a() function, the "bl" instruction or "blx" instruction used.   If the "blx", that is too bad.
Children
No data
More questions in this forum