Skip to content

Toolchain installation

Edgar K edited this page Feb 19, 2021 · 17 revisions

Setup environment

In order to use this repository, the user shall install the following resources and utilities.

Install toolchain prerequisities

Some of the requirements for installing and using this software are (for Ubuntu):

  • Update the system (optional step):
sudo apt-get update
sudo apt upgrade
  • Installation git:
sudo apt-get install git
  • Installation libusb:
sudo apt-get install libusb-1.0-0-dev
  • Installation cmake:
sudo apt-get install cmake

Install toolchain

Installation compiler and debbuger

ARM developer

The GNU Embedded Toolchain for ARM is a ready-to-use, open source suite of tools for C, C++ and Assembly programming targeting ARM Cortex-M and Cortex-R family of processors.

The PPA we want in this case is from the GCC ARM Embedded Maintainer’s team.

Linux (Ubuntu 18.04 and older)
sudo add-apt-repository ppa:team-gcc-arm-embedded/ppa
sudo apt-get update
sudo apt-get install gcc-arm-embedded
Linux (Ubuntu 20.04)

The situation is a bit trickier: go to GNU Arm Embedded Toolchain Downloads website and download the latest archive with the toolchain (as of now, gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2).

Create the file integrate_arm_gcc.sh and paste the code below:

#!/bin/bash

if [ "$#" -ne 1 ]; then
    echo "./integrate_gcc_arm.sh PATH_TO_TAR"
    exit 1
fi

FILENAME=$1
NAME=${FILENAME##*/}
NAME=${NAME%-x86_64-linux.tar.bz2}

echo "Unpacking..."
tar xjf $FILENAME -C /usr/share/
FILES=/usr/share/$NAME/bin/*

for binary in $FILES
do
	bin_name=${binary##*/}
	echo "Create symlink to "$bin_name
	ln -s $binary /usr/bin/$bin_name
	if [ $? -ne 0 ]; then
		echo "oops, trying to fix..."
		rm /usr/bin/$bin_name
		ln -s $binary /usr/bin/$bin_name
	fi
done

echo "Done!"

Make the script executable:

chmod +x ./integrate_arm_gcc.sh

Then run the script with sudo passing the path to the tar archive as a script parameter. Here is an example:

sudo ./integrate_arm_gcc.sh ./gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2
Linux (Fedora)
sudo yum install arm-none-eabi-gcc-cs
sudo yum install arm-none-eabi-binutils-cs
sudo yum install arm-none-eabi-newlib
MacOS
brew tap ArmMbed/homebrew-formulae
brew install arm-none-eabi-gcc

If it is installed correctly, calling autocomplete:

arm-none (press tab twice)

should yield the list of installed binaries:

arm-none-eabi-addr2line   arm-none-eabi-gcc-ar      arm-none-eabi-nm
arm-none-eabi-ar          arm-none-eabi-gcc-nm      arm-none-eabi-objcopy
arm-none-eabi-as          arm-none-eabi-gcc-ranlib  arm-none-eabi-objdump
arm-none-eabi-c++         arm-none-eabi-gcov        arm-none-eabi-ranlib
arm-none-eabi-c++filt     arm-none-eabi-gcov-dump   arm-none-eabi-readelf
arm-none-eabi-cpp         arm-none-eabi-gcov-tool   arm-none-eabi-size
arm-none-eabi-elfedit     arm-none-eabi-gdb         arm-none-eabi-strings
arm-none-eabi-g++         arm-none-eabi-gprof       arm-none-eabi-strip
arm-none-eabi-gcc         arm-none-eabi-ld
arm-none-eabi-gcc-7.3.1   arm-none-eabi-ld.bfd

OpenOCD (optional)

OpenOCD is a free on chip debug solution for targets based on ARM. It is a server which opens a GDB remote target port and a Telnet port.

In order to install OpenOCD, the code necesary for instalation could be found in OpenOCD.

The following commands generate and install the program.

 ./configure [options]
 make
 sudo make install

Installation st-link (recommended)

Stlink package is the software for the ST-Link programmer that works with many 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.

Linux (Ubuntu)

Сlone the repository st-link:

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

Every thing can be built from the top of directory:

cd stlink
make
cd build/Release/lib

To install it run the following command with root permission:

sudo make install

For some reason, the supplementary library might not be installed automatically, thus Linux users should move the library manually to the system directory.

sudo cp libstlink.so.1 /usr/lib/

Linux (Fedora)

sudo yum install stlink
MacOS
brew install stlink

Dunzo! Welcome aboard!