From 6de379addaa0dd4f78656c85e6ddf3f4d961dbcb 2018-11-21 15:37:40 From: burnbabyburn <2515038+burnbabyburn@users.noreply.github.com> Date: 2018-11-21 15:37:40 Subject: [PATCH] Merge pull request #6 from drtyhlpr/master remerge --- diff --git a/README.md b/README.md index b232d33..e97b491 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # rpi23-gen-image ## Introduction -`rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `jessie`, `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 64-bit images can be generated using custom configuration parameters (```templates/rpi3-stretch-arm64-4.11.y```). +`rpi23-gen-image.sh` is an advanced Debian Linux bootstrapping shell script for generating Debian OS images for Raspberry Pi 2 (RPi2) and Raspberry Pi 3 (RPi3) computers. The script at this time supports the bootstrapping of the Debian (armhf) releases `stretch` and `buster`. Raspberry Pi 3 images are generated for 32-bit mode only. Raspberry Pi 3 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. @@ -9,16 +9,7 @@ The following list of Debian packages must be installed on the build system beca It is recommended to configure the `rpi23-gen-image.sh` script to build and install the latest Raspberry Pi Linux kernel. For the RPi3 this is mandatory. Kernel compilation and linking will be performed on the build system using an ARM (armhf) cross-compiler toolchain. -The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux `jessie` and `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information. - -If a Debian Linux `jessie` build system is used it will be required to add the [Debian Cross-toolchains repository](http://emdebian.org/tools/debian/) first: - -``` -echo "deb http://emdebian.org/tools/debian/ jessie main" > /etc/apt/sources.list.d/crosstools.list -sudo -u nobody wget -O - http://emdebian.org/tools/debian/emdebian-toolchain-archive.key | apt-key add - -dpkg --add-architecture armhf -apt-get update -``` +The script has been tested using the default `crossbuild-essential-armhf` toolchain meta package on Debian Linux `stretch` build systems. Please check the [Debian CrossToolchains Wiki](https://wiki.debian.org/CrossToolchains) for further information. ## Command-line parameters The script accepts certain command-line parameters to enable or disable specific OS features, services and configuration settings. These parameters are passed to the `rpi23-gen-image.sh` script via (simple) shell-variables. Unlike environment shell-variables (simple) shell-variables are defined at the beginning of the command-line call of the `rpi23-gen-image.sh` script. @@ -55,7 +46,7 @@ CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh Set Debian packages server address. Choose a server from the list of Debian worldwide [mirror sites](https://www.debian.org/mirror/list). Using a nearby server will probably speed-up all required downloads within the bootstrapping process. ##### `APT_PROXY`="" -Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once. +Set Proxy server address. Using a local Proxy-Cache like `apt-cacher-ng` will speed-up the bootstrapping process because all required Debian packages will only be downloaded from the Debian mirror site once. If `apt-cacher-ng` is running on default `http://127.0.0.1:3142` it is autodetected and you don't need to set this. ##### `APT_INCLUDES`="" A comma separated list of additional packages to be installed by debootstrap during bootstrapping. @@ -66,6 +57,10 @@ A comma separated list of additional packages to be installed by apt after boots --- #### General system settings: +##### `SET_ARCH`=32 +Set Architecture to default 32bit. If you want to to compile 64bit (RPI3 or RPI3+) set it to `64`. This option will set every needed crosscompiler or boeard specific option for a successful build. +If you want to change e.g. cross-compiler -> Templates always override defaults + ##### `RPI_MODEL`=2 Specifiy the target Raspberry Pi hardware model. The script at this time supports the following Raspberry Pi models: `0` = Used for Raspberry Pi 0 and Raspberry Pi 0 W @@ -76,8 +71,8 @@ Specifiy the target Raspberry Pi hardware model. The script at this time support `3P` = Used for Pi 3 model B+ `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` or `3P` is used. -##### `RELEASE`="jessie" -Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases "jessie", "stretch" and "buster". `BUILD_KERNEL`=true will automatically be set if the Debian releases `stretch` or `buster` are used. +##### `RELEASE`="buster" +Set the desired Debian release name. The script at this time supports the bootstrapping of the Debian releases `stretch` and `buster`. ##### `RELEASE_ARCH`="armhf" Set the desired Debian release architecture. @@ -255,7 +250,7 @@ Path to a directory with scripts that should be run in the chroot before the ima Create an initramfs that that will be loaded during the Linux startup process. `ENABLE_INITRAMFS` will automatically get enabled if `ENABLE_CRYPTFS`=true. This parameter will be ignored if `BUILD_KERNEL`=false. ##### `ENABLE_IFNAMES`=true -Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. This parameter is only supported if the Debian releases `stretch` or `buster` are used. +Enable automatic assignment of predictable, stable network interface names for all local Ethernet, WLAN interfaces. This might create complex and long interface names. ##### `DISABLE_UNDERVOLT_WARNINGS`= Disable RPi2/3 under-voltage warnings and overlays. Setting the parameter to `1` will disable the warning overlay. Setting it to `2` will additionally allow RPi2/3 turbo mode when low-voltage is present. @@ -281,8 +276,8 @@ Add SSH (v2) public key(s) from specified file to `authorized_keys` file to enab --- #### Kernel compilation: -##### `BUILD_KERNEL`=false -Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used. +##### `BUILD_KERNEL`=true +Build and install the latest RPi2/3 Linux kernel. Currently only the default RPi2/3 kernel configuration is used. ##### `CROSS_COMPILE`="arm-linux-gnueabihf-" This sets the cross compile enviornment for the compiler. @@ -453,13 +448,13 @@ After the image file was successfully created by the `rpi23-gen-image.sh` script ##### Flashing examples: ```shell -bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie.img /dev/mmcblk0 -dd bs=4M if=./images/jessie/2017-01-23-rpi3-jessie.img of=/dev/mmcblk0 +bmaptool copy ./images/buster/2017-01-23-rpi3-buster.img /dev/mmcblk0 +dd bs=4M if=./images/buster/2017-01-23-rpi3-buster.img of=/dev/mmcblk0 ``` If you have set `ENABLE_SPLITFS`, copy the `-frmw` image on the microSD card, then the `-root` one on the USB drive: ```shell -bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-frmw.img /dev/mmcblk0 -bmaptool copy ./images/jessie/2017-01-23-rpi3-jessie-root.img /dev/sdc +bmaptool copy ./images/buster/2017-01-23-rpi3-buster-frmw.img /dev/mmcblk0 +bmaptool copy ./images/buster/2017-01-23-rpi3-buster-root.img /dev/sdc ``` ## QEMU emulation @@ -483,10 +478,6 @@ Start QEMU full system emulation with cryptfs, initramfs and output to console: qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 -kernel kernel7.img -no-reboot -dtb vexpress-v2p-ca15_a7.dtb -sd ${IMAGE_NAME}.qcow2 -initrd "initramfs-${KERNEL_VERSION}" -append "root=/dev/mapper/secure cryptdevice=/dev/mmcblk0p2:secure rw rootfstype=ext4 console=ttyAMA0,115200 init=/bin/systemd" -serial stdio ``` -## Weekly image builds -The image files are provided by JRWR'S I/O PORT and are built once a Sunday at midnight UTC! -* [Debian Stretch Raspberry Pi2/3 Weekly Image Builds](https://jrwr.io/doku.php?id=projects:debianpi) - ## External links and references * [Debian worldwide mirror sites](https://www.debian.org/mirror/list) * [Debian Raspberry Pi 2 Wiki](https://wiki.debian.org/RaspberryPi2) diff --git a/bootstrap.d/10-bootstrap.sh b/bootstrap.d/10-bootstrap.sh index 8776997..d8cfb69 100644 --- a/bootstrap.d/10-bootstrap.sh +++ b/bootstrap.d/10-bootstrap.sh @@ -19,7 +19,7 @@ if [ "$ENABLE_MINBASE" = true ] ; then fi # Base debootstrap (unpack only) -http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" +http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" # Copy qemu emulator binary to chroot install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" diff --git a/bootstrap.d/11-apt.sh b/bootstrap.d/11-apt.sh index f511f43..b833dfa 100644 --- a/bootstrap.d/11-apt.sh +++ b/bootstrap.d/11-apt.sh @@ -12,28 +12,12 @@ if [ -z "$APT_PROXY" ] ; then fi if [ "$BUILD_KERNEL" = false ] ; then - # Install APT pinning configuration for flash-kernel package - install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel" - - # Install APT sources.list - install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list" - echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list" - - # Upgrade collabora package index and install collabora keyring - chroot_exec apt-get -qq -y update - chroot_exec apt-get -qq -y --allow-unauthenticated install collabora-obs-archive-keyring -else # BUILD_KERNEL=true - # Install APT sources.list - install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list" - - # Use specified APT server and release - sed -i "s/\/ftp.debian.org\//\/${APT_SERVER}\//" "${ETC_DIR}/apt/sources.list" - sed -i "s/ jessie/ ${RELEASE}/" "${ETC_DIR}/apt/sources.list" -fi - -# Allow the installation of non-free Debian packages -if [ "$ENABLE_NONFREE" = true ] ; then - sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list" + echo "Downloading precompiled kernel" + echo "error: not configured" + exit 1; +# BUILD_KERNEL=true +else + echo "No precompiled kernel repositories were added" fi # Upgrade package index and update all installed packages and changed dependencies diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 8b1bc3b..6c93cf6 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -42,9 +42,9 @@ fi # Setup firmware boot cmdline if [ "$ENABLE_SPLITFS" = true ] ; then - CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" else - CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd" fi # Add encrypted root partition to cmdline.txt @@ -73,11 +73,6 @@ else CMDLINE="${CMDLINE} net.ifnames=1" fi -# Set init to systemd if required by Debian release -if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - CMDLINE="${CMDLINE} init=/bin/systemd" -fi - # Install firmware boot cmdline echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" diff --git a/bootstrap.d/20-networking.sh b/bootstrap.d/20-networking.sh index d53b78b..f92e76d 100644 --- a/bootstrap.d/20-networking.sh +++ b/bootstrap.d/20-networking.sh @@ -7,11 +7,11 @@ # Install and setup hostname install_readonly files/network/hostname "${ETC_DIR}/hostname" -sed -i "s/^rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hostname" +sed -i "s/^RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hostname" # Install and setup hosts install_readonly files/network/hosts "${ETC_DIR}/hosts" -sed -i "s/rpi2-jessie/${HOSTNAME}/" "${ETC_DIR}/hosts" +sed -i "s/RaspberryPI/${HOSTNAME}/" "${ETC_DIR}/hosts" # Setup hostname entry with static IP if [ "$NET_ADDRESS" != "" ] ; then @@ -65,13 +65,12 @@ sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network" sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/wlan.network" # Move systemd network configuration if required by Debian release -if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" - if [ "$ENABLE_WIRELESS" = true ] ; then - mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network" - fi - rm -fr "${ETC_DIR}/systemd/network" +mv -v "${ETC_DIR}/systemd/network/eth.network" "${LIB_DIR}/systemd/network/10-eth.network" +# If WLAN is enabled copy wlan configuration too +if [ "$ENABLE_WIRELESS" = true ] ; then + mv -v "${ETC_DIR}/systemd/network/wlan.network" "${LIB_DIR}/systemd/network/11-wlan.network" fi +rm -fr "${ETC_DIR}/systemd/network" # Enable systemd-networkd service chroot_exec systemctl enable systemd-networkd diff --git a/bootstrap.d/21-firewall.sh b/bootstrap.d/21-firewall.sh index d078ba1..e6033c4 100644 --- a/bootstrap.d/21-firewall.sh +++ b/bootstrap.d/21-firewall.sh @@ -11,9 +11,7 @@ if [ "$ENABLE_IPTABLES" = true ] ; then # make sure iptables-legacy is the used alternatives #iptables-save and -restore are slaves of iptables and thus are set accordingly - if ! [ "$RELEASE" = jessie ] ; then - chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy - fi + chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy # Install iptables systemd service install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service" diff --git a/bootstrap.d/42-fbturbo.sh b/bootstrap.d/42-fbturbo.sh index a5ede42..0835552 100644 --- a/bootstrap.d/42-fbturbo.sh +++ b/bootstrap.d/42-fbturbo.sh @@ -28,11 +28,7 @@ if [ "$ENABLE_FBTURBO" = true ] ; then fi # Install Xorg build dependencies - if [ "$RELEASE" = "jessie" ] ; then - chroot_exec apt-get -q -y --no-install-recommends install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev - elif [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev - fi + chroot_exec apt-get -q -y --no-install-recommends --allow-unauthenticated install xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev # Build and install fbturbo driver inside chroot chroot_exec /bin/bash -x <<'EOF' diff --git a/bootstrap.d/99-reduce.sh b/bootstrap.d/99-reduce.sh index 25ec9fe..9576bd6 100644 --- a/bootstrap.d/99-reduce.sh +++ b/bootstrap.d/99-reduce.sh @@ -46,12 +46,8 @@ if [ "$ENABLE_REDUCE" = true ] ; then # Replace bash shell by dash shell (experimental) if [ "$REDUCE_BASH" = true ] ; then - if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash - else - echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --force-yes bash - fi - + # Purge bash and update alternatives + echo "Yes, do as I say!" | chroot_exec apt-get purge -qq -y --allow-remove-essential bash chroot_exec update-alternatives --install /bin/bash bash /bin/dash 100 fi @@ -60,11 +56,6 @@ if [ "$ENABLE_REDUCE" = true ] ; then chroot_exec apt-get -qq -y purge alsa-utils libsamplerate0 libasound2 libasound2-data fi - # Re-install tools for managing kernel modules - if [ "$RELEASE" = "jessie" ] ; then - chroot_exec apt-get -qq -y install module-init-tools - fi - # Remove GPU kernels if [ "$ENABLE_MINGPU" = true ] ; then rm -f "${BOOT_DIR}/start.elf" diff --git a/files/network/hostname b/files/network/hostname index 03a61be..b20bbc3 100644 --- a/files/network/hostname +++ b/files/network/hostname @@ -1 +1 @@ -rpi2-jessie +RaspberryPI diff --git a/files/network/hosts b/files/network/hosts index 360cae7..3ae0878 100644 --- a/files/network/hosts +++ b/files/network/hosts @@ -1,5 +1,5 @@ 127.0.0.1 localhost -127.0.1.1 rpi2-jessie +127.0.1.1 RaspberryPI ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes diff --git a/functions.sh b/functions.sh index 8c52abd..6ee31da 100644 --- a/functions.sh +++ b/functions.sh @@ -63,12 +63,8 @@ chroot_install_cc() { # Install c/c++ build environment inside the chroot if [ -z "${COMPILER_PACKAGES}" ] ; then COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') - - if [ "$RELEASE" = "jessie" ] ; then - chroot_exec apt-get -q -y --no-install-recommends install ${COMPILER_PACKAGES} - elif [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} - fi + # Install COMPILER_PACKAGES in chroot + chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} fi } diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 7bb82c1..d4a4190 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -1,9 +1,8 @@ #!/bin/sh - ######################################################################## # rpi23-gen-image.sh 2015-2017 # -# Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3 +# Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3 # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -43,57 +42,10 @@ set -x # Raspberry Pi model configuration RPI_MODEL=${RPI_MODEL:=2} -#bcm2708-rpi-0-w.dtb (Used for Pi 0 and PI 0W) -RPI0_DTB_FILE=${RPI0_DTB_FILE:=bcm2708-rpi-0-w.dtb} -RPI0_UBOOT_CONFIG=${RPI0_UBOOT_CONFIG:=rpi_defconfig} - -#bcm2708-rpi-b.dtb (Used for Pi 1 model A and B) -RPI1_DTB_FILE=${RPI1_DTB_FILE:=bcm2708-rpi-b.dtb} -RPI1_UBOOT_CONFIG=${RPI1_UBOOT_CONFIG:=rpi_defconfig} - -#bcm2708-rpi-b-plus.dtb (Used for Pi 1 model B+ and A+) -RPI1P_DTB_FILE=${RPI1P_DTB_FILE:=bcm2708-rpi-b-plus.dtb} -RPI1P_UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG:=rpi_defconfig} - -#bcm2709-rpi-2-b.dtb (Used for Pi 2 model B) -RPI2_DTB_FILE=${RPI2_DTB_FILE:=bcm2709-rpi-2-b.dtb} -RPI2_UBOOT_CONFIG=${RPI2_UBOOT_CONFIG:=rpi_2_defconfig} - -#bcm2710-rpi-3-b.dtb (Used for Pi 3 model B) -RPI3_DTB_FILE=${RPI3_DTB_FILE:=bcm2710-rpi-3-b.dtb} -RPI3_UBOOT_CONFIG=${RPI3_UBOOT_CONFIG:=rpi_3_32b_defconfig} - -#bcm2710-rpi-3-b-plus.dtb (Used for Pi 3 model B+) -RPI3P_DTB_FILE=${RPI3P_DTB_FILE:=bcm2710-rpi-3-b-plus.dtb} -RPI3P_UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG:=rpi_3_32b_defconfig} - # Debian release -RELEASE=${RELEASE:=jessie} -KERNEL_ARCH=${KERNEL_ARCH:=arm} -RELEASE_ARCH=${RELEASE_ARCH:=armhf} -CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} -COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2} -if [ "$KERNEL_ARCH" = "arm64" ] ; then - KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} - KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} -fi - -if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then -#RASPBERRY PI 1, PI ZERO, PI ZERO W, AND COMPUTE MODULE DEFAULT Kernel BUILD CONFIGURATION - KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} - KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} -else -#RASPBERRY PI 2, PI 3, PI 3+, AND COMPUTE MODULE 3 DEFAULT Kernel BUILD CONFIGURATION -#https://www.raspberrypi.org/documentation/linux/kernel/building.md - KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} - KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} -fi +RELEASE=${RELEASE:=buster} -if [ "$RELEASE_ARCH" = "arm64" ] ; then - QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} -else - QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} -fi +#Kernel Branch KERNEL_BRANCH=${KERNEL_BRANCH:=""} # URLs @@ -103,7 +55,7 @@ WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-no COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} -VIDEOCORE_URL=${VIDEOCORE_URL=https://github.com/raspberrypi/userland} +VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} # Build directories @@ -130,6 +82,7 @@ WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} # General settings +SET_ARCH=${SET_ARCH:=32} HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} PASSWORD=${PASSWORD:=raspberry} USER_PASSWORD=${USER_PASSWORD:=raspberry} @@ -204,7 +157,7 @@ ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} # Kernel compilation settings -BUILD_KERNEL=${BUILD_KERNEL:=false} +BUILD_KERNEL=${BUILD_KERNEL:=true} KERNEL_REDUCE=${KERNEL_REDUCE:=false} KERNEL_THREADS=${KERNEL_THREADS:=1} KERNEL_HEADERS=${KERNEL_HEADERS:=true} @@ -213,12 +166,6 @@ KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} KERNEL_CCACHE=${KERNEL_CCACHE:=false} -if [ "$KERNEL_ARCH" = "arm64" ] ; then - KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} -else - KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} -fi - # Kernel compilation from source directory settings KERNELSRC_DIR=${KERNELSRC_DIR:=""} KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} @@ -247,7 +194,7 @@ CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} # Packages required in the chroot build environment APT_INCLUDES=${APT_INCLUDES:=""} -APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils" +APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" #Packages to exclude from chroot build environment APT_EXCLUDES=${APT_EXCLUDES:=""} @@ -266,36 +213,113 @@ if [ "$ENABLE_SYSVINIT" = false ] ; then APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" fi -# Set Raspberry Pi model specific configuration -if [ "$RPI_MODEL" = 0 ] ; then - DTB_FILE=${RPI0_DTB_FILE} - UBOOT_CONFIG=${RPI0_UBOOT_CONFIG} -elif [ "$RPI_MODEL" = 1 ] ; then - DTB_FILE=${RPI1_DTB_FILE} - UBOOT_CONFIG=${RPI1_UBOOT_CONFIG} -elif [ "$RPI_MODEL" = 1P ] ; then - DTB_FILE=${RPI1P_DTB_FILE} - UBOOT_CONFIG=${RPI1P_UBOOT_CONFIG} -elif [ "$RPI_MODEL" = 2 ] ; then - DTB_FILE=${RPI2_DTB_FILE} - UBOOT_CONFIG=${RPI2_UBOOT_CONFIG} -elif [ "$RPI_MODEL" = 3 ] ; then - DTB_FILE=${RPI3_DTB_FILE} - UBOOT_CONFIG=${RPI3_UBOOT_CONFIG} -elif [ "$RPI_MODEL" = 3P ] ; then - DTB_FILE=${RPI3P_DTB_FILE} - UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG} +#Check if apt-cacher-ng has its default port open on and set APT_PROXY +if [ -n "$(lsof -i :3142)" ] ; then +HTTP_PROXY=http://127.0.0.1:3142/ +fi + +#make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go! +if [ -n "$SET_ARCH" ] ; then + echo "Setting Architecture specific settings" + ################################## + # 64 bit config + ################################## + if [ "$SET_ARCH" = 64 ] ; then + echo "64 bit mode selected - Setting up enviroment" + # 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"} + + if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} + 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 and 3B+ support 64bit" + exit 1 + fi + fi + + ################################## + # 32 bit config + ################################## + if [ "$SET_ARCH" = 32 ] ; then + echo "32 bit mode selected - Setting up enviroment" + #General 32bit configuration + QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} + KERNEL_ARCH=${KERNEL_ARCH:=arm} + KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} + + #Raspberry setting grouped by board compability + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then + echo "Setting settings for bcm2835 Raspberry PI boards" + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} + RELEASE_ARCH=${RELEASE_ARCH:=armel} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} + CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} + fi + if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then + echo "Setting settings for bcm2837 Raspberry PI boards" + REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" + KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} + RELEASE_ARCH=${RELEASE_ARCH:=armhf} + KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} + CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} + fi + fi +#SET_ARCH not set else - echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!" + echo "error: Please set '32' or '64' as value for SET_ARCH" exit 1 fi -# Check if the internal wireless interface is supported by the RPi model -if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]); then + #Device specific configuration and uboot-config + echo "Select DTB-File" + case "$RPI_MODEL" in + 0) + 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} + ;; + 1P) + 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} + ;; + 3) + 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} + ;; + *) + echo "error: Raspberry Pi model $RPI_MODEL is not supported!" + exit 1 + ;; + esac + echo "$DTB_FILE selected" - echo "error: The selected Raspberry Pi model has no internal wireless interface" - exit 1 -fi +# Check if the internal wireless interface is supported by the RPi model +if [ "$ENABLE_WIRELESS" = true ] ; then + if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then + echo "error: The selected Raspberry Pi model has no internal wireless interface" + exit 1 + else + echo "Raspberry Pi $RPI_MODEL has WIFI support" + fi +fi # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then @@ -305,26 +329,6 @@ if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then fi fi -# Build RPi2/3 Linux kernel if required by Debian release -if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then - BUILD_KERNEL=true -fi - -# Add packages required for kernel cross compilation -if [ "$BUILD_KERNEL" = true ] ; then - if [ "$KERNEL_ARCH" = "arm" ] ; then - if [ "$RELEASE_ARCH" = "armel" ]; then - REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" - fi - if [ "$RELEASE_ARCH" = "armhf" ]; then - REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" - fi - fi - if [ "$RELEASE_ARCH" = "arm64" ]; then - REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" - fi -fi - if [ "$ENABLE_VIDEOCORE" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" fi @@ -358,7 +362,7 @@ fi # Add device-tree-compiler required for building the U-Boot bootloader if [ "$ENABLE_UBOOT" = true ] ; then - APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex" + APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" fi # Check if root SSH (v2) public key file exists @@ -470,11 +474,6 @@ if [ "$ENABLE_MINBASE" = true ] ; then APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" fi -# Add required locales packages -if [ "$DEFLOCAL" != "en_US.UTF-8" ] || ([ -n XKB_MODEL ] || [ -n XKB_LAYOUT ] || [ -n XKB_VARIANT ] || [ -n XKB_OPTIONS ]); then - APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" -fi - # Add parted package, required to get partprobe utility if [ "$EXPANDROOT" = true ] ; then APT_INCLUDES="${APT_INCLUDES},parted" @@ -537,10 +536,6 @@ if [ "$ENABLE_REDUCE" = true ] ; then fi fi -if [ "$RELEASE" != "jessie" ] ; then - APT_INCLUDES="${APT_INCLUDES},libnss-systemd" -fi - # Configure kernel sources if no KERNELSRC_DIR if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then KERNELSRC_CONFIG=true @@ -590,11 +585,6 @@ fi # Remove c/c++ build environment from the chroot chroot_remove_cc -# Remove apt-utils -if [ "$RELEASE" = "jessie" ] ; then - chroot_exec apt-get purge -qq -y --force-yes apt-utils -fi - # Generate required machine-id MACHINE_ID=$(dbus-uuidgen) echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"