I have an STM32 discovery board and would like to be able to program it on Linux.
What is the easiest way to do this?
An easy way to program and debug the STM32 Discovery board (or any STM32 using an ST-Link programmer) is to use the 'stlink' project https://github.com/texane/stlink (however OpenOCD seems more popular)
There are some good pages on how to develop for STM32 discovery on Linux, such as http://gpio.kaltpost.de/?page_id=131 and http://torrentula.to.funpic.de/2012/03/22/setting-up-the-stm32f4-arm-development-toolchain/ and http://jethomson.wordpress.com/2011/11/17/getting-started-with-the-stm32f4discovery-in-linux/
However I found the last link the most useful. It shows how to build ST's STM32 projects as-is - The only change is to add his Makefile, which seems like a perfect solution.
On newer versions of Ubuntu, there is a package you can install which contains an ARM compiler:
This will install the GCC compiler as 'arm-linux-gnueabi-gcc'
However if you do this you'll need to add the line '*(.note.gnu.build-id)' at the bottom of the '/DISCARD/' section of stm32_flash.ld (the linker script supplied with ST's examples) in order for the Ubuntu-packaged compiler to produce code that can be flashed and that works.
Also bear in mind that I have had no luck using the C/GCC standard libraries (which includes floating point routines). However installing the package is an awful lot easier than building GCC from source.
Note that the processors are all a bit different. STM32F0..4 will all need different compiler flags, and the linker script will be slightly different for each (although only really because of the changed RAM and Flash sizes).
And for help with compiling the STM32 examples in Linux go here. That link points to a makefile for the examples which can be invoked with
A couple minor code fixes are also documented, but most of the project should work with
Libraries was taken from ST website, makefile — from one of many GPL examples in internet.