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.
Contents
Generated on 2016-01-21 with: http://docutils.sourceforge.net/rst.html
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.
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
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/ .
Cortex M4 is ARMv7E-M
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 .
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.
apt-get install gdbserver
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
Add http://gnuarmeclipse.sourceforge.net/updates to available repos for Eclipse, install whatever you need according to boards.
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
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.
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 .