A Debian-based Cross-Compile Environment running in Docker.
Workflows :
- Summary
- Create a container
- Open a shell in the container
- Install linux tools
- Building the image from scratch
- License & Acknowledgements
docker run -d --name debian-xcenv --hostname debian-xcenv -v ./exercises:/root/exercises --network=host --tty=true ghcr.io/fred-corp/debian-xcenv
YAML Example :
services:
debian-xcenv:
image: ghcr.io/fred-corp/debian-xcenv:latest
container_name: debian-xcenv
hostname: debian-xcenv
restart: unless-stopped
privileged: true
tty: true
stdin_open: true
8000
network_mode: host
ipc: host
pid: host
volumes:
- "./exercices:/root/exercises"
Then, create the container with docker-compose :
docker-compose up -d
Note : You can also specify the architecture of the container by adding
:arm64
or:amd64
to the image name.
Note : This commands will mount theexercices
folder in the current directory to/root/exercises
in the container. You can change this path to your needs.
You can open a shell in the container using the following command :
docker exec -it -e "TERM=xterm-256color" debian-xcenv /bin/zsh
Depending on your target, you'll need different linux tools.
If you're building for Raspberry Pi, you'll need to install the following tools and files :
From the amazing guide from Jeff Geerling
git clone --depth=1 https://github.com/raspberrypi/linux ./rpi-linux
cd rpi-linux
KERNEL=kernel8
Create the .config
file for the kernel:
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
Then, you can build the kernel:
make -j$(nproc --all) ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- Image modules dtbs
If you're building for Beaglebone Black, you'll need to install the following tools and files :
From the amazing guide from Quentin Delhaye
wget https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf.tar.xz
mkdir -p /opt/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf
chown $LOGNAME:$LOGNAME /opt/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf
tar -xf arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf.tar.xz -C /opt/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf
echo "PATH=/opt/arm-gnu-toolchain-13.2.rel1-aarch64-arm-none-linux-gnueabihf/arm-gnu-toolchain-13.2.Rel1-aarch64-arm-none-linux-gnueabihf/bin/:$PATH" >> ~/.zshrc
source ~/.zshrc
wget https://developer.arm.com/-/media/Files/downloads/gnu/13.2.rel1/binrel/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz
mkdir -p /opt/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf
chown $LOGNAME:$LOGNAME /opt/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf
tar -xf arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf.tar.xz -C /opt/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf
echo "PATH=/opt/arm-gnu-toolchain-13.2.rel1-x86_64-arm-none-linux-gnueabihf/arm-gnu-toolchain-13.2.Rel1-x86_64-arm-none-linux-gnueabihf/bin/:$PATH" >> ~/.zshrc
source ~/.zshrc
arm-none-linux-gnueabihf-gcc -v
Note : You can then follow the rest of Quentin Delhaye's guide to build the kernel; steps should look like this :
Clone the kernel source code (4.19 branch only) :
git clone -b 4.19 --depth=1 https://github.com/beagleboard/linux.git ./bbb-linux
cd bbb-linux
Add a .config
file for the kernel (you can do so by following this step), then compile :
make -j$(nproc --all) CROSS_COMPILE=arm-none-linux-gnueabihf- ARCH=arm
If you want to build the image from scratch, you can do so by running the following command in the root of the repository:
docker-compose build
Then, you can run the image using the following command:
docker-compose up -d
Made with ❤️, lots of ☕️, and lack of 🛌