From 1fe79547704ec67e65127b36be9f0bf512b93f29 2018-11-24 01:59:48 From: Unknown Date: 2018-11-24 01:59:48 Subject: [PATCH] Enable_Bluetooth var - enable_bluetooth var - merged if's in networking.sh --- diff --git a/README.md b/README.md index 9cd5f4c..9ba0fcd 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,6 @@ Set the IP address for the second NTP server. #### Basic system features: ##### `ENABLE_CONSOLE`=true Enable serial console interface. Recommended if no monitor or keyboard is connected to the RPi2/3. In case of problems fe. if the network (auto) configuration failed - the serial console can be used to access the system. -On `RPI_MODEL= 0,3,3P` - Bluetooth gets auto enabled if `ENABLE_CONSOLE` and `ENABLE_UBOOT` are set to `false` ##### `ENABLE_I2C`=false Enable I2C interface on the RPi2/3. Please check the [RPi2/3 pinout diagrams](https://elinux.org/RPi_Low-level_peripherals) to connect the right GPIO pins. @@ -174,6 +173,9 @@ Allow the installation of non-free Debian packages that do not comply with the D ##### `ENABLE_WIRELESS`=false Download and install the [closed-source firmware binary blob](https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm) that is required to run the internal wireless interface of the Raspberry Pi model `3`. This parameter is ignored if the specified `RPI_MODEL` is not `3`. +##### `ENABLE_BLUETOOTH`=false +Enable Bluetooth interface on the RPi0/3. + ##### `ENABLE_RSYSLOG`=true If set to false, disable and uninstall rsyslog (so logs will be available only in journal files) diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 91e16e1..387c3ed 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -94,44 +94,46 @@ if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" - else - # Create temporary directory for Bluetooth sources - temp_dir=$(as_nobody mktemp -d) + fi +fi - # Fetch Bluetooth sources - as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" +if [ "$ENABLE_BLUETOOTH" = true ] ; then + # Create temporary directory for Bluetooth sources + temp_dir=$(as_nobody mktemp -d) - # Copy downloaded sources - mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" + # Fetch Bluetooth sources + as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" - # Raspberry-sys-mod package for /dev/serial device needed by bluetooth service - as_nobody wget -q -O "${R}/tmp/pi-bluetooth/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules - # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ - as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth - as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth + # Copy downloaded sources + mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" - # Set permissions - chown -R root:root "${R}/tmp/pi-bluetooth" + # Raspberry-sys-mod package for /dev/serial device needed by bluetooth service + as_nobody wget -q -O "${R}/tmp/pi-bluetooth/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules + # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/ + as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth + as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth - # Install tools - install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" - install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" + # Set permissions + chown -R root:root "${R}/tmp/pi-bluetooth" - # Install bluetooth udev rule - install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" + # Install tools + install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" + install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" - # Install Firmware Flash file and apropiate licence - mkdir "${ETC_DIR}/firmware/" - install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" - install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" - install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" - install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" - # Install udev rule for bluetooth device - install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules" + # Install bluetooth udev rule + install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" + + # Install Firmware Flash file and apropiate licence + mkdir "${ETC_DIR}/firmware/" + install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" + install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" + install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service" + install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service" + # Install udev rule for bluetooth device + install_readonly "${R}/tmp/pi-bluetooth/99-com.rules" "${ETC_DIR}/udev/rules.d/99-com.rules" - # Remove temporary directory - rm -fr "${temp_dir}" - fi + # Remove temporary directory + rm -fr "${temp_dir}" fi # Create firmware configuration and cmdline symlinks diff --git a/bootstrap.d/20-networking.sh b/bootstrap.d/20-networking.sh index 3ca9f60..3aca05f 100644 --- a/bootstrap.d/20-networking.sh +++ b/bootstrap.d/20-networking.sh @@ -107,28 +107,26 @@ if [ "$ENABLE_WIRELESS" = true ] ; 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" + + # Move downloaded firmware binary blob + mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" + + # Set permissions of the firmware binary blob + chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* + chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then # 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" = 3P ] ; then - mv "${temp_dir}/brcmfmac43455-sdio."* "${WLAN_FIRMWARE_DIR}/" - elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then - mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" + + # Move downloaded firmware binary blob + mv "${temp_dir}/brcmfmac43430-sdio."* "${WLAN_FIRMWARE_DIR}/" + + # Set permissions of the firmware binary blob + chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* + chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* fi # Remove temporary directory for firmware binary blob rm -fr "${temp_dir}" - - # Set permissions of the firmware binary blob - if [ "$RPI_MODEL" = 3P ] ; then - chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* - chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43455-sdio."* - elif [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 0 ] ; then - chown root:root "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* - chmod 600 "${WLAN_FIRMWARE_DIR}/brcmfmac43430-sdio."* - fi fi diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index bdef916..e313f9e 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -106,6 +106,7 @@ APT_PROXY=${APT_PROXY:=""} APT_SERVER=${APT_SERVER:="ftp.debian.org"} # Feature settings +ENABLE_BLUETOOTH=${ENABLE_BLUETOOTH:=false} ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} ENABLE_I2C=${ENABLE_I2C:=false} ENABLE_SPI=${ENABLE_SPI:=false} @@ -352,6 +353,14 @@ if [ "$ENABLE_UBOOT" = true ] ; then APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" fi +if [ "$ENABLE_BLUETOOTH" = true ] ; then + if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then + if [ "$ENABLE_CONSOLE" = false ] ; then + APT_INCLUDES="${APT_INCLUDES},bluetooth,bluez" + fi + fi +fi + # Check if root SSH (v2) public key file exists if [ -n "$SSH_ROOT_PUB_KEY" ] ; then if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then