You will need an ARM bare-metal toolchain to build code for STM32L1 targets.
You can get a toolchain from the
gcc-arm-embedded project that is
pre-built for your platform. Extract the package and add the
bin folder to
You will also need to download and extract the STM32L1 StdPeriphLib, which can be found here.
Writing and Building Firmware
Clone the stm32l1xx-template repository (or fork it and clone your own repository).
git clone firstname.lastname@example.org/uctools:stm32l1-template
Modify the Makefile:
- Set TARGET to the desired name of the output file (eg: TARGET = main)
- Set SOURCES to a list of your sources (eg: SOURCES = main.c startup_gcc.c)
- Set PERIPHLIB_PATH to the full path to where you extracted the STM32L1 peripherial library.
- Set PART_TYPE to the type of your part. This can be md (medium density), mdp (medium density plus), or hd (high density).
The output files will be created in the 'build' folder
You can flash and using your device using stlink. More information is available on the stlink project page.
This template has been tested on the STM32L Discovery development board.