Skip to content

Commit

Permalink
Merge pull request #19 from go-debos/wip/d4s/rpi64
Browse files Browse the repository at this point in the history
Arm64 unified recipe for Raspberry Pi 3 and 4
  • Loading branch information
d4s authored Nov 22, 2020
2 parents 74b2593 + b38beb1 commit 3469eec
Show file tree
Hide file tree
Showing 10 changed files with 173 additions and 123 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
Collection of recipes for ['debos' tool](https://github.com/go-debos/debos).

* `rpi3` contains a recipe for building an image for `stretch`.
* `rpi3bplus` contains a recipe for building an image for `buster`. It has only
been tested using a USB-serial cable to connect to the rpi3. And Ethernet should
work.
* `rpi64` contains a recipe for building an unified image for Raspberry Pi 3 and 4.
It has been tested with `bullseye` and `sid` by using additional parameters:
debos -t suite:sid -t kernel:linux-image-5.8.0-1-arm64-unsigned rpi64/debimage-rpi64.yaml
Use login 'user' with password 'user' to log in.

Initial recipes for Debian are based on previous work located at https://git.apertis.org/cgit/apertis-workshop.git
111 changes: 0 additions & 111 deletions rpi3bplus/debimage-rpi3.yaml

This file was deleted.

6 changes: 0 additions & 6 deletions rpi3bplus/scripts/replace-u-boot-rpi.sh

This file was deleted.

167 changes: 167 additions & 0 deletions rpi64/debimage-rpi64.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
{{- $firmware_version := or .firmware_version "1.20201022" -}}
{{- $mirror := or .mirror "http://deb.debian.org/debian" -}}
{{- $suite := or .suite "bullseye" -}}
{{- $kernel := or .kernel "linux-image-arm64" -}}
{{- $cmdline := or .cmdline " rootwait ro fsck.mode=auto fsck.repair=yes console=ttyS1,115200" -}}
{{- $image := or .image "debian-rpi64.img" -}}

architecture: arm64

actions:
{{ if ne $firmware_version "debian" }}
# Download all needed proprietary stuff first
- action: download
description: Download latest version of the firmware from GitHub
url: http://github.com/raspberrypi/firmware/archive/{{ $firmware_version }}.tar.gz
unpack: true # Unpack downloaded file
name: firmware # name for usage directory with unpacked content in other actions
{{ end }}

- action: debootstrap
suite: {{ $suite }}
components:
- main
- non-free
mirror: {{ $mirror }}
variant: minbase

- action: apt
description: Install extra packages
packages:
- adduser
- bluetooth
- ca-certificates
- dbus-user-session
- iproute2
- i2c-tools
- libnss-resolve
- openssh-server
- sudo
- systemd-sysv
- u-boot-menu
- u-boot-rpi
- vim-tiny

- action: overlay
description: Install U-Boot menu configuration
source: overlays/u-boot-menu

- action: apt
description: Install kernel and firmware packages for RPi
packages:
- {{ $kernel}}
- firmware-brcm80211
- rpi.gpio-common

- action: overlay
description: Copy config.txt
source: overlays/fw-config
destination: /boot/firmware

- action: run
description: Install U-Boot
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/u-boot/rpi_arm64/u-boot.bin ${ROOTDIR}/boot/firmware/"

- action: run
description: Copy DTBs for the kernel
chroot: false
command: sh -c "mkdir -p ${ROOTDIR}/boot/dtbs; cp -rav ${ROOTDIR}/usr/lib/linux-image-*-arm64/broadcom ${ROOTDIR}/boot/dtbs/"

{{ if ne $firmware_version "debian" }}
- action: overlay
description: Install RPi boot firmware ({{ $firmware_version }})
origin: firmware
source: firmware-{{ $firmware_version }}/boot
destination: /boot/firmware

{{ else }}
- action: apt
description: Install RPi firmware package
packages:
- raspi-firmware

- action: run
description: Install RPi boot firmware (Debian)
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/raspi-firmware/* ${ROOTDIR}/boot/firmware/"

- action: run
description: Copy DTBs from the kernel
chroot: false
command: sh -c "cp -av ${ROOTDIR}/usr/lib/linux-image-*-arm64/broadcom/* ${ROOTDIR}/boot/firmware/"

- action: run
description: Use upstream DTBs naming
chroot: false
command: sh -c "echo upstream_kernel=1 >> ${ROOTDIR}/boot/firmware/config.txt"

# Do not need to keep firmware package after firmware partition setup.
# raspi-firmware contains kernel postinstall script incompatible with U-Boot
- action: run
description: Remove RPi firmware package
chroot: true
command: dpkg -P raspi-firmware
{{ end }}

- action: run
description: Cleanup firmware partition
chroot: false
command: sh -c "rm -rf ${ROOTDIR}/boot/firmware/kernel* ${ROOTDIR}/boot/firmware/vmlinuz* ${ROOTDIR}/boot/firmware/initrd.img*"

- action: run
description: Set up user
chroot: true
script: scripts/setup-user.sh

- action: run
description: Add hostname
chroot: true
command: echo rpi64 > /etc/hostname

- action: overlay
description: Autoload modules
source: overlays/modules

- action: overlay
source: overlays/networkd

- action: run
chroot: true
script: scripts/setup-networking.sh

- action: image-partition
imagename: {{ $image }}
imagesize: 4GB
partitiontype: msdos
mountpoints:
- mountpoint: /
partition: root
- mountpoint: /boot/firmware
partition: firmware
options: [ x-systemd.automount ]
partitions:
- name: firmware
fs: fat32
start: 0%
end: 64MB
- name: root
fs: ext4
start: 64MB
end: 100%
flags: [ boot ]

- action: filesystem-deploy
description: Deploying filesystem onto image
setup-kernel-cmdline: true
append-kernel-cmdline: {{ $cmdline }}

- action: run
description: Create block map file
postprocess: true
command: bmaptool create {{ $image }} > {{ $image }}.bmap

- action: run
description: Compressing final image
postprocess: true
command: gzip -f {{ $image }}
File renamed without changes.
1 change: 1 addition & 0 deletions rpi64/overlays/modules/etc/modules-load.d/i2c-dev.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
i2c-dev
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ U_BOOT_ALTERNATIVES="default recovery"
U_BOOT_DEFAULT="l0"
U_BOOT_ENTRIES="all"
U_BOOT_MENU_LABEL="Debian GNU/Linux"
U_BOOT_PARAMETERS="root=/dev/mmcblk0p2 ro rootwait console=ttyS1,115200"
U_BOOT_PARAMETERS="root=LABEL=root ro rootwait console=ttyS1,115200"
U_BOOT_ROOT=""
U_BOOT_TIMEOUT="50"
U_BOOT_FDT="broadcom/bcm2837-rpi-3-b-plus.dtb"
#U_BOOT_FDT_DIR="/boot/dtbs/"

File renamed without changes.
File renamed without changes.

0 comments on commit 3469eec

Please sign in to comment.