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 (5.1.0.0.1.1396320587)
  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.

http://railsapps.github.io/xcode-command-line-tools.html

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

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

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.

Conclusion

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.