From ae455ff1f90781f70d7d3f44ed9a4f2796c5a19d 2018-11-18 07:37:30 From: Unknown Date: 2018-11-18 07:37:30 Subject: [PATCH] added testing support for zswap and kvm support --- diff --git a/bootstrap.d/13-kernel.sh b/bootstrap.d/13-kernel.sh index fd18094..e57b25e 100644 --- a/bootstrap.d/13-kernel.sh +++ b/bootstrap.d/13-kernel.sh @@ -82,6 +82,36 @@ if [ "$BUILD_KERNEL" = true ] ; then -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ "${KERNEL_DIR}/.config" fi + + # GPL v2.0 + #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh + if [ "$KERNEL_ZSWAP" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then + # enable ZSWAP support for better performance during large builds etc. + # requires activation via kernel parameter or sysfs + # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.) + # and e.g. https://wiki.archlinux.org/index.php/zswap for parameters etc. + + set_kernel_config ZPOOL y "${KERNEL_DIR}/.config" + set_kernel_config ZSWAP y "${KERNEL_DIR}/.config" + set_kernel_config ZBUD y "${KERNEL_DIR}/.config" + set_kernel_config Z3FOLD y "${KERNEL_DIR}/.config" + set_kernel_config ZSMALLOC y "${KERNEL_DIR}/.config" + set_kernel_config PGTABLE_MAPPING y "${KERNEL_DIR}/.config" + fi + + if [ "$KERNEL_VIRT" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then + # Submit PRs with edits targeting the _bottom_ of this file + # Please set modules where possible, rather than building in, and + # provide a short rationale comment for the changes made + + # enable basic KVM support; see e.g. + # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 + + set_kernel_config VIRTUALIZATION y "${KERNEL_DIR}/.config" + set_kernel_config KVM y "${KERNEL_DIR}/.config" + set_kernel_config VHOST_NET m "${KERNEL_DIR}/.config" + set_kernel_config VHOST_CROSS_ENDIAN_LEGACY y "${KERNEL_DIR}/.config" + fi if [ "$KERNELSRC_CONFIG" = true ] ; then # Load default raspberry kernel configuration @@ -242,17 +272,32 @@ if [ "$BUILD_KERNEL" = true ] ; then fi else # BUILD_KERNEL=false - echo " Install precompiled kernel..." - echo "error: not implemented" +# echo " Install precompiled kernel..." +# echo "error: not implemented" +if [ "$KERNEL_ARCH" = arm64 ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then + # Create temporary directory for dl + temp_dir=$(as_nobody mktemp -d) + + # Fetch kernel dl + as_nobody wget -c "$RPI3_64_KERNEL_URL" "${temp_dir}"/kernel.tar.xz + #extract download + tar -xJf kernel.tar.xz -C "${R}" + + # Remove temporary directory for kernel sources + rm -fr "${temp_dir}" + + # Set permissions of the kernel sources + chown -R root:root "${R}/boot" + chown -R root:root "${R}/lib" +fi + # Check if kernel installation was successful - VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)" - if [ -z "$VMLINUZ" ] ; then - echo "error: kernel installation failed! (/boot/vmlinuz-* not found)" + KERNEL="$(ls -1 "${R}"/boot/kernel* | sort | tail -n 1)" + if [ -z "$KERNEL" ] ; then + echo "error: kernel installation failed! (/boot/kernel* not found)" cleanup exit 1 fi - # Copy vmlinuz kernel to the boot directory - install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}" if [ "$SET_ARCH" = 64 ] ; then echo "Using precompiled arm64 kernel" diff --git a/functions.sh b/functions.sh index 8c52abd..7f6f719 100644 --- a/functions.sh +++ b/functions.sh @@ -79,3 +79,26 @@ chroot_remove_cc() { COMPILER_PACKAGES="" fi } +#GPL v2.0 +#https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh +# edited with thir param +#start +set_kernel_config() { + # flag as $1, value to set as $2, config must exist at "./.config" + local TGT="CONFIG_${1}" + local REP="${2//\//\\/}" + if grep -q "^${TGT}[^_]" .config; then + sed -i "s/^\(${TGT}=.*\|# ${TGT} is not set\)/${TGT}=${REP}/" "${3}" + else + echo "${TGT}=${2}" >> "${3}" + fi +} + +unset_kernel_config() { + # unsets flag with the value of $1, config must exist at "./.config" + local TGT="CONFIG_${1}" + sed -i "s/^${TGT}=.*/# ${TGT} is not set/" "${2}" +} +# +#end +# diff --git a/rpi23-gen-image.sh b/rpi23-gen-image.sh index 71b451d..db6ee6e 100755 --- a/rpi23-gen-image.sh +++ b/rpi23-gen-image.sh @@ -55,7 +55,12 @@ 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} +#BIS= Kernel has KVM and zswap enabled +RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} +#default bcmrpi3_defconfig target kernel +RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} +RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} #https://aur.archlinux.org/packages/pi-bluetooth/ BLUETOOTH_URL=${BLUETOOTH_URL:=https://aur.archlinux.org/pi-bluetooth.git} @@ -166,6 +171,8 @@ KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} KERNEL_CCACHE=${KERNEL_CCACHE:=false} +KERNEL_ZSWAP=${KERNEL_ZSWAP:=true} +KERNEL_VIRT=${KERNEL_VIRT:=true} # Kernel compilation from source directory settings KERNELSRC_DIR=${KERNELSRC_DIR:=""}