Skip to content

Commit

Permalink
Refactor Kernel build to use Debos recipe (#135)
Browse files Browse the repository at this point in the history
* Update kernel config to apply changes rather than full configuration

* Add chroot kernel build recipe and update kernel packages
Deprecate cross-compiled kernel patches

* Update base images

---------

Co-authored-by: Daniel McKnight <daniel@neon.ai>
  • Loading branch information
NeonDaniel and Daniel McKnight committed Mar 27, 2024
1 parent 31f3b4a commit ecf0b56
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 21 deletions.
2 changes: 1 addition & 1 deletion base_images/base_images.md5
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
a6d01ca6981b96ebfb274d0b34b9ebc2 opi5_base.tar.gz
885ba774079d865c45e134be184e2511 rpi4_base.tar.gz
f4555d8e206ccc61906f3b340283e279 rpi4_base.tar.gz
12 changes: 8 additions & 4 deletions kernel_build/rpi4/build_kernel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

sudo apt install -y git bc bison flex libssl-dev make libc6-dev libncurses5-dev\
crossbuild-essential-arm64 libncurses5-dev binutils
crossbuild-essential-arm64 libncurses5-dev binutils build-essential

ROOT_PATH="$(pwd)"

Expand All @@ -37,9 +37,13 @@ git clone --depth=1 https://github.com/raspberrypi/linux -b "${branch}"
cd linux || exit 10
export KERNEL=kernel8
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- bcm2711_defconfig
mv .config .config.old
cp "../config-${branch}" .config
make -j4 ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- deb-pkg

while read line; do
echo "${line}"
./scripts/config --set-val ${line}
done < "../config-overlay-${branch}"

make -j ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- deb-pkg
cd .. || exit 10
rm -rf linux
for file in *.deb; do
Expand Down
10 changes: 10 additions & 0 deletions kernel_build/rpi4/config-overlay-rpi-6.1.y
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CONFIG_LOCALVERSION "-gecko"
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE n
CONFIG_MEDIA_SUPPORT y
CONFIG_MEDIA_SUPPORT_FILTER n
CONFIG_SQUASHFS y
CONFIG_SQUASHFS_XZ y
CONFIG_SQUASHFS_4K_DEVBLK_SIZE y
CONFIG_OVERLAY_FS y
CONFIG_HEADERS_INSTALL y
10 changes: 10 additions & 0 deletions overlays/00-build-kernel/var/config-overlay-rpi-6.1.y
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CONFIG_LOCALVERSION "-gecko"
CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y
CONFIG_CPU_FREQ_DEFAULT_GOV_POWERSAVE n
CONFIG_MEDIA_SUPPORT y
CONFIG_MEDIA_SUPPORT_FILTER n
CONFIG_SQUASHFS y
CONFIG_SQUASHFS_XZ y
CONFIG_SQUASHFS_4K_DEVBLK_SIZE y
CONFIG_OVERLAY_FS y
CONFIG_HEADERS_INSTALL y
Binary file modified overlays/02-rpi4/var/tmp/linux-headers-6.1.77-gecko+_6.1.77-gecko+-1_arm64.deb
100644 → 100755
Binary file not shown.
Binary file modified overlays/02-rpi4/var/tmp/linux-image-6.1.77-gecko+_6.1.77-gecko+-1_arm64.deb
100644 → 100755
Binary file not shown.
Binary file modified overlays/02-rpi4/var/tmp/linux-libc-dev_6.1.77-gecko+-1_arm64.deb
100644 → 100755
Binary file not shown.
66 changes: 66 additions & 0 deletions recipes/00-build-kernel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{{ $kernel := "rpi-6.6.y" }}

architecture: arm64
actions:
- action: debootstrap
suite: bookworm
components:
- main
mirror: https://deb.debian.org/debian
variant: minbase
- action: apt
chroot: true
description: Install Build Dependencies
packages:
- git-core
- bc
- bison
- flex
- libssl-dev
- make
- libc6-dev
- libncurses5-dev
- binutils
- build-essential
- rsync
- kmod
- cpio
- lsb-release
- gcc
- zstd
- debhelper

- action: overlay
description: Overlay Configuration
source: ../overlays/00-build-kernel
destination: /
- action: run
chroot: true
description: Clone Kernel
command: git clone --depth=1 https://github.com/raspberrypi/linux -b {{ $kernel }} /var/linux

- action: run
chroot: true
description: Configure Kernel
command: |
cd /var/linux || exit 10
export KERNEL=kernel8
make ARCH=arm64 bcm2711_defconfig
while read line; do
echo "${line}"
./scripts/config --set-val ${line}
done < "/var/config-overlay-{{ $kernel }}"
- action: run
chroot: true
description: Build Kernel
command: |
cd /var/linux || exit 10
make -j16 ARCH=arm64 deb-pkg && echo "made kernel" || echo "kernel make failed"
- action: run
description: Copy output patch to host
chroot: false
command: |
mv "${ROOTDIR}/var/linux"*.deb "/image_build/overlays/02-rpi4/var/tmp/"
chmod 777 "/image_build/overlays/02-rpi4/var/tmp/"*.deb
16 changes: 0 additions & 16 deletions recipes/02-rpi4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,31 +49,15 @@ actions:
- libcamera-apps

- action: run
origin: kernel
chroot: true
description: Install kernel
label: dpkg
command: dpkg -i /var/tmp/*.deb && rm /var/tmp/* -r || exit 3

- action: run
description: Copy dtb and kernel ({{ $kernel_version }}) to boot firmware partition
chroot: true
script: ../scripts/02-link_kernel.sh {{ $kernel_version }}

- action: run
description: Patch kernel headers
chroot: true
script: ../scripts/02-patch_kernel_headers.sh

# - action: run
# description: Patch RPi5 Support
# chroot: true
# command: |
# cd /usr/lib/firmware/brcm
# ln ../cypress/cyfmac43455-sdio.bin brcmfmac43455-sdio.raspberrypi,5-model-b.bin
# ln ../cypress/cyfmac43455-sdio.clm_blob brcmfmac43455-sdio.raspberrypi,5-model-b.clm_blob
# ln brcmfmac43455-sdio.raspberrypi,4-model-b.txt brcmfmac43455-sdio.raspberrypi,5-model-b.txt

- action: run
description: Link firmware
chroot: true
Expand Down

0 comments on commit ecf0b56

Please sign in to comment.