Updated: Using The stm32f4 discovery board with Mac OSX 10.9 Mavericks

My first posting about the stm32f4 discovery board and Mac OSX 10.9 Mavericks became a little bit outdated. That is because the used software has been updated since then. The following sotware is used in this tutorial: But wait with the download. We will do the installation step by step together.

  1. Mac OSX Mavericks (10.9.3)
  2. Xcode Command Line Tools (
  3. homebrew, package manager for OSX (0.9.5)
  4. Eclipse Kepler for C/C++ Developer (4.3.2)
  5. ST-Link (Commit ID 4782ab0ca736202e31d1afcbc62ce469a5daedf7)
  6. gcc-arm-none-eabi GCC arm crosscompiler Toolchain for Mac (4.8-2014-q1-update)

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 this is not the case please check this website.


Install Brew and Dependencies

i recommend to install homebrew which is a package manager that will help us to install some dependencies. Homebrew is package manager for OS X similar to macports or fink. You could also use macports to  download the dependencies by your own.
After you have installed your favorite package manager open your preferred Terminal application and run the command:

$ brew install libusb autogen automake wget pkg-config

Stlink Utility

Now we are ready to downlaod and install the stlink utility. It 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  

a couple of binaries are generated where the most interesting for use is

  • st-util

varify that everything worked fine. Connect the STM32 Board to your Mac and in the stlink directory fire the command

$ ./st-util
2014-06-01T18:20:05 INFO src/stlink-common.c: Loading device parameters....
2014-06-01T18:20:05 INFO src/stlink-common.c: Device connected is: F4 device, id 0x10016413
2014-06-01T18:20:05 INFO src/stlink-common.c: SRAM size: 0x30000 bytes (192 KiB), Flash: 0x100000 bytes (1024 KiB) in pages of 16384 bytes
Chip ID is 00000413, Core ID is  2ba01477.
Target voltage is 2878 mV.
Listening at *:4242...

If you get a different output you should check if the board is recognized by your Mac.

Crosscompiler for Mac: gcc-arm-none-eabi

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

$ cd ~/dev/
$ wget https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2
$ tar xvf gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2

dont worry, we will realy need all this tools.

Install and setting up the Eclipse IDE

I will use the GUI debugger front-end given by Eclipse. Download Eclipse as C++ development environment from the eclipse.org website or do it directly from within the command line

$ 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 Kepler will start and we can create a new Workspace. Choose a workspace location you prefer. Since i put everything in my ~/dev/ folder it looks like this:

install new Software

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.

install new Software

First add the source to your Eclipse. It will install templates for some boards, as well for the stm32f discovery. Add the link http://gnuarmeclipse.sourceforge.net/updates as show in the following two screenshots.

add source

and just select all

add source

The next package is the following one


add source

and this time just select the two packages 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 source

create an new blinking LED project.

Go to the menu of eclipse and create a new C-Project. Find the folder Executable and choose the “STM32F4XX C/C++ Project”.

add source

leave the rest of the setting allown except the last settings page where you point to your compiler.

add source

add source

add source

add source

A new project is created that will show errors. Just ignore them and compile the project as shown below. The errors will disappear.

add source

Integrate ST-Util

In the next step we will configure Eclipse to run st-util as external programm.

add source

  1. go to the external run configuration menu
  2. create a new external run configuration
  3. point to the location of the st-util in my case (/Users/markus/dev/stlink/st-util)
  4. that the working directory to the variable ${project_loc}
  5. leave the arguments empty.
  6. done

add source

Lets Debug.

We still need to integrate the debugger with eclipse. Go to the debug configuration menu

add source

in the debugger tab, choose the location ~/dev/gcc-arm-none-eabi/bin/arm-none-eabi-gdb

add source

and configure the JTAG device as generic TCP/IP running on localhost and port 4242. This is the already configured st-link util. That musst be started befor you think about debuging. Now hit debug and you are ready.

The setup is now a little bit like this.

add source

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.


The STM32F4xx discovery board is a cheap microcontroller that offers a lot of GPIO and is powerful enough to emulate a SEGA Master System. It can be set up with free and open source software. There are extensions boards available that brings Wifi, Ethernet and even touch screens to this board. The STM32F4 Discovery board is a great and cheap micro-controller that makes it easy to step into the world of embedded devices.


  1. Joel

    Thank you for a great guide!
    But, i have followed your guide, and when i am to build i get this error:
    Description Resource Path Location Type
    make: *** No rule to make target `system/src/stm32f4-hal/stm32f4xx_hal.o’, needed by `tester.elf’. Stop. tester C/C++ Problem

    Have you seen this or do you know what could be wrong?

    Kindest regards

    1. admin

      Do you have any more information about what does not work?

      first: make sure you installed homebrew correctly
      $brew doctor

      second: make sure you installed autogen correctly.
      $ brew install libusb autogen automake wget pkg-config

    2. Filippo Appignani

      Hi Naeem,
      I have the same problem and I have resolved installing “autoconf” with macport:

      sudo port install autoconf

      After that you need to install “automake” with macport:

      sudo port install automake

      That’s it! I hope this help you.

  2. Axel

    cool tutorial so far 🙂

    If i want to debug the sample blinky code following error Popup thows up:

    Error in final launch sequence
    Failed to execute MI command:
    -file-exec-and-symbols /Volumes/Daten/ST32/projects/test_001/Debug/test_001.elf
    Error message from debugger back end:
    “/Volumes/Daten/ST32/projects/test_001/Debug/test_001.elf”: not in executable format: File format not recognized
    “/Volumes/Daten/ST32/projects/test_001/Debug/test_001.elf”: not in executable format: File format not recognized

    can you help me pls?

  3. alpha

    your tutorial is very great. I have successfully installed all module. But it cannot work in debug mode. It shows
    “Error with command: ~/dev/gcc-arm-none-eabi/bin/arm-none-eabi-gdb –version
    Cannot run program “~/dev/gcc-arm-none-eabi/bin/arm-none-eabi-gdb”: Unknown reason”
    And I am using STM32F103. This IC is not in the support list?
    Thanks a lot.

    1. admin

      Sorry that i approved your comment so late and sorry that i can’t help you with this. Did you find an answer elsewhere? Would be nice to here about it. I have to admit, that i don’t own an STM controller at the moment.

  4. Al

    thank you very much for this tutorial. Works great.
    Here is a tip to launch st-link and debug session with one click:
    1. On ‘Run Configurations’ create a new ‘Launch Group’.
    2. Then on the right click ‘Add…’, select ‘run’ as launch mode then select ‘Program-> st-util’
    3. click ‘Add…’ again and select ‘debug’ as launch mode then select your GDB debug session.

  5. Matt

    Thanks so much for this tut! I get
    Error with command: gdb –version
    Cannot run program “gdb”: Unknown reason
    When I hit debug.

  6. Gabriel

    Hi !

    I’ve been following your tutorial to get the toolchain up and running and so far it’s been working perfectly !

    I just have a little problem regarding the traces (from diag/Trace.h) and the semihosting in order to get the “printf” working. What are the steps required to get that working or where should I look for the output ?

    Thanks a lot !


  7. Michel

    i can run st-util and arm-none-eabi-gdb from the command line and the both seems to work without problem .

    But i have a situation that give me headache from a few days.It concern the integration of st-util in eclipse with the external run configuration . I can not find the location of the file ( st-util ) in my system (Mac osx el capitan).I try to find it in stlink folder and in others places but without success.

    Please help me

    Thank you

    1. admin

      Hi Michel,

      you can locate the st-util in you terminal by using the command: whereis st-util
      for example
      $ weheris sh
      wil return

      Now you can copy the path and switch to the finder. In the finder open a new file navigator window and push the keys “CMD+SHIFT+G” and paste the path.
      Hope this will help

  8. Gianluca

    Hi! Did you manage to get the stm32f4 working as a Simulink TARGET under Mac OS X? There is the hardware support package under Windows so it should just be a matter of target language compiler, given the fact the the ARM toolchain should be the same… thanks!

  9. favalcatraz

    Hi, when open a project, under the folder Executable I don’t find “STM32F4XX C/C++ Project”. How I can fix it?

Leave a Reply

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