From 486b4ea08ef20a34589440e1cda85d1f2fc796c7 2018-11-16 12:25:47 From: burnbabyburn Date: 2018-11-16 12:25:47 Subject: [PATCH] . --- diff --git a/README.md b/README.md index 98f2705..384bfd0 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ CONFIG_TEMPLATE=rpi2stretch ./rpi23-gen-image.sh ## Supported parameters and settings #### APT settings: -##### `APT_SERVER`="ftp.debian.org" +##### `APT_SERVER`="ftp.debian.org/debian" 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`="" diff --git a/bootstrap.d/10-bootstrap.sh b/bootstrap.d/10-bootstrap.sh index 1840e37..c4d229a 100644 --- a/bootstrap.d/10-bootstrap.sh +++ b/bootstrap.d/10-bootstrap.sh @@ -26,7 +26,7 @@ if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then fi # Base debootstrap (unpack only) -http_proxy=${APT_PROXY} debootstrap ${EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}/debian" +http_proxy=${APT_PROXY} debootstrap ${EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}" # Copy qemu emulator binary to chroot install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index 79a35e6..e077315 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -30,7 +30,7 @@ if [ "$BUILD_KERNEL" = true ] ; then else as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux fi - + # Copy downloaded kernel sources cp -r "${temp_dir}/linux/"* "${R}/usr/src/linux/" @@ -108,7 +108,7 @@ if [ "$BUILD_KERNEL" = true ] ; then echo "CONFIG_CRYPTO_CBC=y" echo "CONFIG_CRYPTO_XTS=y" echo "CONFIG_CRYPTO_SHA512=y" - echo "CONFIG_CRYPTO_MANAGER=y" + echo "CONFIG_CRYPTO_MANAGER=y" } >> "${KERNEL_DIR}"/.config fi fi @@ -172,6 +172,11 @@ if [ "$BUILD_KERNEL" = true ] ; then if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install fi +# make tar.gz kernel package - missing os bzw. modules +#** ** ** WARNING ** ** ** +#Your architecture did not define any architecture-dependent files +#to be placed into the tarball. Please add those to ./scripts/package/buildtar . +# make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" targz-pkg # Prepare boot (firmware) directory mkdir "${BOOT_DIR}" @@ -184,7 +189,7 @@ if [ "$BUILD_KERNEL" = true ] ; then # Prepare device tree directory mkdir "${BOOT_DIR}/overlays" - + # Ensure the proper .dtb is located if [ "$KERNEL_ARCH" = "arm" ] ; then for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do diff --git a/bootstrap.d/14-fstab.sh b/bootstrap.d/14-fstab.sh index 577d092..8d20dda 100644 --- a/bootstrap.d/14-fstab.sh +++ b/bootstrap.d/14-fstab.sh @@ -9,6 +9,11 @@ # 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" diff --git a/bootstrap.d/15-rpi-config.sh b/bootstrap.d/15-rpi-config.sh index 5333234..28ab98c 100644 --- a/bootstrap.d/15-rpi-config.sh +++ b/bootstrap.d/15-rpi-config.sh @@ -42,18 +42,26 @@ if [ "$BUILD_KERNEL" = true ] ; then 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" +if [ "$ENABLE_UBOOTUSB" = true ] ; then + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" else - CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" + 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" + else + CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" + fi fi + # Add encrypted root partition to cmdline.txt 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_UBOOTUSB" = 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 diff --git a/bootstrap.d/41-uboot.sh b/bootstrap.d/41-uboot.sh index 41b614a..a6f46b5 100644 --- a/bootstrap.d/41-uboot.sh +++ b/bootstrap.d/41-uboot.sh @@ -40,13 +40,8 @@ if [ "$ENABLE_UBOOT" = true ] ; then install_readonly "${R}/tmp/u-boot/u-boot.bin" "${BOOT_DIR}/u-boot.bin" printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> "${BOOT_DIR}/config.txt" - # Install and setup U-Boot command file - # Set correct KERNEL_IMAGE in mkfile - sed -i "s/kernel7.img/$KERNEL_BIN_IMAGE/g" files/boot/uboot.mkimage - # Set correct DTB_FILE - sed -i "s/bcm2709-rpi-2-b.dtb/$DTB_FILE/g" files/boot/uboot.mkimage install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage" - printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" + printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" if [ "$ENABLE_INITRAMFS" = true ] ; then # Convert generated initramfs for U-Boot using mkimage @@ -56,8 +51,9 @@ if [ "$ENABLE_UBOOT" = true ] ; then rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" # Configure U-Boot to load generated initramfs - printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" - printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" + printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage" + + fi else # ENABLE_INITRAMFS=false # Remove initramfs from U-Boot mkfile sed -i '/.*initramfs.*/d' "${BOOT_DIR}/uboot.mkimage" @@ -70,25 +66,31 @@ if [ "$ENABLE_UBOOT" = true ] ; then printf "\nbootz \${kernel_addr_r} - \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage" fi fi - + if [ "$SET_ARCH" = 64 ] ; then echo "Setting up config.txt to boot 64bit uboot" - printf "\n# Enable CPU 64 bit mode\narm_control=0x200\n" >> "${BOOT_DIR}/config.txt" - printf "\n# Tell u-boot a 64bit kernel is used\narm_64bit=1\n" >> "${BOOT_DIR}/config.txt" - printf "\n# Device tree start addr\ndevice_tree_address=0x100\n" >> "${BOOT_DIR}/config.txt" - printf "\n# Device tree stop adrr\ndevice_tree_end=0x8000\n" >> "${BOOT_DIR}/config.txt" + + printf "\n# 64bit-mode" >> "${BOOT_DIR}/config.txt" + printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md" >> "${BOOT_DIR}/config.txt" + printf "\narm_64bit=1" >> "${BOOT_DIR}/config.txt" + sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage" fi + if [ "$ENABLE_UBOOTUSB" = true ] ; then + sed -i "s|mmc|usb|g" "${BOOT_DIR}/uboot.mkimage" + fi + + # Set mkfile to use the correct mach id if [ "$ENABLE_QEMU" = true ] ; then sed -i "s/^\(setenv machid \).*/\10x000008e0/" "${BOOT_DIR}/uboot.mkimage" fi - + # Set mkfile to use the correct dtb file sed -i "s/^\(setenv dtbfile \).*/\1${DTB_FILE}/" "${BOOT_DIR}/uboot.mkimage" # Set mkfile to use kernel image - sed "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" + sed -i "s/^\(fatload mmc 0:1 \${kernel_addr_r} \).*/\1${KERNEL_IMAGE}/" "${BOOT_DIR}/uboot.mkimage" # Remove all leading blank lines sed -i "/./,\$!d" "${BOOT_DIR}/uboot.mkimage" diff --git a/files/apt/sources.list b/files/apt/sources.list index 31c4dbf..4a600dd 100644 --- a/files/apt/sources.list +++ b/files/apt/sources.list @@ -1,9 +1,8 @@ -deb http://ftp.debian.org/debian jessie main contrib -#deb-src http://ftp.debian.org/debian jessie main contrib - -deb http://ftp.debian.org/debian/ jessie-updates main contrib -#deb-src http://ftp.debian.org/debian/ jessie-updates main contrib - -#deb http://security.debian.org/ jessie/updates main contrib -#deb-src http://security.debian.org/ jessie/updates main contrib +# Debian packages for testing +deb http://mirror.united-gameserver.de/debian/ testing main contrib non-free +# Uncomment the deb-src line if you want 'apt-get source' +# to work with most packages. +deb-src http://mirror.united-gameserver.de/debian/ testing main contrib non-free +# Security updates for stable +# deb http://security.debian.org/ stable/updates main contrib non-free diff --git a/files/boot/uboot.mkimage b/files/boot/uboot.mkimage index 6ce6500..9dca77c 100644 --- a/files/boot/uboot.mkimage +++ b/files/boot/uboot.mkimage @@ -1,5 +1,5 @@ # Set device tree fdtfile -setenv dtbfile bcm2709-rpi-2-b.dtb +setenv dtbfile bcm2710-rpi-3-b.dtb # Tell Linux that it is booting on a Raspberry Pi2/3 setenv machid 0x00000c42 @@ -8,7 +8,8 @@ setenv machid 0x00000c42 saveenv # Load the existing Linux kernel into RAM -fatload mmc 0:1 ${kernel_addr_r} kernel7.img +mmc dev 0 +fatload mmc 0:1 ${kernel_addr_r} Image fatload mmc 0:1 ${fdt_addr_r} ${dtbfile} fatload mmc 0:1 ${ramdisk_addr_r} ${initramfs} diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 68cdca9..2b99b49 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -206,14 +206,17 @@ else RLS="$RELEASE" fi -rm "${ETC_DIR}/apt/sources.list" +if [ -f "$(pwd)/files/apt/sources.list" ] ; then +rm "$(pwd)/files/apt/sources.list" +fi if [ "$ENABLE_NONFREE" = true ] ; then - netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS" + netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" else - netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS" + netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" fi -APT_SERVER=$(grep -m 1 http /etc/apt/sources.list | cut -d ' ' -f 2) +APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) +APT_SERVER=${APT_SERVER::-1} #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