# Error when compiling start-up file on STM32

I am attempting to provide custom interrupt handlers for my Cortex M3 (reference manual here). ST kindly provides a standard library, which has various startup files all called "startup_stm32f2xx.s". Each is in a different folder according to IDE.

Now I do not use an IDE (I compile directly with Yagarto, a modified version of the gcc toolchain). I have already asked which of the start-up to use. However, having now tried all the available startup files, I always get the same error:

/startup_stm32f2xx.s:1:0: error: target CPU does not support ARM mode

A quick Google search reveals that this probably means that the assembler code has instructions that my ARM cannot understand, which is surprising given that the code was provided for my board.

How can I compile the startup file that defines the interrupt vector on my STM32?

Edit: In each of the files, startup_stm32f2xx.s:1:0 is the beginning of a comment. Also, I'm using the flag -mcpu=cortex-m3. Here is the complete error message:

\$ make all
arm-none-eabi-gcc -x assembler-with-cpp -c -g -mcpu=cortex-m3 -gdwarf-2 -Wa,-amhls=startup_stm32f2xx.lst   startup_stm32f2xx.s -o startup_stm32f2xx.o
startup_stm32f2xx.s:1:0: error: target CPU does not support ARM mode
makefile:46: recipe for target startup_stm32f2xx.o' failed
make: *** [startup_stm32f2xx.o] Error 1

-
Ignorant question: is Yagarto compatible with the STM32 toolchain? –  clabacchio Apr 23 '12 at 10:41
What do you mean by STM32 toolchain? There is only an STM32 standard library. –  Randomblue Apr 23 '12 at 10:42
AFAIK microcontrollers come with a toolset to write the binaries on the micro; is the library compatible with your family? –  clabacchio Apr 23 '12 at 10:45
To write the binary files on the microprocessor I use OpenOCD (through JTAG), which has no special relationship to the STM32 in particular. –  Randomblue Apr 23 '12 at 10:51

You may also need -mthumb -mno-thumb-interwork -mfpu=vfp -msoft-float -mfix-cortex-m3-ldrd as compiler options for arm-none-eabi-gcc. For the assembler, use -mcpu=cortex-m3 -mthumb as options.

Edit:

The -mthumb switches gcc and the assembler into "thumb" mode - they will generate arm mode instructions per default, which do not work on Cortex M3.

Since there is no ARM mode, we don't need ARM/Tumb interworking, thus -mno-thumb-interwork.

The compiler needed -mfpu=vfp -msoft-float for floating point support. Cortex M3 has no hardware floating point AFAIK, at least I am not aware of any silicon that has both Cortex M3 and floating point in hardware. There are some Cortex M4 that have.

Most Cortex M3 need -mfix-cortex-m3-ldrd, this is in the errata documentation for the Cortex M3 core versions.

-
This is very likely to be true, but please explain what each of them means and why they are important. –  AngryEE Apr 23 '12 at 13:23
That fixed the problem, thanks! –  Randomblue Apr 25 '12 at 16:31
file startup_stm32f2xx.o

The file startup_stm32f2xx.o doesn't get created; I only have the .s` file. I've added a complete dump of the error message above. –  Randomblue Apr 25 '12 at 14:32