Bookworm armhf cross compile docker: Difference between revisions
From embeddedTS Manuals
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
Debian provides cross toolchains within their distribution for different architectures. | Debian provides cross toolchains within their distribution for different architectures. | ||
For best portability we recommend using a container like docker to run a Debian 12 rootfs for the toolchain. On any Linux system first install docker. | For best portability we recommend using a container like docker to run a Debian 12 rootfs for the toolchain. On any Linux system first install docker. | ||
{{Warning|We do not suggest using docker on Windows. Even though it will let you execute the compilers under a virtual machine in Windows, many build processes will not work with a case insensitive filesystem such as the Linux kernel.}} | |||
* Ubuntu/Debian: | * Ubuntu/Debian: | ||
<source lang=bash> | <source lang=bash> | ||
apt-get install docker -y | sudo apt-get install docker -y | ||
</source> | </source> | ||
* Fedora | * Fedora | ||
<source lang=bash> | <source lang=bash> | ||
dnf install docker -y | sudo dnf install docker -y | ||
</source> | </source> | ||
Line 17: | Line 19: | ||
</source> | </source> | ||
Make sure you can run docker's hello world image to verify it is working: | Make sure you can run docker's hello world image as your user to verify it is working: | ||
<source lang=bash> | <source lang=bash> | ||
docker run hello-world | docker run hello-world |
Revision as of 16:08, 5 January 2023
Debian provides cross toolchains within their distribution for different architectures.
For best portability we recommend using a container like docker to run a Debian 12 rootfs for the toolchain. On any Linux system first install docker.
WARNING: | We do not suggest using docker on Windows. Even though it will let you execute the compilers under a virtual machine in Windows, many build processes will not work with a case insensitive filesystem such as the Linux kernel. |
- Ubuntu/Debian:
sudo apt-get install docker -y
- Fedora
sudo dnf install docker -y
# Add your user to the docker group. You may need to logout/log back in.
sudo usermod -aG docker $USER
Make sure you can run docker's hello world image as your user to verify it is working:
docker run hello-world
Now create a file "/opt/docker-toolchain/docker-debian-bookworm-armhf/Dockerfile" with these contents:
# syntax = docker/dockerfile:1.2
FROM debian:bookworm
RUN dpkg --add-architecture armhf
RUN apt-get update && apt-get install -y \
autogen \
automake \
bash \
bc \
bison \
build-essential \
bzip2 \
ca-certificates \
ccache \
chrpath \
cpio \
curl \
diffstat \
fakeroot \
file \
flex \
gawk \
gcc-arm-linux-gnueabihf \
git \
gzip \
kmod \
libgpiod-dev:armhf \
libncursesw5-dev \
libssl-dev \
libtool \
libyaml-dev \
locales \
lz4 \
lzop \
make \
multistrap \
ncurses-dev \
pkg-config \
python3 \
python3-cbor \
python3-pexpect \
python3-pip \
qemu-user-static \
rsync \
runit \
socat \
srecord \
swig \
texinfo \
u-boot-tools \
zstd \
unzip \
vim \
wget \
xz-utils
# Provide a more friendly name
ENV debian_chroot debian_bookworm
RUN echo "PS1='\${debian_chroot}\\[\033[01;32m\\]@\\H\[\\033[00m\\]:\\[\\033[01;34m\\]\\w\\[\\033[00m\\]\\$ '" >> /etc/bash.bashrc
# Set up locales
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \
echo 'LANG="en_US.UTF-8"'>/etc/default/locale && \
dpkg-reconfigure --frontend=noninteractive locales && \
update-locale LANG=en_US.UTF-8
ENV LC_ALL en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US.UTF-8
# Needed for make dtbs_check
RUN pip3 install dtschema
Next make a shell script to enter into this docker container. In /usr/local/bin/docker-debian-bookworm:
#!/bin/bash -e
# Enters a docker running Debian 12 Bookworm
# Any arguments are run in the docker, or if no arguments it runs a shell
export TAG=debian-bookworm-armdev
SCRIPTPATH=$(readlink -f "$0")
DOCKERPATH=$(dirname "$SCRIPTPATH")/../docker/debian-bookworm
DOCKER_BUILDKIT=1 docker build --tag "$TAG" "$DOCKERPATH" --quiet
exec docker run --rm \
-it \
--volume "$(pwd)":/work \
--user $(id -g):$(id -u) \
-w /work \
-e HOME=/tmp \
"$TAG" \
$@;
Make this executable, and call it:
chmod a+x /usr/local/bin/docker-debian-bookworm
docker-debian-bookworm