Page Personnelle de Vincent Kerhoas
Vincent Kerhoas
Enseignant du Supérieur
Professeur Agrégé
Page Personnelle de Vincent Kerhoas

Raspberry PI Cross Development Environment

Equipment :


Talking with the target

In following examples, static address for PC is 192.168.0.1.
It can be modified with $ sudo ifconfig [Eth_name] 192.168.0.1

Connection

NOTE : ssh must be activated on RPI

Graphical mode :

Copies

Copy PC –> RPI

Copy de fichiers PC <–> RPI

filezilla:

Host : 192.168.0.2
Username : rpi
Password :
Port : 22

ssh/scp without password

RPI (via ssh)

PC

Eduroam wifi Configuration


Compiling on Target

Considering the following helloworld.cpp file :

helloworld.cpp

let’s copy it on the target :

RPI side (via SSH)

The RPI compiler is of course ARM type :

We compile, we execute :


Cross Compilation

Now let’s see how to create the RPI program on the PC.

Interest:

An evidence : The PC has a compilation toolchain for Pentium.

ARM 64 ( aarch 64 ) linux Compiler

Installation

the easiest way :

NOTE : alternatively you can download and build yourself your own compiler, or download a pre built version at linaro.org or developer.arm.com ( be aware of compiling issues due to compiler versions ).

helloworld

PC Side

RPI Side (via SSH)

So this is exactly the same for a simple hello world.

Makefile version :


hello_world


with libraries ( ex : opencv )

It gets complicated ; let’s consider the opencv library.
The executable creation must be done with RPI opencv libs ( not the PC ones).

RPI Side

opencv installation

PC Side: RPI File system with sshfs

A solution could be copying RPI libs on the PC in order to create a minimal file system. This supposes dealing with dependances and update links to get relative paths.
An other solution, more elegant, is mounting the RPI file system through ssh thanks to sshfs.

Installation

Utilisation

This is the RPI file system ; it is mounted in PC rpi_mnt directory

Compilation


WORKSPACE_TSI_OPENCV_CROSS


let’s have à look to the Makefile:

Notes :

let’s go:

Test on Target

NOTE :

The same project for a native compiling :


test_opencv_local



Debug with gdbserver

Ok we compiled, but how to debug our program ( other than with printf) ?

Installations

RPI side

PC side

with tdb

you can get it in installations.html ( 1. IDE Eclipse / Tdb )

RPI side

PC side

In the project directory, create a .tdbinit file :

With Eclipse ( STM32CUBEIDE or Eclipse C/C++ 2023 )

RPI side

PC side

Eclipse:

Toogle breakpoint at the main beginning. After loading program, press F8 ( continue ), you should go to the breakpoint.
Each time you debug, don’t forget to execute gdbserver on raspberry pi.