Skip to content

Instantly share code, notes, and snippets.

@kbingham
Last active April 14, 2025 11:46
Show Gist options
  • Select an option

  • Save kbingham/b35cc1402d02b0ef41b450941ad8f0c3 to your computer and use it in GitHub Desktop.

Select an option

Save kbingham/b35cc1402d02b0ef41b450941ad8f0c3 to your computer and use it in GitHub Desktop.

Revisions

  1. kbingham revised this gist Jun 20, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion Dockerfile.debian.bullseye.cross-arm64
    Original file line number Diff line number Diff line change
    @@ -10,7 +10,8 @@ RUN dpkg --add-architecture arm64
    # Expected system requirements
    RUN apt-get update && apt-get install -y \
    sudo \
    git
    git \
    dpkg-dev

    # Base libcamera image, with non-toolchain dependencies for building.
    # Base libcamera always-host packages (compilation dependencies)
  2. kbingham revised this gist Jun 7, 2022. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -21,3 +21,6 @@ If this works well, I'll hope to wrap this up into a better system for testing c
    ### Install built components on RPi

    TODO: This could be a step to build a debian package (would be nice) or tar/scp built objects to the target...

    Another alternative is to run sshfs and mount the RPi rootfs directly. Then a script could call
    `DESTDIR=$RPI_MOUNT_POINT ninja -C ./build/rpi/bullsye install`
  3. kbingham revised this gist May 17, 2022. 3 changed files with 11 additions and 25 deletions.
    16 changes: 7 additions & 9 deletions Dockerfile.debian.bullseye.cross-arm64
    Original file line number Diff line number Diff line change
    @@ -15,15 +15,11 @@ RUN apt-get update && apt-get install -y \
    # Base libcamera image, with non-toolchain dependencies for building.
    # Base libcamera always-host packages (compilation dependencies)
    RUN apt-get install -y \
    ninja-build pkg-config \
    meson ninja-build pkg-config \
    python3-yaml python3-ply python3-jinja2 \
    openssl \
    python3-sphinx doxygen graphviz \
    liblttng-ust-dev python3-jinja2 lttng-tools \
    python3-pip

    # Install supported version of meson
    RUN pip3 install 'meson==0.55.3'
    python3-sphinx doxygen graphviz texlive-latex-extra \
    liblttng-ust-dev python3-jinja2 lttng-tools

    # Base libcamera cross compiler and target architecture packages
    RUN apt-get install -y \
    @@ -37,11 +33,13 @@ RUN apt-get install -y \
    qttools5-dev-tools:arm64 libtiff-dev:arm64 \
    libexif-dev:arm64 libjpeg-dev:arm64 libyaml-dev:arm64

    # Generate the meson cross file using the debian package helper
    RUN /usr/share/meson/debcrossgen --arch arm64 -o /usr/share/meson/arm64-cross


    # Create a custom user to operate in the container
    RUN adduser --disabled-password --gecos '' libcamera
    RUN adduser libcamera sudo
    RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

    WORKDIR /home/libcamera
    USER libcamera
    USER libcamera
    8 changes: 4 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,19 +1,19 @@
    # Cross compilation environment for libcamera for the RPi Bullseye OS

    This will let you build a cross compilation docker image, and use it to compile libcamera for the RPi.
    These commands are expected to be run in a checkedout libcamera source, and save the Dockerfile and meson cross file locally.
    These commands are expected to be run in a checked out libcamera source, and save the Dockerfile file locally. A meson cross file will be automatically generated inside the debian bullseye environment.

    If this works well, I'll hope to wrap this up into a better system for testing cross compilation and automating the build of RPi packages.

    ### Build your cross compile docker image:

    `/usr/bin/docker build -t libcamera/debian/bullseye-cross-arm64 Dockerfile.debian.bullseye.cross-arm64`
    `/usr/bin/docker build -t libcamera/debian/bullseye-cross-arm64 - < Dockerfile.debian.bullseye.cross-arm64`

    ### Run a shell in the new docker image in the local libcamera directory
    `docker run -v "$PWD":"$PWD" -v "$HOME":"$HOME" -w "$PWD" --rm -it libcamera/debian/bullseye-cross-arm64`
    `docker run -v "$PWD":"$PWD" -w "$PWD" --rm -it libcamera/debian/bullseye-cross-arm64`

    ### Configure meson to perform the cross build
    `meson build/rpi/bullseye --cross-file aarch64-linux-gnu.mesoncross`
    `meson build/rpi/bullseye --cross-file /usr/share/meson/arm64-cross`

    ### (Cross-compile) Build libcamera at host compile speeds
    `ninja -C ./build/rpi/bullseye/`
    12 changes: 0 additions & 12 deletions aarch64-linux-gnu.mesoncross
    Original file line number Diff line number Diff line change
    @@ -1,12 +0,0 @@
    [binaries]
    c = '/usr/bin/aarch64-linux-gnu-gcc'
    cpp = '/usr/bin/aarch64-linux-gnu-g++'
    ar = '/usr/bin/aarch64-linux-gnu-gcc-ar'
    strip = '/usr/bin/aarch64-linux-gnu-strip'
    pkgconfig = '/usr/bin/aarch64-linux-gnu-pkg-config'

    [host_machine]
    system = 'linux'
    cpu_family = 'aarch64'
    cpu = 'aarch64'
    endian = 'little'
  4. kbingham revised this gist May 6, 2022. 1 changed file with 15 additions and 12 deletions.
    27 changes: 15 additions & 12 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,23 @@
    # Build your cross compile docker image:
    # Cross compilation environment for libcamera for the RPi Bullseye OS

    /usr/bin/docker build -t libcamera/debian/bullseye-cross-arm64 Dockerfile.debian.bullseye.cross-arm64
    This will let you build a cross compilation docker image, and use it to compile libcamera for the RPi.
    These commands are expected to be run in a checkedout libcamera source, and save the Dockerfile and meson cross file locally.

    # Run a shell in the new docker image in the local libcamera directory
    docker run \
    -v "$PWD":"$PWD" \
    -v "$HOME":"$HOME" \
    -w "$PWD" --rm -it libcamera/debian/bullseye-cross-arm64
    If this works well, I'll hope to wrap this up into a better system for testing cross compilation and automating the build of RPi packages.

    # Configure meson to perform the cross build
    meson build/rpi/bullseye --cross-file aarch64-linux-gnu.mesoncross
    ### Build your cross compile docker image:

    # (Cross-compile) Build libcamera at host compile speeds
    ninja -C ./build/rpi/bullseye/
    `/usr/bin/docker build -t libcamera/debian/bullseye-cross-arm64 Dockerfile.debian.bullseye.cross-arm64`

    ### Run a shell in the new docker image in the local libcamera directory
    `docker run -v "$PWD":"$PWD" -v "$HOME":"$HOME" -w "$PWD" --rm -it libcamera/debian/bullseye-cross-arm64`

    # Install built components on RPi
    ### Configure meson to perform the cross build
    `meson build/rpi/bullseye --cross-file aarch64-linux-gnu.mesoncross`

    ### (Cross-compile) Build libcamera at host compile speeds
    `ninja -C ./build/rpi/bullseye/`

    ### Install built components on RPi

    TODO: This could be a step to build a debian package (would be nice) or tar/scp built objects to the target...
  5. kbingham created this gist May 6, 2022.
    47 changes: 47 additions & 0 deletions Dockerfile.debian.bullseye.cross-arm64
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    FROM debian:bullseye

    ENV DEBIAN_FRONTEND noninteractive
    ENV LANG='C.UTF-8' LC_ALL='C.UTF-8'

    # Support multiarch builds to perform cross compilation
    # https://wiki.debian.org/Multiarch/HOWTO
    RUN dpkg --add-architecture arm64

    # Expected system requirements
    RUN apt-get update && apt-get install -y \
    sudo \
    git

    # Base libcamera image, with non-toolchain dependencies for building.
    # Base libcamera always-host packages (compilation dependencies)
    RUN apt-get install -y \
    ninja-build pkg-config \
    python3-yaml python3-ply python3-jinja2 \
    openssl \
    python3-sphinx doxygen graphviz \
    liblttng-ust-dev python3-jinja2 lttng-tools \
    python3-pip

    # Install supported version of meson
    RUN pip3 install 'meson==0.55.3'

    # Base libcamera cross compiler and target architecture packages
    RUN apt-get install -y \
    gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
    libgnutls28-dev:arm64 \
    libboost-dev:arm64 \
    libudev-dev:arm64 \
    libgstreamer1.0-dev:arm64 libgstreamer-plugins-base1.0-dev:arm64 \
    libevent-dev:arm64 \
    qtbase5-dev:arm64 libqt5core5a:arm64 libqt5gui5:arm64 libqt5widgets5:arm64 \
    qttools5-dev-tools:arm64 libtiff-dev:arm64 \
    libexif-dev:arm64 libjpeg-dev:arm64 libyaml-dev:arm64



    RUN adduser --disabled-password --gecos '' libcamera
    RUN adduser libcamera sudo
    RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

    WORKDIR /home/libcamera
    USER libcamera
    20 changes: 20 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    # Build your cross compile docker image:

    /usr/bin/docker build -t libcamera/debian/bullseye-cross-arm64 Dockerfile.debian.bullseye.cross-arm64

    # Run a shell in the new docker image in the local libcamera directory
    docker run \
    -v "$PWD":"$PWD" \
    -v "$HOME":"$HOME" \
    -w "$PWD" --rm -it libcamera/debian/bullseye-cross-arm64

    # Configure meson to perform the cross build
    meson build/rpi/bullseye --cross-file aarch64-linux-gnu.mesoncross

    # (Cross-compile) Build libcamera at host compile speeds
    ninja -C ./build/rpi/bullseye/


    # Install built components on RPi

    TODO: This could be a step to build a debian package (would be nice) or tar/scp built objects to the target...
    12 changes: 12 additions & 0 deletions aarch64-linux-gnu.mesoncross
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    [binaries]
    c = '/usr/bin/aarch64-linux-gnu-gcc'
    cpp = '/usr/bin/aarch64-linux-gnu-g++'
    ar = '/usr/bin/aarch64-linux-gnu-gcc-ar'
    strip = '/usr/bin/aarch64-linux-gnu-strip'
    pkgconfig = '/usr/bin/aarch64-linux-gnu-pkg-config'

    [host_machine]
    system = 'linux'
    cpu_family = 'aarch64'
    cpu = 'aarch64'
    endian = 'little'