Basic steps :
Install stlink, so that linux recognizes the STM32 card over USB
Install OpenOCD, which provides a ‘virtual JTAG’ debugging environment
Redherring : CodeSourcery
Install ARM gnu tools ‘gcc-arm-embedded’
Download the STM32-F3 supplier code (includes the demo .hex file, for instance)
Get the STM32-F3-Discovery template
Make the template’s simple blinking LED demo work
Reflash the initial demo using stlink
Off to do our own projects…
Have a look at
the stlink github site. It’s confirmed to work (by me) :
git clone git://github.com/texane/stlink.git
## Tells us to install libusb1
su -c "yum install libusb1-devel"
su -c "make install"
su -c "cp 49-stlinkv2.rules /etc/udev/rules.d/"
#either reboot or execute
su -c "udevadm control --reload-rules"
# Not plugged in, the following gives no output :
ls -l /dev/stlink *
# When plugged in, gives following output :
# "lrwxrwxrwx. 1 root root 15 Mar 17 04:06 /dev/stlinkv2_1 -> bus/usb/003/004"
# All done setting up stlink
cd .. Install OpenOCD
Have a look at the
SourceForge site for the OpenOCD project. Then install it :
git clone git://openocd.git.sourceforge.net/gitroot/openocd/openocd
su -c "yum install libtool texinfo"
# Wait a while for sub-projects to git clone themselves
./configure --prefix =/usr --enable-maintainer-mode --enable-stlink
su -c "make install"
# All done setting up openocd
NB : the following should show the config file we’re interested in using :
ls -l /usr/share/openocd/scripts/board/stm32f3discovery.cfg
CodeSourcery (A bit of a red herring)
CodeSourcery seems to be the toolchain that’s easiest to set up. However, the email sign-up thing is a bit grating, and at the end of the day, I decided to ditch their binaries, and go for the something closer to the metal. The following looks like it would work…
## Sign up for CodeSourcery LITE
## Actually, this is probably a red herring : Let's go for more genuine OSS
## Finished with CodeSourcery
the ARM gcc-arm-embedded site to download the Linux installation tarball on the RHS :
mv ~/Downloads/gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar.bz2 .
tar -xf gcc-arm-none-eabi-4_7-2012q4-20121208-linux.tar
Add the binaries into your PATH (NB: this apparently needs to be an absolute path, and yours will differ):
## : /home/andrewsm/sketchpad/teensized/STM32-F3-Discovery/gcc-arm-none-eabi-4_7-2012q4
PATH = "/home/andrewsm/sketchpad/teensized/STM32-F3-Discovery/gcc-arm-none-eabi-4_7-2012q4/bin: $PATH " `
Finish up :
# All done setting up(!) the arm-none-eabi toolchain
cd .. STM dev kit download (for examples)
the STM download site, and download the zip file :
mv ~/Downloads/stm32f3discovery_fw.zip .
# Sample code in ./Projects
# Original demo code in :
rm stm32f3discovery_fw.zip Get the STM32-F3-Discovery template
Oh, I didn’t yet mention that a lot of the magic is done here. But just getting to this stage was pretty involved, so I thought I’d write it all out long-hand.
Anyway, without further ado, here’s the magic sauce (not created by me) :
git clone git://github.com/mblythe86/stm32f3-discovery-basic-template.git
# make the sample project
# Check that the .elf contains something reasonable...
arm-none-eabi-objdump -d main.elf
## Change the makefile to enable OpenOCD to find our board
# Recompile and Upload to the board
# Done with ensuring that STM32 project template works
cd .. Reflash the initial demo… using stlink
The .hex file for the original demo code for the STM32F3 is in :
Let’s reflash that back onto the board to prove that nothing irreversible has happened :
-f /home/andrewsm/sketchpad/teensized/STM32-F3-Discovery/openocd/tcl/board/stm32f3discovery.cfg \
-f ./stm32f3-discovery-basic-template/extra/stm32f3-openocd.cfg \
-c "reset halt" \
-c "flash write_image erase ./STM32F3-Discovery_FW_V1.1.0/Project/Demonstration/Binary/STM32F3_Discovery_Demo_V1.1.0.hex" \
-c "shutdown" Now let’s move fowards with our own sample project
cp -R stm32f3-discovery-basic-template project-test