Skip to content

Cross-Compilation Tool Bugs with Raspberry Pi 5 #746

@dus-tin8

Description

@dus-tin8

Board: Raspberry Pi 5
OS: Raspberry Pi OS Bookworm 2024-05 (64-bit)
Kernel: 6.6.x
Goal: Get a custom kernel compiled

https://github.com/geerlingguy/raspberry-pi-pcie-devices/tree/master/extras/cross-compile

The cross-compilation process described in this repository does not fully work out of the box for the Raspberry Pi 5 - mainly due to:

  • Docker issues due to outdated packages and security settings
  • Wrong install path for the compiled kernel

Fixes

Despite the repo being very helpful overall, some crucial adjustments are required.

Error during Build of Container

#0 0.538 Err:4 http://deb.debian.org/debian buster Release
#0 0.538   404  Not Found [IP: 151.101.194.132 80]
#0 0.549 Err:5 http://deb.debian.org/debian-security buster/updates Release
#0 0.549   404  Not Found [IP: 151.101.194.132 80]
...

Debian Buster has been archived, and the old package sources (such as http://deb.debian.org/debian buster) now return 404 Not Found errors. As a result, apt-get update fails during the Docker build process.

To work around this, the APT sources need to be updated to use the Debian archive mirror (http://archive.debian.org) and the Acquire::Check-Valid-Until option must be disabled to avoid signature expiry checks.

**Dockerfile**
...
RUN echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid && \
    sed -i 's|http://deb.debian.org|http://archive.debian.org|g' /etc/apt/sources.list && \
    sed -i 's|http://security.debian.org|http://archive.debian.org|g' /etc/apt/sources.list && \
    apt-get clean && \
    apt-get update && \
    apt-get install -y git bc sshfs bison flex libssl-dev python3 make kmod libc6-dev libncurses5-dev crossbuild-essential-armhf crossbuild-essential-arm64 && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*
...

Problems with the copykernel Script

While using the copykernel.sh script with a Raspberry Pi 5, I encountered two specific problems. Below are detailed descriptions and working solutions:

  1. fuse: mount failed: Permission denied
    This happens because the container does not have the necessary privileges to use FUSE (sshfs) by default. Add the following security option to docker-compose.yml:
services:
  cross-compiler:
    security_opt:
      - apparmor:unconfined
  1. Raspberry Pi still boots into the default kernel
    Even after copying the kernel and modules using the script, the Raspberry Pi boots the wrong kernel:
[    0.000000] Linux version 6.6.51+rpt-rpi-2712

This is because RPi 5, CM5 and Pi 500 firmware defaults to loading kernel_2712.img because this image contains optimisations specific to those models (e.g. 16K page-size).
Additionally, the path to the kernel is different. It has to be changed from /boot to /boot/firmware.

**/usr/local/bin/copykernel.sh**
...
sshfs root@$PI_ADDRESS:/boot/firmware /mnt/pi-fat32
...

Notice that the script copies the image to kernel8.img so either delete kernel_2712.img or set the /boot/firmware/config.txt with an additional parameter:

[all]
kernel=kernel8.img

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions