STM32F4 Discovery on Linux

From MakeICT Wiki
Revision as of 19:20, 14 April 2016 by Dominic Canare (talk | contribs) (Created page with "== Interface tools == To interface with the STM32F4 Discovery board, download and install the stlink tools: sudo apt-get install build-essential dh-autoreconf libusb-1.0-0...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Interface tools

To interface with the STM32F4 Discovery board, download and install the stlink tools:

   sudo apt-get install build-essential dh-autoreconf libusb-1.0-0-dev
   git clone https://github.com/texane/stlink
   cd stlink
   ./autogen.sh
   ./configure
   make
   sudo make install

You will need to give permissions for regular (non-root) users to use these tools. This should probably be done with the sudoers file (if you use sudo on your system), but this should work universally:

   sudo chmod u+s $( which st-flash ) $( which st-util )

Building code

To compile code for the STM32F4 Discovery board, you will need these dependencies:

   sudo apt-get install build-essential gcc-arm-none-eabi gdb-arm-none-eabi

Here is a code template:

   git clone https://github.com/MakeICT/stm32f4discovery-template blink
   cd blink
   make
   make flash

Flashing a program

If you're using the code template (from above), use this:

   make flash

To flash manually (if you're not using the template from above):

   sudo st-flash write bin/main.bin 0x8000000

Debugging a program

Run this command in one terminal

   st-util

This connects ST tools to the device. The LED on the board will blink to solid green.

Run this command in another terminal:

   arm-none-eabi-gdb bin/main.elf
       (gdb) target extended localhost:4242
       (gdb) load
       (gdb) continue

After the `target` and `load` commands, the board's LED will blink to slid green. After the `continue` command (while the program is running), it will flash between green and red.