From 0a79ba1f3943bd20f19c1feae75fc18006fe59d4 2018-10-26 23:38:01 From: drtyhlpr Date: 2018-10-26 23:38:01 Subject: [PATCH] Merge pull request #140 from burnbabyburn/RPI3B DTB for all. Thanks to burnbabyburn! --- diff --git a/README.md b/README.md index 9e3c88c..14baf39 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,14 @@ A comma separated list of additional packages to be installed by apt after boots #### General system settings: ##### `RPI_MODEL`=2 -Specifiy the target Raspberry Pi hardware model. The script at this time supports the Raspberry Pi models `2` and `3`. `BUILD_KERNEL`=true will automatically be set if the Raspberry Pi model `3` is used. +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 +`1` = Used for Pi 1 model A and B +`1P` = Used for Pi 1 model B+ and A+ +`2` = Used for Pi 2 model B +`3` = Used for Pi 3 model B +`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. diff --git a/bootstrap.d/20-networking.sh b/bootstrap.d/20-networking.sh index 2229d72..ec0cfa0 100644 --- a/bootstrap.d/20-networking.sh +++ b/bootstrap.d/20-networking.sh @@ -30,10 +30,16 @@ install_readonly files/network/interfaces "${ETC_DIR}/network/interfaces" # Install configuration for interface eth0 install_readonly files/network/eth.network "${ETC_DIR}/systemd/network/eth.network" +# Install configuration for interface wl* +install_readonly files/network/wlan.network "${ETC_DIR}/systemd/network/wlan.network" + +#always with dhcp since wpa_supplicant integration is missing +sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/wlan.network" + if [ "$ENABLE_DHCP" = true ] ; then # Enable DHCP configuration for interface eth0 sed -i -e "s/DHCP=.*/DHCP=yes/" -e "/DHCP/q" "${ETC_DIR}/systemd/network/eth.network" - + # Set DHCP configuration to IPv4 only if [ "$ENABLE_IPV6" = false ] ; then sed -i "s/DHCP=.*/DHCP=v4/" "${ETC_DIR}/systemd/network/eth.network" @@ -55,10 +61,15 @@ fi # Remove empty settings from network configuration sed -i "/.*=\$/d" "${ETC_DIR}/systemd/network/eth.network" +# Remove empty settings from wlan configuration +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" fi @@ -85,23 +96,39 @@ fi # Download the firmware binary blob required to use the RPi3 wireless interface if [ "$ENABLE_WIRELESS" = true ] ; then if [ ! -d ${WLAN_FIRMWARE_DIR} ] ; then - mkdir -p ${WLAN_FIRMWARE_DIR} + mkdir -p ${WLAN_FIRMWARE_DIR} fi # Create temporary directory for firmware binary blob temp_dir=$(as_nobody mktemp -d) - # Fetch firmware binary blob + # Fetch firmware binary blob for RPI3B+ + if [ "$RPI_MODEL" = 3B ] ; then + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.bin" + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.txt" + as_nobody wget -q -O "${temp_dir}/brcmfmac43455-sdio.clm_blob" "${WLAN_FIRMWARE_URL}/brcmfmac43455-sdio.clm_blob" + else + # Fetch firmware binary blob for RPI3 as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.bin" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.bin" as_nobody wget -q -O "${temp_dir}/brcmfmac43430-sdio.txt" "${WLAN_FIRMWARE_URL}/brcmfmac43430-sdio.txt" - + fi + # Move downloaded firmware binary blob + if [ "$RPI_MODEL" = 3B ] ; then + mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" + else mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" - + fi + # Remove temporary directory for firmware binary blob rm -fr "${temp_dir}" # Set permissions of the firmware binary blob + if [ "$RPI_MODEL" = 3B ] ; then + chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* + chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* + else chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* + fi fi diff --git a/files/network/wlan.network b/files/network/wlan.network new file mode 100644 index 0000000..5f252c3 --- /dev/null +++ b/files/network/wlan.network @@ -0,0 +1,12 @@ +[Match] +Name=wlan0 + +[Network] +DHCP=no +Address= +Gateway= +DNS= +DNS= +Domains= +NTP= +NTP= diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index b235ed2..5ba4c19 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -42,10 +42,24 @@ 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} @@ -56,10 +70,19 @@ 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] +#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 + if [ "$RELEASE_ARCH" = "arm64" ] ; then QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} else @@ -207,9 +230,6 @@ CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} -# Stop the Crypto Wars -DISABLE_FBI=${DISABLE_FBI:=false} - # Chroot scripts directory CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} @@ -227,23 +247,36 @@ COMPILER_PACKAGES="" set +x # Set Raspberry Pi model specific configuration -if [ "$RPI_MODEL" = 2 ] ; then +elif [ "$RPI_MODEL" = 0 ] ; then + DTB_FILE=${RPI2_DTB_FILE} + UBOOT_CONFIG=${RPI2_UBOOT_CONFIG} +elif [ "$RPI_MODEL" = 1 ] ; then + DTB_FILE=${RPI2_DTB_FILE} + UBOOT_CONFIG=${RPI2_UBOOT_CONFIG} +elif [ "$RPI_MODEL" = 1P ] ; then + DTB_FILE=${RPI2_DTB_FILE} + UBOOT_CONFIG=${RPI2_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} BUILD_KERNEL=true +elif [ "$RPI_MODEL" = 3P ] ; then + DTB_FILE=${RPI3P_DTB_FILE} + UBOOT_CONFIG=${RPI3P_UBOOT_CONFIG} + BUILD_KERNEL=true else echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!" exit 1 fi # Check if the internal wireless interface is supported by the RPi model -if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" != 3 ] ; then +if [ "$ENABLE_WIRELESS" = true ] && [ "$RPI_MODEL" = 2 ]; then echo "error: The selected Raspberry Pi model has no internal wireless interface" exit 1 -fi +fi # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then @@ -277,15 +310,10 @@ if [ "$KERNEL_CCACHE" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" fi -# Stop the Crypto Wars -if [ "$DISABLE_FBI" = true ] ; then - ENABLE_CRYPTFS=true -fi - # Add cryptsetup package to enable filesystem encryption if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" - APT_INCLUDES="${APT_INCLUDES},cryptsetup" + APT_INCLUDES="${APT_INCLUDES},cryptsetup,console-setup" if [ -z "$CRYPTFS_PASSWORD" ] ; then echo "error: no password defined (CRYPTFS_PASSWORD)!"