diff --git a/README.md b/README.md index 32d3bd1..d07a30c 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ `rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2), Raspberry Pi 3 (RPi3) and Raspberry Pi 4 (RPi4) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `jessie`, `stretch`, `buster` and 'bullseye'. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 and Raspberry Pi 4 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```). + ## Build dependencies The following list of Debian packages must be installed on the build system because they are essentially required for the bootstrapping process. The script will check if all required packages are installed and missing packages will be installed automatically if confirmed by the user. @@ -208,6 +209,7 @@ The following static networking parameters are only supported if `ENABLE_WIFI_DH |ENABLE_UBOOT|boolean|false|`true`\|`false`|Replace the default RPi 0/1/2/3 second stage bootloader (bootcode.bin) with [U-Boot bootloader](https://git.denx.de/?p=u-boot.git;a=summary). U-Boot can boot images via the network using the BOOTP/TFTP protocol. RPI4 needs tbd| |UBOOTSRC_DIR|string||`FullPathToUBootFolder`|Full path to a directory named `u-boot` of [U-Boot bootloader sources](https://git.denx.de/?p=u-boot.git;a=summary) that will be copied, configured, build and installed inside the chroot| |ENABLE_FBTURBO|boolean|false|`true`\|`false`|Install and enable the [hardware accelerated Xorg video driver](https://github.com/ssvb/xf86-video-fbturbo) `fbturbo`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling| +|ENABLE_GR_ACCEL|boolean|false|`true`\|`false`|Install and enable [one of the 3D graphics accelerators for Raspi4](https://www.raspberrypi.org/documentation/configuration/config-txt/video.md) `vc4-fkms-v3d`. Not compatible with `fbturbo` mutually excluded and installed for Raspberry4 only| |FBTURBOSRC_DIR|string||`FullPathToFbTurboFolder`|Full path to a directory named `xf86-video-fbturbo` of [hardware accelerated Xorg video driver sources](https://github.com/ssvb/xf86-video-fbturbo) that will be copied, configured, build and installed inside the chroot| |ENABLE_VIDEOCORE|boolean|false|`true`\|`false`|Install and enable the [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) `vcgencmd`. Please note that this driver is currently limited to hardware accelerated window moving and scrolling| |VIDEOCORESRC_DIR|string||`FullPathToVideoSrcFolder`|Full path to a directory named `userland` of [ARM side libraries for interfacing to Raspberry Pi GPU](https://github.com/raspberrypi/userland) that will be copied, configured, build and installed inside the chroot| diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index 8d1f576..148f0b7 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -31,7 +31,7 @@ if [ "$BUILD_KERNEL" = true ] ; then # Create temporary directory for kernel sources temp_dir=$(as_nobody mktemp -d) - # Fetch current RPi2/3 kernel sources + # Fetch current RPi2/3/4 kernel sources if [ -z "${KERNEL_BRANCH}" ] ; then as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux else @@ -883,4 +883,4 @@ else # BUILD_KERNEL=false cleanup exit 1 fi -fi \ No newline at end of file +fi diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 6278b50..5f0a4b9 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -20,7 +20,7 @@ if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then cp "${RPI_FIRMWARE_DIR}"/boot/fixup4x.dat "${BOOT_DIR}"/fixup4x.dat cp "${RPI_FIRMWARE_DIR}"/boot/start4cd.elf "${BOOT_DIR}"/start4cd.elf cp "${RPI_FIRMWARE_DIR}"/boot/start4db.elf "${BOOT_DIR}"/start4db.elf - cp "${RPI_FIRMWARE_DIR}"/boot/start4.elf "${BOOT_DIR}"/start4x.elf + cp "${RPI_FIRMWARE_DIR}"/boot/start4.elf "${BOOT_DIR}"/start4.elf cp "${RPI_FIRMWARE_DIR}"/boot/start4x.elf "${BOOT_DIR}"/start4x.elf else # Create temporary directory for boot binaries @@ -40,7 +40,7 @@ else as_nobody wget -q -O "${temp_dir}/fixup4x.dat" "${FIRMWARE_URL}/fixup4x.dat" as_nobody wget -q -O "${temp_dir}/start4cd.elf" "${FIRMWARE_URL}/start4cd.elf" as_nobody wget -q -O "${temp_dir}/start4db.elf" "${FIRMWARE_URL}/start4db.elf" - as_nobody wget -q -O "${temp_dir}/start4x.elf" "${FIRMWARE_URL}/start4x.elf" + as_nobody wget -q -O "${temp_dir}/start4.elf" "${FIRMWARE_URL}/start4.elf" as_nobody wget -q -O "${temp_dir}/start4x.elf" "${FIRMWARE_URL}/start4x.elf" # Move downloaded boot binaries @@ -266,7 +266,12 @@ echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" # Setup minimal GPU memory allocation size: 16MB (no X) if [ "$ENABLE_MINGPU" = true ] ; then - echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" + if [ "$ENABLE_GR_ACCEL" = false ] ; then + echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" + else + ### Cannot reduce memory if graphics acceleration is requested + echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" + fi fi # Setup boot with initramfs @@ -315,6 +320,19 @@ if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" fi +#Enable graphics acceleration for Model 4 +if [ "$RPI_MODEL" = 4 ] && [ "$ENABLE_GR_ACCEL" = true ] ; then + echo "max_framebuffers=2" >> "${BOOT_DIR}/config.txt" + echo "arm_64bit=1" >> "${BOOT_DIR}/config.txt" + echo "cmdline=cmdline.txt" >> "${BOOT_DIR}/config.txt" + echo "dtparam=audio=on" >> "${BOOT_DIR}/config.txt" + if [ "$ENABLE_MINGPU" = false ] ; then + echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" + fi + echo "dtoverlay=vc4-fkms-v3d, cma-128" >> "${BOOT_DIR}/config.txt" +fi + + # Install kernel modules blacklist mkdir -p "${ETC_DIR}/modprobe.d/" install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" diff --git a/bootstrap.d/42-fbturbo.sh b/bootstrap.d/42-fbturbo.sh index 0835552..828dbfc 100644 --- a/bootstrap.d/42-fbturbo.sh +++ b/bootstrap.d/42-fbturbo.sh @@ -5,7 +5,7 @@ # Load utility functions . ./functions.sh -if [ "$ENABLE_FBTURBO" = true ] ; then +if [ "$ENABLE_FBTURBO" = true ] && [ "$ENABLE_GR_ACCEL" = false ] ; then # Install c/c++ build environment inside the chroot chroot_install_cc diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 45a3a50..8ff4564 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -45,7 +45,7 @@ RPI_MODEL=${RPI_MODEL:=3P} # Debian release RELEASE=${RELEASE:=buster} if [ $RELEASE = "bullseye" ] ; then - RELEASE=testing + RELEASE=testing fi # Kernel Branch @@ -191,6 +191,7 @@ CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} ENABLE_UBOOT=${ENABLE_UBOOT:=false} UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} +ENABLE_GR_ACCEL=${ENABLE_GR_ACCEL:=true} FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} @@ -270,14 +271,14 @@ fi # Setup architecture specific settings if [ -n "$SET_ARCH" ] ; then - # 64-bit configuration + ## 64-bit configuration if [ "$SET_ARCH" = 64 ] ; then - # General 64-bit depended settings + ### General 64-bit depended settings QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} KERNEL_ARCH=${KERNEL_ARCH:=arm64} KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} - # Raspberry Pi model specific settings + ### Raspberry Pi model specific settings if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then if [ "$RPI_MODEL" != 4 ] ; then KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} @@ -289,20 +290,21 @@ if [ -n "$SET_ARCH" ] ; then RELEASE_ARCH=${RELEASE_ARCH:=arm64} KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} + else echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit" exit 1 fi fi - # 32-bit configuration + ## 32-bit configuration if [ "$SET_ARCH" = 32 ] ; then - # General 32-bit dependend settings + ### General 32-bit dependend settings QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} KERNEL_ARCH=${KERNEL_ARCH:=arm} KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} - # Raspberry Pi model specific settings + ### Raspberry Pi (0-1P) model specific settings if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} @@ -320,7 +322,7 @@ if [ -n "$SET_ARCH" ] ; then fi fi fi - # Raspberry Pi model specific settings + ### Raspberry Pi (2-4) model specific settings if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then if [ "$RPI_MODEL" != 4 ] ; then KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} @@ -377,17 +379,18 @@ case "$RPI_MODEL" in ;; esac -# Raspberry PI 0,3,3P with Bluetooth and Wifi onboard +# Raspberry PI 0,3,3P,4 with Bluetooth and Wifi onboard if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then - # Include bluetooth packages on supported boards + ## Include bluetooth packages on supported boards if [ "$ENABLE_BLUETOOTH" = true ] ; then APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez" fi if [ "$ENABLE_WIRELESS" = true ] ; then APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb,wpasupplicant" fi -else # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard - # Check if the internal wireless interface is not supported by the RPi model +# Raspberry PI 1,1P,2 without Wifi and bluetooth onboard +else + ## Check if the internal wireless interface is not supported by the RPi model if [ "$ENABLE_WIRELESS" = true ] || [ "$ENABLE_BLUETOOTH" = true ]; then echo "error: The selected Raspberry Pi model has no integrated interface for wireless or bluetooth" exit 1 @@ -506,7 +509,7 @@ if [ -n "$MISSING_PACKAGES" ] ; then read -r confirm [ "$confirm" != "y" ] && exit 1 - # Make sure all missing required packages are installed + ## Make sure all missing required packages are installed apt-get update && apt-get -qq -y install `echo "${MISSING_PACKAGES}" | sed "s/ //"` fi @@ -554,8 +557,8 @@ fi # Check if specified CHROOT_SCRIPTS directory exists if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then - echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" - exit 1 + echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" + exit 1 fi # Check if specified device mapping already exists (will be used by cryptsetup) @@ -649,12 +652,12 @@ fi # Replace selected packages with smaller clones if [ "$ENABLE_REDUCE" = true ] ; then - # Add levee package instead of vim-tiny + ## Add levee package instead of vim-tiny if [ "$REDUCE_VIM" = true ] ; then APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" fi - # Add dropbear package instead of openssh-server + ## Add dropbear package instead of openssh-server if [ "$REDUCE_SSHD" = true ] ; then APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" fi @@ -821,20 +824,21 @@ if [ "$ENABLE_SPLITFS" = true ] ; then dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" - # Write firmware/boot partition tables + ## Write firmware/boot partition tables sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null < /dev/null <