From 3332c4bc43915fb5b891f68f49e0352ed0dc83d6 2023-02-24 16:59:20 From: g-vidal Date: 2023-02-24 16:59:20 Subject: [PATCH] Merge branch 'contribGV' of http://depot.tremplin.ens-lyon.fr/Raspi2-3_GenImage into contribGV --- diff --git a/README.md b/README.md index 77d4f91..215ce6a 100644 --- a/README.md +++ b/README.md @@ -207,7 +207,11 @@ 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| +<<<<<<< HEAD |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| +======= +|ENABLE_GR_ACCEL|boolean|true|`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` and installed for Raspberry4 only. +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 |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| @@ -399,6 +403,6 @@ qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no * [Official Raspberry Pi Firmware on github](https://github.com/raspberrypi/firmware) * [Official Raspberry Pi Kernel on github](https://github.com/raspberrypi/linux) * [U-BOOT git repository](https://git.denx.de/?p=u-boot.git;a=summary) -* [Xorg DDX driver fbturbo](https://github.com/ssvb/xf86-video-fbturbo) +* [Xorg DDX driver #FFFFFF#FFFFFF#FFFFFF](https://github.com/ssvb/xf86-video-fbturbo) * [RPi3 Wireless interface firmware](https://github.com/RPi-Distro/firmware-nonfree/tree/master/brcm) * [Collabora RPi2 Kernel precompiled](https://repositories.collabora.co.uk/debian/) diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index 148f0b7..e3a438a 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -141,11 +141,10 @@ if [ "$BUILD_KERNEL" = true ] ; then #set_kernel_config CONFIG_MMC_SDHCI_IPROC n #set_kernel_config CONFIG_USB_DWC2 n #sed -i "s|depends on MMC_BCM2835_MMC && MMC_BCM2835_DMA|depends on MMC_BCM2835_MMC|" "${KERNEL_DIR}"/drivers/mmc/host/Kconfig - #VLAN got disabled without reason in arm64bit set_kernel_config CONFIG_IPVLAN m fi - + # enable ZSWAP see https://askubuntu.com/a/472227 or https://wiki.archlinux.org/index.php/zswap if [ "$KERNEL_ZSWAP" = true ] ; then set_kernel_config CONFIG_ZPOOL y @@ -156,7 +155,7 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_PGTABLE_MAPPING y set_kernel_config CONFIG_LZO_COMPRESS y fi - + if [ "$RPI_MODEL" = 4 ] ; then # Following are set in current 32-bit LPAE kernel set_kernel_config CONFIG_CGROUP_PIDS y @@ -362,7 +361,7 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_PCIE_BRCMSTB y set_kernel_config CONFIG_BCM2835_MMC y - # Snap needs squashfs. The ubuntu eoan-preinstalled-server image at + # Snap needs squashfs. The ubuntu eoan-preinstalled-server image at # http://cdimage.ubuntu.com/ubuntu-server/daily-preinstalled/current/ uses snap # during cloud-init setup at first boot. Without this the login accounts are not # created and the user can not login. @@ -404,10 +403,10 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_SLAB_FREELIST_RANDOM=y set_kernel_config CONFIG_SLAB_FREELIST_HARDENED=y set_kernel_config CONFIG_MMU_NOTIFIER y - + # erratum set_kernel_config ARM64_ERRATUM_834220 y - + # https://sourceforge.net/p/kvm/mailman/message/18440797/ set_kernel_config CONFIG_PREEMPT_NOTIFIERS y fi @@ -471,7 +470,7 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_SYSTEM_TRUSTED_KEYS m set_kernel_config CONFIG_SYSTEM_EXTRA_CERTIFICATE_SIZE 4096 fi - + if [ "$ENABLE_CRYPTFS" = true ] ; then set_kernel_config CONFIG_EMBEDDED y set_kernel_config CONFIG_EXPERT y @@ -625,7 +624,7 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_NF_TABLES_BRIDGE y set_kernel_config CONFIG_NF_CT_NETLINK_TIMEOUT m set_kernel_config CONFIG_NFT_OSF m - + fi # Enables BPF syscall for systemd-journald see https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 or https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA @@ -637,7 +636,7 @@ if [ "$BUILD_KERNEL" = true ] ; then set_kernel_config CONFIG_XDP_SOCKETS y fi - # KERNEL_DEFAULT_GOV was set by user + # KERNEL_DEFAULT_GOV was set by user if [ "$KERNEL_DEFAULT_GOV" != ondemand ] && [ -n "$KERNEL_DEFAULT_GOV" ] ; then case "$KERNEL_DEFAULT_GOV" in performance) @@ -811,16 +810,16 @@ else # BUILD_KERNEL=false temp_dir=$(as_nobody mktemp -d) # Fetch kernel dl - as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" + as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" fi if [ "$SET_ARCH" = 64 ] && [ "$RPI_MODEL" = 4 ] ; then # Create temporary directory for dl temp_dir=$(as_nobody mktemp -d) # Fetch kernel dl - as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL" + as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI4_64_KERNEL_URL" fi - + #extract download tar -xJf "${temp_dir}"/kernel.tar.xz -C "${temp_dir}" diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 5f0a4b9..12877f5 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -265,6 +265,7 @@ fi echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" # Setup minimal GPU memory allocation size: 16MB (no X) +<<<<<<< HEAD if [ "$ENABLE_MINGPU" = true ] ; then if [ "$ENABLE_GR_ACCEL" = false ] ; then echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" @@ -272,6 +273,10 @@ if [ "$ENABLE_MINGPU" = true ] ; then ### Cannot reduce memory if graphics acceleration is requested echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" fi +======= +if [ "$ENABLE_MINGPU" = true ] && [ "$ENABLE_GR_ACCEL" = false ] ; then + echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 fi # Setup boot with initramfs @@ -315,6 +320,17 @@ if [ "$ENABLE_SPI" = true ] ; then fi 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" + echo "gpu_mem=128" >> "${BOOT_DIR}/config.txt" + echo "dtoverlay=vc4-fkms-v3d, cma-128" >> "${BOOT_DIR}/config.txt" +fi + + # Disable RPi2/3 under-voltage warnings if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index f516e5a..285e4df 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -42,9 +42,15 @@ set -x # Raspberry Pi model configuration defaults to 3P RPI_MODEL=${RPI_MODEL:=3P} +<<<<<<< HEAD # Debian release defaults to bullseye RELEASE=${RELEASE:=bullseye} if [ "$RELEASE" = "bookworm" ] ; then +======= +# Debian release +RELEASE=${RELEASE:=buster} +if [ $RELEASE = "bullseye" ] ; then +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 RELEASE=testing fi echo "Debian release value used : " $RELEASE @@ -280,7 +286,11 @@ if [ -n "$SET_ARCH" ] ; then KERNEL_ARCH=${KERNEL_ARCH:=arm64} KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} +<<<<<<< HEAD ### Raspberry Pi model specific settings +======= + ### Raspberry Pi 64-bit model specific settings +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 4 ] ; then if [ "$RPI_MODEL" != 4 ] ; then KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} @@ -292,7 +302,11 @@ if [ -n "$SET_ARCH" ] ; then RELEASE_ARCH=${RELEASE_ARCH:=arm64} KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} +<<<<<<< HEAD +======= + +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 else echo "error: Only Raspberry PI 3, 3B+ and 4 support 64-bit" exit 1 @@ -313,25 +327,32 @@ if [ -n "$SET_ARCH" ] ; then RELEASE_ARCH=${RELEASE_ARCH:=armel} KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} +<<<<<<< HEAD if [ $ENABLE_XORG = true ] ; then if [$RELEASE = "stretch" ] || [$RELEASE = "oldstable" ] ; then printf "\nBest support for armel architecture is provided under Debian stretch/oldstable. Choose yes to change release to Debian stretch[y/n] " read -r confirm +======= + if [ $ENABLE_XORG = true ] ; then + if [$RELEASE = "stretch" ] || [$RELEASE = "oldstable" ] ; then + printf "\nBest support for armel architecture is provided under Debian stretch/oldstable. Choose yes to change release to Debian stretch[y/n] " + read -r confirm +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 if [ "$confirm" = "y" ] ; then - $RELEASE = "stretch" - fi - fi - fi + $RELEASE = "stretch" + fi + fi + fi fi ### 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} - KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} else KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2711_defconfig} - KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7l.img} fi REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" @@ -340,7 +361,8 @@ if [ -n "$SET_ARCH" ] ; then CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} fi fi -# SET_ARCH not set + + # SET_ARCH not set else echo "error: Please set '32' or '64' as value for SET_ARCH" exit 1 @@ -348,37 +370,37 @@ fi # Device specific configuration and U-Boot configuration case "$RPI_MODEL" in 0) - DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; 1) - DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; 1P) - DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} + ;; 2) - DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} + ;; 3) - DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} + ;; 3P) - DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} + ;; 4) - DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb} - UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig} - ;; + DTB_FILE=${DTB_FILE:=bcm2711-rpi-4-b.dtb} + UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_4_defconfig} + ;; *) - echo "error: Raspberry Pi model $RPI_MODEL is not supported!" - exit 1 - ;; + echo "error: Raspberry Pi model $RPI_MODEL is not supported!" + exit 1 + ;; esac # Raspberry PI 0,3,3P,4 with Bluetooth and Wifi onboard @@ -390,8 +412,13 @@ if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$ if [ "$ENABLE_WIRELESS" = true ] ; then APT_INCLUDES="${APT_INCLUDES},wireless-tools,crda,wireless-regdb,wpasupplicant" fi +<<<<<<< HEAD # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard else +======= + # Raspberry PI 1,1P,2 without Wifi and bluetooth onboard +else +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 ## 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" @@ -445,7 +472,7 @@ if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup,cryptsetup-initramfs" - # If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package + ## If cryptfs,dropbear and initramfs are enabled include dropbear-initramfs package if [ "$CRYPTFS_DROPBEAR" = true ] && [ "$ENABLE_INITRAMFS" = true ]; then APT_INCLUDES="${APT_INCLUDES},dropbear-initramfs" fi @@ -468,10 +495,17 @@ if [ "$ENABLE_UBOOT" = true ] ; then fi if [ "$ENABLE_USBBOOT" = true ] ; then +<<<<<<< HEAD if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P" exit 1 fi +======= +if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 2 ]; then + echo "error: Booting from USB alone is only supported by Raspberry Pi 3 and 3P" + exit 1 +fi +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 fi # Check if root SSH (v2) public key file exists @@ -706,7 +740,7 @@ fi # Execute custom scripts inside the chroot if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" - chroot_exec /bin/bash -x <<'EOF' + chroot_exec /bin/bash -x << EOF for SCRIPT in /chroot_scripts/* ; do if [ -f $SCRIPT -a -x $SCRIPT ] ; then $SCRIPT @@ -826,6 +860,7 @@ 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}" +<<<<<<< HEAD ## Write firmware/boot partition tables sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null < /dev/null < /dev/null << EOM +${TABLE_SECTORS},${FRMW_SECTORS},c,* +EOM + + # Write root partition table + sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null << EOM +>>>>>>> 7588b4f62cfa955de0822acf49908044e0504249 ${TABLE_SECTORS},${ROOT_SECTORS},83 EOM @@ -845,7 +889,7 @@ else dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" # Write partition table - sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null < /dev/null << EOM ${TABLE_SECTORS},${FRMW_SECTORS},c,* ${ROOT_OFFSET},${ROOT_SECTORS},83 EOM