====== Using the STM32F* ====== **NOTICE**: If you are using a computer of the Laboratory you can skip directly to the Step for installing Libopencm3. If you are using a personal computer, and are using Debian Buster or newer, then execute: sudo apt install gcc-arm-none-eabi libftdi1 openocd libusb-1.0-0-dev stlink-tools ===== 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 ===== Old Debian version ===== ** WARNING **: Only follow this tutorial if you are using Jessie or older versions. === Arm Toolchain === **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: - 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 * For a complete list of official architectures go to: http://www.debian.org/ports/ * We need to add i386 arch using the follwing command: 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. - Get the dependencies: sudo apt-get install libncurses5:i386 - 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 - 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 - Remember to reload your .bashrc file, there are two ways: * Close your session and login again. * Reloading your .bashrc file directly: . .bashrc === Stlink === **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|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