Raspberry Pi cross-compilation in a Docker container.
Please raise any issues on the GitHub issue tracker as I don't get notified about Docker Hub comments.
- the gcc-linaro-arm-linux-gnueabihf-raspbian toolchain from raspberrypi/tools
- commands in the container are run as the calling user, so that any created files have the expected ownership (ie. not root)
- make variables (
LDetc) are set to point to the appropriate tools in the container
HOSTenvironment variables are set in the container
- symlinks such as
rpxc-objdumpare created in
- current directory is mounted as the container's workdir,
- works with boot2docker on OSX
This image is not intended to be run manually. Instead, there is a helper script which comes bundled with the image.
To install the helper script, run the image with no arguments, and redirect the output to a file.
docker run sdt4docker/raspberry-pi-cross-compiler > rpxc chmod +x rpxc mv rpxc ~/bin/
rpxc [command] [args...]
Execute the given command-line inside the container.
If the command matches one of the rpxc built-in commands (see below), that will be executed locally, otherwise the command is executed inside the container.
rpxc -- [command] [args...]
To force a command to run inside the container (in case of a name clash with a built-in command), use
-- before the command.
Fetch the latest version of the docker image.
Update the installed rpxc script with the one bundled in the image.
Update both the docker image, and the rpxc script.
The following command-line options and environment variables are used. In all cases, the command-line option overrides the environment variable.
RPXC_CONFIG / --config <path-to-config-file>
This file is sourced if it exists.
RPXC_IMAGE / --image <docker-image-name>
The docker image to run.
RPXC_ARGS / --args <docker-run-args>
Extra arguments to pass to the
docker run command.
Build the Makefile in the current directory.
rpxc rpxc-gcc -o hello-world hello-world.c
Standard bintools are available by adding an
Build the kernel from raspberrypi/linux.
The CROSS_COMPILE and ARCH flags are automatically set.
rpxc bash -c 'find . -name \*.o | sort > objects.txt'
Note that commands are executed verbatim. If you require any shell processing for environment variable expansion or redirection, please use
bash -c 'command args...'.
More examples can be found in the examples directory.