Open a terminal window and type:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
Or in one convenient command that doesn't require any interaction:
sudo apt-get -y update && sudo apt-get -y upgrade && sudo apt-get -y autoremove
Open a terminal window and type:
sudo apt-get install dh-autoreconf libusb-1.0.0-dev
Git is a popular version control system that is very popular, notably due to GitHub. You will need the tool to download the latest version of STLink directly from its repository
Again in the command line:
sudo apt-get install git
Start by adding the PPA to your system:
sudo add-apt-repository ppa:terry.guo/gcc-arm-embedded
You then want to update your sources:
sudo apt-get update
and install the package:
sudo apt-get install gcc-arm-none-eabi
If it installs correctly, doing autocomplete in the terminal like so:
arm-none (press tab twice)
should yield a list similar to:
arm-none-eabi-addr2line arm-none-eabi-gcc-4.7.4 arm-none-eabi-ld.bfd arm-none-eabi-ar arm-none-eabi-gcc-ar arm-none-eabi-nm arm-none-eabi-as arm-none-eabi-gcc-nm arm-none-eabi-objcopy arm-none-eabi-c++ arm-none-eabi-gcc-ranlib arm-none-eabi-objdump arm-none-eabi-c++filt arm-none-eabi-gcov arm-none-eabi-ranlib arm-none-eabi-cpp arm-none-eabi-gdb arm-none-eabi-readelf arm-none-eabi-elfedit arm-none-eabi-gdbtui arm-none-eabi-size arm-none-eabi-g++ arm-none-eabi-gprof arm-none-eabi-strings arm-none-eabi-gcc arm-none-eabi-ld arm-none-eabi-strip
The STLink package is the software for the STLink programmer that works with many boards ST boards. On the discovery boards, the programmer is embedded at the top. YOu just need to make sure you plug in your mini-USB cable into the center-most port that is labeled ST-Link.
Start by cloning the git repository to a local folder:
git clone https://github.com/texane/stlink.git
Go into the directory: cd stlink
and run the following commands (from the repository instructions):
./autogen.sh
./configure
make
You should now have compiled a series of STLink tools. Verify this by listing the contents of the directory that start with st-
ls -la | grep st-
Let's install these to our computer, so that we don't have to keep coming back to this temporary folder where we've built the software
make install
Now you should be able to access these programs from anywhere in the terminal. Verify this by moving to a different directory:
cd .. && st-util
Download Neil's blink example and unzip it somewhere.
Open a terminal and navigate to that folder. Following which, you will compile the blink example:
make
Once, you have compiled the blink example, you should get a blink.elf file that you will want to flash to your board:
sudo make flash
The interface works in two halves: the st-util and the GDB utility. The former hooks into the device and provides an interface for the interactive debugger shell embodied in the latter tool.
Let's start by loading the ST Utility:
sudo st-util
It should have spit out some information and say that it's listening on *:4242
In a new terminal window, you now want to start the debug tool GDB:
arm-none-eabi-gdb
It should drop you to the GDB command line, that starts each input line with: (gdb).
Connect your GDB tool to the ST utility:
tar extended-remote :4242
You should see on the ST utility console that the GDB tool connected. And now we want to load your program:
load blink.elf
You will notice that on your board, the LEDs will be stopped and the program will have stopped executing, often midway through it. This is because the debugger has kicked in and we want to tell it to continue with the execution. In the GDB console type:
continue
If you want to drop back to the GDB shell to set debug points in your code or do other debug functions, just press CTRL+C (^C), the UNIX universal interrupt command.
Congratulations! You have now setup your system to load and debug code for the STM32 board! Please feel free to add to this tutorial in future. In particular if you have figured out installation of the toolchain on Mac OS.