From 8bda66042adbc366a1bc25042b9e14b6af9cb42b 2018-12-16 21:53:00 From: Unknown Date: 2018-12-16 21:53:00 Subject: [PATCH] USBBOOT is Back Now working with and without uboot --- diff --git a/bootstrap.d/14-fstab.sh b/bootstrap.d/14-fstab.sh index 4ecba25..35683a0 100644 --- a/bootstrap.d/14-fstab.sh +++ b/bootstrap.d/14-fstab.sh @@ -8,11 +8,6 @@ # Install and setup fstab install_readonly files/mount/fstab "${ETC_DIR}/fstab" -if [ "$ENABLE_UBOOTUSB" = true ] ; then - sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab" - sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab" -fi - # Add usb/sda disk root partition to fstab if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab" @@ -28,11 +23,19 @@ if [ "$ENABLE_CRYPTFS" = true ] ; then echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab" if [ "$ENABLE_SPLITFS" = true ] ; then - # Add usb/sda disk to crypttab + # Add usb/sda1 disk to crypttab sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab" fi fi +if [ "$ENABLE_USBBOOT" = true ] ; then + sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab" + sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab" + + # Add usb/sda2 disk to crypttab + sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab" +fi + # Generate initramfs file if [ "$ENABLE_INITRAMFS" = true ] ; then if [ "$ENABLE_CRYPTFS" = true ] ; then diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 4510e83..25ffa35 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -39,10 +39,14 @@ else 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 init=/bin/systemd" +if [ "$ENABLE_USBBOOT" = true ] ; then + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait 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 init=/bin/systemd" + if [ "$ENABLE_SPLITFS" = true ] ; then + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" + else + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline console=tty1 rootwait init=/bin/systemd" + fi fi # Add encrypted root partition to cmdline.txt @@ -50,7 +54,11 @@ if [ "$ENABLE_CRYPTFS" = true ] ; then if [ "$ENABLE_SPLITFS" = true ] ; then CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") else - CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") + if [ "$ENABLE_USBBOOT" = true ] ; then + CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") + else + CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") + fi fi fi @@ -59,6 +67,11 @@ if [ "$ENABLE_PRINTK" = true ] ; then install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf" fi +# Enable Kernel messages on standard output +if [ "$KERNEL_SECURITY" = true ] ; then + install_readonly files/sysctl.d/84-rpi-ASLR.conf "${ETC_DIR}/sysctl.d/84-rpi-ASLR.conf" +fi + # Install udev rule for serial alias - serial0 = console serial1=bluetooth install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules" diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh index e81dcd9..56fca4e 100644 --- a/bootstrap.d/41-uboot.sh +++ b/bootstrap.d/41-uboot.sh @@ -79,7 +79,7 @@ if [ "$ENABLE_UBOOT" = true ] ; then fi # instead of sd, boot from usb device - if [ "$ENABLE_UBOOTUSB" = true ] ; then + if [ "$ENABLE_USBBOOT" = true ] ; then sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" fi diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 247af3a..503c364 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -158,7 +158,7 @@ ENABLE_MINBASE=${ENABLE_MINBASE:=false} ENABLE_REDUCE=${ENABLE_REDUCE:=false} ENABLE_UBOOT=${ENABLE_UBOOT:=false} UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} -ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} +ENABLE_USBBOOT=${ENABLE_USBBOOT=false} ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=false} ENABLE_NEXMON=${ENABLE_NEXMON:=false} @@ -325,17 +325,6 @@ case "$RPI_MODEL" in ;; esac -if [ "$ENABLE_UBOOTUSB" = true ] ; then - if [ "$ENABLE_UBOOT" = false ] ; then - echo "error: Enabling UBOOTUSB requires u-boot to be enabled" - exit 1 - fi - if [ "$RPI_MODEL" != 3 ] || [ "$RPI_MODEL" != 3P ] ; then - echo "error: Enabling UBOOTUSB requires Raspberry 3" - exit 1 - fi -fi - # Raspberry PI 0,3,3P with Bluetooth and Wifi onboard if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then # Include bluetooth packages on supported boards @@ -421,6 +410,13 @@ if [ "$ENABLE_UBOOT" = true ] ; then APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" fi +if [ "$ENABLE_USBBOOT" = true ] ; then + 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 +fi + # Check if root SSH (v2) public key file exists if [ -n "$SSH_ROOT_PUB_KEY" ] ; then if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then