STM32F4 Discovery starting projects:

Set up the development enviroment : set-up the enviroment with open source tools.

Starting projects : samples for newbies.

 

Set up the development enviroment - using open source tools

In this section I explain how to set up your development enviroment for programming STMF4-Discovery with open source tools.

The first thing to do is select a toolchain for build your exe in a comprensive way for your MCU.

Any toolchain supporting the cortex m3 should do. I prefer the Mentor's toolchain in particular you can choose between arm-non-eabi or arm-none-linux-gnueabi. Details for the installation are provided in the topmost README file.

May be you would to know that you can install it everywhere you want !! and then you must create a enviroment variable to point to correct installation path.

 

After that you installed (and checked) your toolchain you musty install ST-LINK.

STLINK is open source software to program and debug ST’s STM32 Discovery kits. Those kits have an onboard chip that translates USB commands sent by the host PC into JTAG/SWD commands. This chip is called STLINK, (yes, isn’t that confusing? I'm sorry but you can write to ST and suggest a new name ... :)) and comes in 2 versions (STLINK v1 and v2).

Before continuing, the following dependencies must be met:

• libusb-1.0

• pkg-config

• autotools

The STLINK software source code is retrieved using:

$>git clone git://github.com/texane/stlink stlink-git

Everything can be built from the top directory:

$>cd stlink-git

$>./ autogen.sh

$>./configure

$>make

It includes:

• a communication library (stlink.git/libstlink.a),

• a GDB server (stlink.git/st-util),

• a flash manipulation tool (stlink.git/st-flash).

For use the GDB server.

A GDB server must be started to interact with the STM32.

$ ./st-util

or If you prefer you can export another enviroment variable to point to installation directory (I usually do in this way).

for the help you can digit:

$ ./st-util --help

 

Then, GDB can be used to interact with the kit (I suggest you to do this in another command tab or in another terminal screen).

$ arm-none-eabi-gdb

(gdb) target extended-remote localhost:4242

(gdb) monitor halt

(gdb) load /path2yourelffile/main.elf

(gdb) kill

(gdb) quit

The commands sequence is clear.

- The first command connect the server to the board althrought the 4242 port;

- The second stop all modules of the MCU and put it in reset

- The third one kill the debugg session

- The last one quit the gdb server.

At this point, in the terminal in which run st-util, you can run the Ctrl-C shortcut to terminate the application.

If all is gone well the STM32F4 is running your application! If not try to puch the reset press button (the black one).

There are several other commands for debbug the application with gdb ... you are free to check the official documentation...

Sample programs