From dfafe06964638e0c4bb90f40055b6e62db4bb1d3 Mon Sep 17 00:00:00 2001 From: Yannick Heneault Date: Sat, 2 Apr 2022 21:36:41 -0400 Subject: [PATCH] added support for raspberry pi 4 --- conf/turnkey.d/arm.d/rpi | 12 +++++ conf/turnkey.d/{ => x86.d}/grub-debug | 0 conf/turnkey.d/{ => x86.d}/grub-iface-naming | 0 mk/turnkey.mk | 2 +- .../rpi-reconfigure-raspi-firmware.service | 14 +++++ overlays/turnkey.d/arm.d/fstab/etc/fstab | 4 ++ .../arm.d/interfaces/etc/network/interfaces | 17 ++++++ .../initramfs-tools/hooks/rpi-resizerootfs | 23 ++++++++ .../scripts/local-bottom/rpi-resizerootfs | 53 +++++++++++++++++++ .../{ => x86.d}/grub/etc/default/grub | 0 .../interfaces/etc/network/interfaces | 0 plans/boot | 10 +++- plans/turnkey/base | 7 ++- plans/wifi | 4 ++ 14 files changed, 143 insertions(+), 3 deletions(-) create mode 100755 conf/turnkey.d/arm.d/rpi rename conf/turnkey.d/{ => x86.d}/grub-debug (100%) rename conf/turnkey.d/{ => x86.d}/grub-iface-naming (100%) create mode 100644 overlays/turnkey.d/arm.d/firmware/etc/systemd/system/rpi-reconfigure-raspi-firmware.service create mode 100644 overlays/turnkey.d/arm.d/fstab/etc/fstab create mode 100644 overlays/turnkey.d/arm.d/interfaces/etc/network/interfaces create mode 100755 overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/hooks/rpi-resizerootfs create mode 100755 overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs rename overlays/turnkey.d/{ => x86.d}/grub/etc/default/grub (100%) rename overlays/turnkey.d/{ => x86.d}/interfaces/etc/network/interfaces (100%) diff --git a/conf/turnkey.d/arm.d/rpi b/conf/turnkey.d/arm.d/rpi new file mode 100755 index 00000000..51081cc7 --- /dev/null +++ b/conf/turnkey.d/arm.d/rpi @@ -0,0 +1,12 @@ +#!/bin/bash -e + +systemctl enable rpi-reconfigure-raspi-firmware.service + +cp /usr/lib/linux-image-*-arm64/broadcom/bcm*rpi*.dtb /boot/firmware/ + +sed -i 's/root=/console=ttyS1,115200 root=/' /boot/firmware/cmdline.txt +sed -i 's#root=/dev/mmcblk0p2#root=LABEL=RASPIROOT#' /boot/firmware/cmdline.txt +sed -i 's/^#ROOTPART=.*/ROOTPART=LABEL=RASPIROOT/' /etc/default/raspi*-firmware + +sed -i 's/cma=64M //' /boot/firmware/cmdline.txt + diff --git a/conf/turnkey.d/grub-debug b/conf/turnkey.d/x86.d/grub-debug similarity index 100% rename from conf/turnkey.d/grub-debug rename to conf/turnkey.d/x86.d/grub-debug diff --git a/conf/turnkey.d/grub-iface-naming b/conf/turnkey.d/x86.d/grub-iface-naming similarity index 100% rename from conf/turnkey.d/grub-iface-naming rename to conf/turnkey.d/x86.d/grub-iface-naming diff --git a/mk/turnkey.mk b/mk/turnkey.mk index 289b5084..ee6df679 100644 --- a/mk/turnkey.mk +++ b/mk/turnkey.mk @@ -3,7 +3,7 @@ RELEASE ?= debian/$(shell lsb_release -s -c) CDROOT ?= gfxboot-turnkey HOSTNAME ?= $(shell basename "$(shell pwd)") -CONF_VARS += HOSTNAME ROOT_PASS NONFREE PHP_VERSION TKL_TESTING BACKPORTS +CONF_VARS += HOSTNAME ROOT_PASS NONFREE PHP_VERSION TKL_TESTING BACKPORTS ARCH_FAMILY CONF_VARS += WEBMIN_THEME WEBMIN_FW_TCP_INCOMING WEBMIN_FW_TCP_INCOMING_REJECT WEBMIN_FW_UDP_INCOMING WEBMIN_FW_NAT_EXTRA WEBMIN_FW_MANGLE_EXTRA # these are needed to control styling of credits (e.g., conf/apache-credit) CONF_VARS += CREDIT_STYLE CREDIT_STYLE_EXTRA CREDIT_ANCHORTEXT CREDIT_LOCATION diff --git a/overlays/turnkey.d/arm.d/firmware/etc/systemd/system/rpi-reconfigure-raspi-firmware.service b/overlays/turnkey.d/arm.d/firmware/etc/systemd/system/rpi-reconfigure-raspi-firmware.service new file mode 100644 index 00000000..d8c55582 --- /dev/null +++ b/overlays/turnkey.d/arm.d/firmware/etc/systemd/system/rpi-reconfigure-raspi-firmware.service @@ -0,0 +1,14 @@ +[Unit] +Description=Reconfigure raspi-firmware to regenerate config.txt matching actual hardware +Before=sysinit.target +DefaultDependencies=no +RequiresMountsFor=/boot/firmware + +[Service] +Type=oneshot +TimeoutSec=infinity +ExecStart=/usr/sbin/dpkg-reconfigure raspi-firmware +ExecStart=/bin/systemctl --no-reload disable %n + +[Install] +RequiredBy=sysinit.target diff --git a/overlays/turnkey.d/arm.d/fstab/etc/fstab b/overlays/turnkey.d/arm.d/fstab/etc/fstab new file mode 100644 index 00000000..805b5997 --- /dev/null +++ b/overlays/turnkey.d/arm.d/fstab/etc/fstab @@ -0,0 +1,4 @@ +# The root file system has fs_passno=1 as per fstab(5) for automatic fsck. +LABEL=RASPIROOT / ext4 rw 0 1 +# All other file systems have fs_passno=2 as per fstab(5) for automatic fsck. +LABEL=RASPIFIRM /boot/firmware vfat rw 0 2 diff --git a/overlays/turnkey.d/arm.d/interfaces/etc/network/interfaces b/overlays/turnkey.d/arm.d/interfaces/etc/network/interfaces new file mode 100644 index 00000000..cf720aa3 --- /dev/null +++ b/overlays/turnkey.d/arm.d/interfaces/etc/network/interfaces @@ -0,0 +1,17 @@ +# UNCONFIGURED INTERFACES +# remove the above line if you edit this file + +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp + +allow-hotplug eth1 +iface eth1 inet dhcp + +allow-hotplug wlan0 +iface wlan0 inet dhcp + wpa-ssid my-network-ssid + wpa-psk s3kr3t_P4ss + diff --git a/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/hooks/rpi-resizerootfs b/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/hooks/rpi-resizerootfs new file mode 100755 index 00000000..f4776aa4 --- /dev/null +++ b/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/hooks/rpi-resizerootfs @@ -0,0 +1,23 @@ +#!/bin/sh +set -e + +# +# List the soft prerequisites here. This is a space separated list of +# names, of scripts that are in the same directory as this one, that +# must be run before this one can be. +# +PREREQS="" +case $1 in + prereqs) echo "$PREREQS"; exit 0;; +esac + +. /usr/share/initramfs-tools/hook-functions + +# XXX: tail and realpath are included by default, right? +#copy_exec /usr/bin/realpath +#copy_exec /usr/bin/tail +copy_exec /sbin/blkid +copy_exec /bin/lsblk +copy_exec /sbin/parted +copy_exec /sbin/partprobe +copy_exec /sbin/resize2fs diff --git a/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs b/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs new file mode 100755 index 00000000..09bf36f2 --- /dev/null +++ b/overlays/turnkey.d/arm.d/resizerootfs/etc/initramfs-tools/scripts/local-bottom/rpi-resizerootfs @@ -0,0 +1,53 @@ +#!/bin/sh +set -e + +# +# List the soft prerequisites here. This is a space separated list of +# names, of scripts that are in the same directory as this one, that +# must be run before this one can be. +# +PREREQS="" +case $1 in + prereqs) echo "$PREREQS"; exit 0;; +esac + +. /scripts/functions + +# Given the root partition, get the underlying device and partition number +rootpart=$(realpath $ROOT) +rootpart_nr=$(blkid -sPART_ENTRY_NUMBER -o value -p $rootpart) +rootdev="/dev/$(lsblk -no pkname "$rootpart")" + +# Parted will detect if the GPT label is messed up and fix it +# automatically, we just need to tell it to do so. +parted -s $rootdev print 2>&1 | grep -z "fix the GPT" && { + echo "Fix" | parted ---pretend-input-tty $rootdev print +} + +# Check if there's free space at the end of the device +free_space="$(parted -m -s $rootdev print free | tail -n1 | grep free)" +if test -z "$free_space"; then + # Great, we already resized; nothing left to do! + exit 0 +fi + +log_begin_msg "$0 resizing $ROOT" + +# Unmount for safety +umount "${rootmnt}" + +# Expand the partition size to fill the entire device +parted -s $rootdev resizepart $rootpart_nr 100% + +wait_for_udev 5 + +# Now resize the filesystem +partprobe $rootdev +resize2fs $rootpart + +# Remount root +if ! mount -r ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then + panic "Failed to mount ${ROOT} as root file system." +fi + +log_end_msg diff --git a/overlays/turnkey.d/grub/etc/default/grub b/overlays/turnkey.d/x86.d/grub/etc/default/grub similarity index 100% rename from overlays/turnkey.d/grub/etc/default/grub rename to overlays/turnkey.d/x86.d/grub/etc/default/grub diff --git a/overlays/turnkey.d/interfaces/etc/network/interfaces b/overlays/turnkey.d/x86.d/interfaces/etc/network/interfaces similarity index 100% rename from overlays/turnkey.d/interfaces/etc/network/interfaces rename to overlays/turnkey.d/x86.d/interfaces/etc/network/interfaces diff --git a/plans/boot b/plans/boot index b21798ea..06a53334 100644 --- a/plans/boot +++ b/plans/boot @@ -2,16 +2,20 @@ systemd /* even in CHROOT_ONLY we need systemctl to configure systemd se #ifndef CHROOT_ONLY +#ifndef ARM64 syslinux /* Collection of bootloaders */ syslinux-common /* Collection of bootloaders (common) */ isolinux /* Collection of bootloaders (ISO 9960) */ -hdparm /* Tune hard disk parameters for high performance */ live-boot /* live-boot replaces casper in v16.x */ live-tools /* live tools provides additional tools for live booting */ live-boot-initramfs-tools +#endif + +hdparm /* Tune hard disk parameters for high performance */ initramfs-tools firmware-linux-free busybox +parted #ifdef UBUNTU upstart @@ -33,6 +37,10 @@ linux-image-686-pae #ifdef AMD64 linux-image-amd64 #endif +#ifdef ARM64 +linux-image-arm64 +raspi-firmware +#endif #endif #endif diff --git a/plans/turnkey/base b/plans/turnkey/base index 780c0272..ada65c0d 100644 --- a/plans/turnkey/base +++ b/plans/turnkey/base @@ -1,12 +1,18 @@ #include #include #include +#ifdef ARM64 +#include +#endif wget curl rsync +#ifndef ARM64 di-live +#endif + whiptail /* di-live recommends */ kbd /* di-live recommends */ lvm2 /* di-live recommends */ @@ -15,7 +21,6 @@ eject /* di-live recommends */ confconsole kbd /* confconsole recommends */ -di-live /* confconsole recommends */ resolvconf /* confconsole recommends */ /* jiiterentropy-rngd provides entropy from cpu jitter; req'd in buster to */ diff --git a/plans/wifi b/plans/wifi index 7c454946..b16910a3 100644 --- a/plans/wifi +++ b/plans/wifi @@ -3,4 +3,8 @@ wireless-tools # Tools for manipulating Linux Wireless Extensions wpasupplicant # Client support for WPA and WPA2 (IEEE 802.11i) +#ifdef ARM64 +firmware-brcm80211 +#endif + #endif