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.

model based workflow with the stm32 discovery board

I was happy to read that ST announced a Matlab package for the STM32-Discovery Board that will allow you to build software with a model based workflow. But as it turned out the package offered by ST is very limited and only offers a Simulink blockset for the ADC, GPIO, TIMERS and UART. But the STM32-Discovery board can do a lot more then this. I was even more happy to see that there exist another package provided by someone else. This package comes with a very handy installer and offers in addition I2C, SPI, FLASH, CRC, CAN and even more blocks for Simulink. And in addition the blocks by waijung are compatible with more Matlab version, compared to the blocks by ST. That block set only works with the Matlab version 2013b and never. Also i have to say that the documentation for the waijung blockset is really great.

Bildschirmfoto 2014-03-25 um 20.58.13

 

http://waijung.aimagin.com/

The combination of that cheap STM32-Discovery board with the free block set from waijung allows a fast and simple start with a model based workflow. Beside the fact that Matlab is very expensive if you are not a student

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.