User Tools

Site Tools


Writing /var/lib/dokuwiki/data/meta/tutorials/stm32f4.meta failed
tutorials:stm32f4

This is an old revision of the document!


Arm Toolchain

Debian Jessie or newer

If you have Debian jessie (or newer) you can just install the package.

sudo apt install gcc-arm-none-eabi libftdi1 openocd libusb-1.0-0-dev

Old Debian versions

Warning: Only follow this if you have an old version of Debian.

Before we used the summon-arm-toolchain script to make the crosscompiler tool, but now summon-arm-toolchain is not maintained anymore and now they recommend to use the official toolchain from ARM:

https://launchpad.net/gcc-arm-embedded

Also you must install the following packages:

sudo apt-get install libftdi1 openocd libusb-1.0-0-dev

To install:

  1. Set multiarch in your system.
  • To add an extra architecture (in Debian from dpkg 1.16.2 onwards) the syntaxis is as follows:
    dpkg --add-architecture <arch>
    dpkg --add-architecture i386
  • Your dpkg architectures are stored in /var/lib/dpkg/arch.
  • Now, modify /etc/apt/sources.list. Apt-sources can be architecture qualified with this syntax for each 'source':
    deb [arch=amd64,i386] http://site.example.com/debian distribution
  • Next, do apt-get update always after adding new architectures.
  1. Get the dependencies:
sudo apt-get install libncurses5:i386
  1. Download the latest installation tarball for GNU Tools for ARM Embedded Processors, and uncompress:
cd ~/local/src
wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2014-q4-major/+download/gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
tar -xjf gcc-arm-none-eabi-4_9-2014q4-20141203-linux.tar.bz2
  1. Make the toolchain executables available to the users add the bin directory to your PATH variable:
echo 'export PATH=$PATH:/home/****user****/local/src/gcc-arm-none-eabi-4_9-2014q4/bin/' >> /home/****user****/.bashrc
  1. Remember to reload your .bashrc file, there are two ways:
  • Close your session and login again.
  • Reloading your .bashrc file directly:
. .bashrc

Debian Buster or newer

sudo apt install stlink-tools

Old Debian versions

WARNING: Only follow this if you have older Debian versions.

Project's webpage: https://github.com/texane/stlink

First we need to install the package: libusb-1.0

También se debe seguir el tutorial Using xstow for local installations antes de continuar con la instalación.

Primero ingresamos a la carpeta

cd ~/local/src/

Se descarga con git

git clone https://github.com/texane/stlink

Ingresamos a la carpeta

cd stlink

Configuramos

mkdir build
cd build
ccmake ..

Presione “c”. Seleccione en CMAKE_BUILD_TYPE=debug. Luego en CMAKE_INSTALL_PREFIX=/home/user/local/DIR/stlink Presione “c”, y luego “g” denuevo.

Compilamos, e instalamos

make
make install 
cd 
cd local/DIR
xstow stlink

Ahora necesitamos copiar las siguientes reglas (tenemos que estar ubicados en ~/local/src/stlink/etc/udev/rules.d/),

sudo cp 49-stlinkv1.rules /etc/udev/rules.d/
sudo cp 49-stlinkv2.rules /etc/udev/rules.d/
sudo cp 49-stlinkv2-1.rules /etc/udev/rules.d/
sudo /etc/init.d/udev restart
udevadm control --reload-rules
udevadm trigger --attr-match=subsystem=usb

Libopencm3

http://www.libopencm3.org/

To build the library:

cd ~/local/src/
git clone https://github.com/libopencm3/libopencm3-examples
cd libopencm3-examples
git submodule init
git submodule update
cd libopencm3
make

Be sure to install python-yaml first.

To build an example and flash it to the f4discovery:

cd ../
cd examples/stm32/f4/stm32f4-discovery/miniblink/
make
make flash

New STM versions

New versions use STLINK 2-1. If you have errors, flashing the microcontroller, you should change your OOCD_INTERFACE configuration in the corresponding Makefile or passing as an argument on the flash instruction as seen below:

$ make flash OOCD_INTERFACE=stlink-v2-1
tutorials/stm32f4.1559242008.txt.gz · Last modified: 2022/09/20 00:08 (external edit)