stm32f4 discovery and mac osx 10.9 Mavericks


i have updated this post over here: updated guide. So please use the new tutorial.


after couple hours of research  i couldn’t find any tutorial that is up to date and describes how to use the stm32f4 discovery development board with the latest operating system for the Mac ( OS X 10.9 Mavericks). So i will try to summaries my experience with this board . The stm32f4 board is a very cheap development board holding and 32-bit ARM Cortex-M4F core with 1 MB Flash, 192 KB RAM in an LQFP100 package. More information about this board can be found on the vendors website Before we can start to use this board we need to download and install some utilities on the Mac. Lets start with the basics.

Xcode Command Line Tools

First of all, make sure you have installed Apples free Xcode command line tools installed or the full Xcode IDE. If it is not installed yet or you don’t know, check this resource about how to

install the command line tools. Install some dependencies i recommend to install homebrew as little (actually big) helper. homebrew is package manager for OS X similar to macports or fink.  You can also use macports to  download the dependencies by your own. if you have homebrew installed just open your preferred Terminal application and run the command: $ brew install libusb autogen automake wget pkg-config

stlink utility

The stlink utility  tool is used for programming and debugging different micro-controllers. First download/clone the source code from github. Therefor we create a new directory.

$ mkdir ~/dev/
$ cd ~/dev/

Clone the source from Github into the new created directory. This can take a while, depending on your internet connectivity.

 $ git clone https://github.com/texane/stlink.git 
 $ cd ~/dev/stlink/     

Now we can configure and compile the source code of the stlink utility.

$ ./autogen.sh 
$ ./configure 
$ make  

After this  we also need to compile the flash tool. The compilation should be fast and run without errors. If you got, take a look at the Github project.

$ cd ~/dev/stlink/flash
$ make

which should generate a file called st-flash in the flash directory. Next step is to compile the gdbserver. Therefor switch to the directory

$ cd ~/dev/stlink/gdbserver
$ make

now a new executable file will appear in your directory with the name  st-util

gcc-arm-none-eabi for Mac

Download a pre compilted version GNU Tools for ARM Embedded Processors into the same dev dir. There are versions available for windows, mac and linux.

$ cd ~/dev/
$ wget https://launchpad.net/gcc-arm-embedded/4.7/4.7-2013-q3-update/+download/gcc-arm-none-eabi-4_7-2013q3-20130916-mac.tar.bz2
$ tar xvf gcc-arm-none-eabi-4_7-2013q3-20130916-mac.tar.bz2

dont worry, we will realy need all this tool.

install the IDE

Because i am lazy i will use the GUI debugger front-end of Eclipse. Download Eclipse as C++ development environment from the eclipse

website or directly with $ cd ~/dev/

$ wget http://ftp.osuosl.org/pub/eclipse/technology/epp/downloads/release/kepler/SR1/eclipse-cpp-kepler-SR1-macosx-cocoa-x86_64.tar.gz 
$ tar xvf eclipse-cpp-kepler-SR1-macosx-cocoa-x86_64.tar.gz 
$ ./eclipse/eclipse 

eclipse should start now and we can go on. Choose a workspace location you prefer. In the next step we will install some plugins in Eclipse. These plugins will handle the cross compilation and provides the libs for the stm32f32 and other boards. Like i said: lazy. So go and install new Software:

install new Software

First add the source

http://gnuarmeclipse.sourceforge.net/updates as show in the following two screenshots.

add source

and just select all

add all

The next package is the following one

http://download.eclipse.org/tools/cdt/releases/kepler

add all

and this time just select the “C/C++ GDB Hardware Debugging” package show in the next screenshot. The other packages can be installed as well, but are not necessary in order to debug your code on the device.

add all

create an example create a new c project and choose in

Project Type Executable -> STM32F4xx StdPeriph Lib v1.2 C Project and as Toolchain Cross ARM GCC. Choose a name and click Next this dialog.

add all

Locate the toolchain on your files system and go on, to Finish.

add all

get the debugger running

We still need to integrate the debugger with eclipse. But before we can do this, we have to integrate the ST-link tool as external tool. Make sure that you modify the location of st-util. Also notice the Arguments.

add all

Now we can configure a new debugger like in the following pictures.

add all add all

Thats it.

You can now compile and debug your project. If you are not able to compile the project, close and open eclipse and try again. Befor you can debug you have to start the external tool.

add all then start the debugger and you are ready to go. If you have any questions, please ask and comment. And please notice that in the screenshots i havn’t been conseqently in naming. The project is sometimes testing or tester.

5 Comments

  1. Yunus

    Hey,

    first i want to thank you for this explanation. It is really difficult to find help for setting up an IDE on Mac OS.

    I have a problem when i want to “debug” the test project I get the error: “Error while launching command: gdb –version”

    Typing the command to terminal window produces same error. I’ve deleted the stink folder and repeated the chapter in your tutorial but nothing changes.

    Do you may have an idea where the problem could be?

    1. admin

      as it seems to me your gdb is not in your path where your System expects the binary.
      So could it be, that you point to a wrong location your harddrive?
      Check the first picture in the section “integrate the debugger”.

  2. Przemyslaw Gumienny

    Could you be more clear on the setting up the eclipse part? I did everything as you told me to do, and a lot of things are different in Eclipse, starting with that while creating a new project I don’t have an option to create v1.2c project, only STM32F4xx C/C++ Project. And then the differences just pile up, resulting in me not being able to complete the tutorial. Thanks 🙂

    1. admin

      Hy,

      thanks for your feedback. They updated the toolchain and i would like to update this blogpost. But therefor i have to organize a new board, since i don’t have one right now. This could take a while. I will update this blogpost, but i don’t know when.

Leave a Reply

Your email address will not be published. Required fields are marked *