1   ARM dev tools for Debian (Sid)

Author:Andrea Manni
Copyright:GFDL
Version:0.1

This are just personals notes, it’s not meant to be a proper tutorial for public review.

Generated on 2016-01-21 with: http://docutils.sourceforge.net/rst.html

1.1   Debian arch

Modify sources.list to have::
deb http://ftp.debian.org/debian/ sid main non-free contrib

As often mirrors don’t have Debian armhf port available. You need to pull the ftp archive.

Add the right architecture: for ARM we use:

dpkg --add-architecture armhf
apt-get update
dpkg --print-architecture # That's what your host is using
dpkg --print-foreign-architectures  # That's your target enviroments

Now install the cross compiler, Sid should have a pretty well updated version. You may wanna take a snapshot / backup of the system now:

lvcreate -s -L5g -n sid_bak /dev/main/sid
apt-get install crossbuild-essential-armhf

Warning

The cross compiler is meant to build code for a Linux system, something like a embedded RaspberryPy running Debian and not a Cortex ARM processor for any microcontroller.

1.2   Test the build chain

Take whatever C++ example file:

#include <iostream>                           // a PREPROCESSOR directive
using namespace std;                      // make definitions visible
int main()                                    // function header
{   // start of function body
    cout << "This is ARM code.";  // message
    cout << endl;                             // start a new line
    cout << "You won't regret it!" << endl;   // more output
    return 0;                                 // terminate main()
}                                             // end of function body
And compile it::

arm-linux-gnueabihf-g++ hello.cpp file a.out

a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=0ecbdddcde90341984c81cddc027d9cb127503c9, not stripped

This should work on an OrangePC / RPi:

OrangePI:/tmp:$ dpkg --print-architecture
armhf

We can test on x86 (AMD64) using Qemu, after installing you can execute the binary:

apt-get install qemu-user-static
apt-get install libicu-dev:armhf # We need some libraries to build something

Libraries should go to: /usr/lib/arm-linux-gnueabihf/ .

1.3   Boards

  • MSP432 Launchpad is ARM 32Bit Cortex M4F: that’s supposed to be ARM armel as in: gobjc++-arm-linux-gnueabi
  • Nucleo NUCLEO-L476RG has a CPU STM32L476RG: it should be Cortex M4 ARMv7E-M so we compile fo: armhf: gobjc-arm-linux-gnueabihf . Ultra-low-power with FPU ARM Cortex-M4 MCU 80 MHz with 1 Mbyte Flash: https://developer.mbed.org/platforms/ST-Nucleo-L476RG/
  • OrangePC: armhf , ARMv7 Processor rev 5 (v7l)

Cortex M4 is ARMv7E-M

1.4   Eclipse

Download last version of eclipse CDT: https://eclipse.org/cdt/downloads.php

Create a new project “hello world” like:

* Cross compiler Prefix: arm-linux-gnueabihf-
* CC Path:  /usr/bin

It should compile, Project properties -> Tool Chain -> should say Cross CC .

1.5   Debug su remoto embedded

This procedure is for embedded system ala RPi / OrangePi where you have a complete Gnu/Linux OS for running a GDB server. Files can be uploaded with SSH (maybe with a post build hook in Eclipse).

Install from the main archive “General purpose tools” -> Remote System Explorer User Actions” . With this you can have SSH - FTP connection to a remote host in order to upload object files to debug remotely.

1.5.1   GDB server on target

apt-get install gdbserver

1.5.2   Debug client on host - workstation

Install the multiarch GDB server and tell Eclipse that it’s about ARM:

apt-get install gdb-multiarch

vim ~/workspace/arm/.gdbinit

set architecture arm

1.6   uC ARM plugin per Eclipse

Add http://gnuarmeclipse.sourceforge.net/updates to available repos for Eclipse, install whatever you need according to boards.

::
cd stlink/ apt-get install autoconf ./autogen.sh ./configure apt-get install libusb-1.0-0-dev make sudo make install

1.7   STM32 specific

For a Cortex CPU we can’t use any g++-5-arm- linux -gnueabihf compiler as these are made to copile code to run on an other Gnu/Linux system. We have to install:

apt-get install  gcc-arm-none-eabi

After a compiler we need a set of libraries to have something working, for an overview of the possibilities check:

Summary

  • Mbed: easiest, most abstract less optimized. Can denvelop from browser. Closed system
  • STM32 Cube HAL: abstraction level on hardware, portability, low optimization (but low level APIs available), RTOS
  • STM32 Standard peripherali libraries (SPL): no HAL, less portability, more optimization
  • Bare metal, Assembly and C

I have a NUCLEO-L476RG: 1 MB Flash and a fast CPU: we are going to go full abstract with HAL and RTOS. ST provides CubeMX to initialize the uC and provide the libraries / middleware for the code.

1.8   MXCube Eclipse plugin

There’s a CubeMX plugin for Eclipse: jar:file:/tmp/stsw-stm32095.zip!/ - http://www.st.com/web/en/catalog/tools/PF257931# . Doc for installing is: http://www.st.com/st-web-ui/static/active/cn/resource/technical/document/user_manual/DM00104712.pdf

Fun Facts: it does not work with Linux ‘cause STM are morons.

That can be painfully made to work standalone, it’s a matter of exploding the .jar / .zip into something usable as java -jar STM32CubeMX.exe.

Download something that goes by the name of stm32cubemx.zip from http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF259242?sc=microxplorer

cd /tmp
unzip stm32cubemx.zip
java -jar SetupSTM32CubeMX-4.12.0.exe
cd STM32CubeMX/
java -jar STM32CubeMX.exe

Yet it does not generate a Eclipse Project, most similar thing is a SW4STM32 .