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


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.

For more info see GCC Documentation and ARM infocenter.

  • 3
    \$\begingroup\$ This is very likely to be true, but please explain what each of them means and why they are important. \$\endgroup\$ – AngryEE Apr 23 '12 at 13:23

Check that you're using the right assembler to create startup_stm32f2xx.o. To find out what architecture you assembled for, type:

file startup_stm32f2xx.o

You should see something like ARM-elf little endian. If you don't, then you should fix your makefile/build script.

  • \$\begingroup\$ 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. \$\endgroup\$ – Randomblue Apr 25 '12 at 14:32

I was facing the same problem when I switched from Em::Blocks to IDE-less-GCC-based-development. Strangely it seems that ST Microelectronics is supplying startup files which are compatible to the toolchains of the biggest IDEs, however, they don't provide one which works with GAS (the GCC-assembler).

I could help myself with just using the startup file which was included with Em::Blocks.

Here is my post on Stack Overflow.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.