Electronic – Move embedded programming from Keil to Linux

gcckeillinuxstm32

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?

Best Answer

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.

all:
    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
  • -D STM32L1XX_MD -D USE_STDPERIPH_DRIVER
    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