I'm currently using Keil to develop for an STM32 discovery board. My project is close to finished, and I'd like to move to a Linux based building environment. I've been using the preconfigured flashing tool and the STLink drivers for windows to flash the board, and I got keil to export a bin file, which I managed to flash on my Linux machine using qSTLink2. So far, so good.

Now I'm stuck on moving the process of building the entire project. Specifically:

How do I port my .uvproj to a makefile, while taking things like the 'startup_stm32l1xx_md.s' startup file into account?

  • \$\begingroup\$ I haven't used in an STM32 in particular under a Linux GCC build environment, but you'll probably find GCC needs a different startup file. You might be best to find an already working simple project and then add your code to that. \$\endgroup\$
    – PeterJ
    Commented Jan 2, 2014 at 9:22
  • \$\begingroup\$ The hard way, no doubt. \$\endgroup\$ Commented Jan 2, 2014 at 9:24
  • \$\begingroup\$ Could I use the current .o file Keil generated using MDK-ARM, ignore the compilation for that one file for now, and link it in statically? \$\endgroup\$
    – Lg102
    Commented Jan 2, 2014 at 11:22
  • \$\begingroup\$ As PeterJ already wrote. It will use a different startup file with different labels and different semantics. There should be no way to keep the Keil startup_stm32l1xx_md.o file. Don't you have the source startup_stm32l1xx_md.s for it? \$\endgroup\$
    – harper
    Commented Jan 2, 2014 at 15:10
  • \$\begingroup\$ I do, but it seems oriented at MDK-ARM (or so the header claims). I've replaced it with another. I'm not sure what the distinction between medium and high density entails, though. \$\endgroup\$
    – Lg102
    Commented Jan 2, 2014 at 16:22

2 Answers 2


Got it done. I figured I'd share my results so others can use it. Thanks for your time, everyone.

I used this ARM toolchain to build my project, and the texane/stlink library, which comes with the ./st-flash tool, to flash the binary to my STM32L1. While texane/stlink comes with GDB, I found I could get the building+flashing process done without it.

My Makefile ended up looking like this. It isn't very pretty or abstract, but it gets the job done.

    arm-none-eabi-gcc -T stm32l1xx.ld -mthumb -mcpu=cortex-m3 -D STM32L1XX_MD -D USE_STDPERIPH_DRIVER startup_stm32l1xx_md.s system_stm32l1xx.c main.c [ sources ] -lm --specs=nosys.specs -o Project.elf

In which:

  • arm-none-eabi-gcc
    The ARM toolchain
  • -T stm32l1xx.ld
    The linker document
  • -mthumb -mcpu=cortex-m3
    Tell GCC this is for an M3
    Defines for the Standard Peripheral Driver
  • startup_stm32l1xx_md.s
    GCC oriented startup document.
  • system_stm32l1xx.c main.c [ sources ]
    List of my source files
  • -lm
    For Math.h(LibMath)
  • --specs=nosys.specs
    Don't use sytems calls like _exit.
  • -o Project.elf
    Output name
  • 1
    \$\begingroup\$ Where does the stm32l1xx.ld file come from? \$\endgroup\$
    – oxr463
    Commented Jun 28, 2019 at 19:25

There is a Gnu ARM toolchain (arm-none-eabi), and supposedly openOCD works with gdb (although I haven't been able to make that happen under Win7 - openOCD connects to an STM32F4disco board OK, but gdb has problems connecting to openOCD).

Do some digging around here and you will find links to the toolchain, openOCD and sample projects that include startup source.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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