mkdir stm

cd stm

mkdir setup

cd setup

wget https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2

tar -xvjf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2

export PATH=$PATH:~/gcc-arm-none-eabi-5_4-2016q3/bin

arm-none-eabi-gcc --version

 

arm-none-eabi-gcc (GNU Tools for ARM Embedded Processors) 4.8.4 20140526 (release) 
[ARM/embedded-4_8-branch revision 211358]
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

 

 

 

sudo apt-get install automake
sudo apt-get install autoconf pkg-config libusb-1.0 git
git clone https://github.com/texane/stlink.git
cd ~/stlink



###################################
git clone https://github.com/rowol/stm32_discovery_arm_gcc

The important part of the project is the Makefile

Edit the Makefile, and set STLINK to point to where you have installed it:

STLINK=/home/rowol/stlink             #Example, change to your location

 

Make STM_COMMON point to where you installed the STM32 Library code:

STM_COMMON=/home/rowol/stm32_discovery_arm_gcc/STM32F4-DISCOVERY_FW_V1.1.0

 

Build the code by running make:

make

 

 
 
make burn

GDB (debugger)

In the directory with your source code, I've also add a .gdbinit file which contains:

define reload
kill
monitor jtag_reset
load
end

target extended localhost:4242
load

This will execute whenever you start GDB in the source directory

 

To start up:

~/stlink/st-util                 #Start GDB server
arm-none-eabi-gdb main.elf       #In a second terminal window, start GDB

continue #Starts code running, or use other GDB commands to # set breakpoints, etc first...
 
    If you need to make changes and recompile the code, you can reload the same application (i.e. .bin file) from within GDB with this sequence:
  • Hit ^C if the code is running, to get to a gdb prompt
  • reload      #Macro we defined in .gdbinit, it does kill/monitor/jtag_reset/load sequence
  • Start new code running again with 'run' or other debugger commands