• Stars
    star
    169
  • Rank 223,429 (Top 5 %)
  • Language CMake
  • Created almost 5 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Rasperry PI Toolchains

Repository for Raspberry PI cross compiler using the new GCC8 and GCC9 for Raspbian Buster. This supports all new Raspberry PIs (ARMv7), and the older ones, including Zero, A, B, B+ (ARMv6) with newer GCCs.

You can probably also use this repository for any other ARMv6 and ARMv7 devices.

By default, newer GCC versions do not create correct binaries for ARMv6. Even though you pass the correct -mcpu= flag to gcc, it will create startup code for the newer ARMv7 architecture. Running them on your RasPI Zero will cause an "Illegal Instruction" exception.

See also: https://stackoverflow.com/questions/55465118/gcc-8-cross-compiler-outputs-armv7-executable-instead-of-armv6

This work is based on the great @tttapa and the Docker file here: https://gist.github.com/tttapa/534fb671c5f6cced0e1722d3e4aec987

A corresponding Blog post can be found here: https://solarianprogrammer.com/2018/05/06/building-gcc-cross-compiler-raspberry-pi/

A similar project can also be found here, but it only includes the compiled toolchains, which did not work out of the box for me: https://sourceforge.net/projects/raspberry-pi-cross-compilers

How to get the toolchain

You have two options:

  • Use the prebuilt toolchain attached to every github release (recommended)
  • Build the toolchain yourself

Use pre-built toolchain

Every github release has a pre-build toolchain attached. See

  1. Download the toolchain:
wget https://github.com/Pro/raspi-toolchain/releases/latest/download/raspi-toolchain.tar.gz
  1. Extract it. Note: The toolchain has to be in /opt/cross-pi-gcc since it's not location independent.
sudo tar xfz raspi-toolchain.tar.gz --strip-components=1 -C /opt
  1. You are done!

Build the toolchain from source

To build the toolchain, just clone this repository and then call:

docker build -f Dockerfile --network=host -t gcc9-rpi-zero .

This will take some time since it builds a docker container with the gcc compiler.

To run the docker container, use

docker run -it gcc9-rpi-zero bash

Install from source after building

To get the toolchain from the docker container into your host, just copy the files:

CONTAINER_ID=$(docker create gcc9-rpi-zero)
sudo docker cp $CONTAINER_ID:/opt/cross-pi-gcc /opt/cross-pi-gcc

It's important that you put the files into the same directory, since the toolchain has the paths hardcoded inside.

After that feel free to delete the docker container.

Test the toolchain

This repository contains a simple hello world example.

To cross-compile any executable after you installed the toolchain on your host, you need to get the current libraries and include files from your raspberry:

# Use the correct IP address here
rsync -vR --progress -rl --delete-after --safe-links [email protected]:/{lib,usr,etc/ld.so.conf.d,opt/vc/lib} $HOME/rpi/rootfs

Then call the script build_hello_world.sh.

To test the executable, copy it to your raspi:

scp build/hello [email protected]:/home/pi/hello
ssh [email protected]
./hello

More Repositories

1

dkim-exchange

DKIM Signing Agent for Microsoft Exchange Server
C#
402
star
2

open62541-esp32

open62541 OPC UA example for an ESP32 Microcontroller
C
45
star
3

open62541-arduino

open62541 OPC UA example for Arduino
CMake
34
star
4

middleware_evaluation

Performance tests for performance evaluation of various middleware implementations (OPC UA, MQTT, DDS, ROS)
C++
22
star
5

exchange-catchall

Exchange CatchAll Agent
C#
21
star
6

put.io-sync

Put.io Sync
JavaScript
18
star
7

opcua-animal-server

OPC UA Server for the OPC UA Companion Specification for Animals - A Tutorial
C
14
star
8

opcua-animal-cs

OPC UA Companion Specification for Animals - A Tutorial
C#
10
star
9

opcua-device-skills

OPC UA Device-Independent Skill Model
C#
9
star
10

processing-collada-loader

COLLADA 3D Model Loader for the Processing framework
Java
9
star
11

tinysvcmdns

Fork from https://bitbucket.org/geekman/tinysvcmdns
C
6
star
12

battery-monitor

PowerShell script to log current battery status of your PC
PowerShell
6
star
13

put.io-firefox

Put.io Firefox Addon
JavaScript
5
star
14

opcua-modeling-tutorial

Additional files as part of the OPC UA Modeling Tutorial on https://opcua.rocks/from-modelling-to-execution-opc-ua-information-model-tutorial/
Shell
3
star
15

HostEurope-Automatic-Snapshot

Automatic Snapshot generation for HostEurope VServer
Perl
3
star
16

open62541-influxdb

Automatical logging of OPC UA Variables to InfluxDB
C++
3
star
17

gazebo_hanoi

testing gazebo hanoi game
CMake
2
star
18

open62541-performance

open62541 Performance Tests
C
2
star
19

opcua-modeling-tutorial-server

Example server for the OPC UA Modeling Tutorial
C
2
star
20

tum-cogsys

Cognitive Systems Practical Course
C++
1
star
21

open62541_namespaces

Example repository for generating multiple namespaces out of .xml files in open62541
CMake
1
star
22

edo_gazebo

Comau e.DO Gazebo Simulation
CMake
1
star
23

Catalyst-Action-RenderView-ErrorHandler-Action-Email

Email Action for Catalyst::Action::RenderView::ErrorHandler
Perl
1
star