diff --git a/tools/wltests/android/create_boot_img.sh b/tools/wltests/android/create_boot_img.sh index 951c4634dcc79ea5ebe5882be6421e8a48337791..e06d7c81bfaadb9d7e3a142373f4628c745ebc50 100755 --- a/tools/wltests/android/create_boot_img.sh +++ b/tools/wltests/android/create_boot_img.sh @@ -11,7 +11,8 @@ source "${DEFINITIONS_PATH}" DEFAULT_KERNEL="${KERNEL_SRC}/arch/${ARCH}/boot/${KERNEL_IMAGE}" KERNEL="${KERNEL:-$DEFAULT_KERNEL}" -DEFAULT_RAMDISK="${PLATFORM_OVERLAY_PATH}/${RAMDISK_IMAGE}" +# Don't append a path if no ramdisk image is provided +[ -z ${RAMDISK_IMAGE} ] || DEFAULT_RAMDISK="${PLATFORM_OVERLAY_PATH}/${RAMDISK_IMAGE}" RAMDISK="${RAMDISK:-$DEFAULT_RAMDISK}" DEFAULT_BOOT_IMAGE="${ARTIFACTS_PATH}/${ANDROID_BOOT_IMAGE}" @@ -23,7 +24,7 @@ if [ ! -f ${KERNEL} ] ; then c_error "KERNEL image not found: ${KERNEL}" exit $ENOENT fi -if [ ! -f ${RAMDISK} ] ; then +if [ ! -z ${RAMDISK} ] && [ ! -f ${RAMDISK} ] ; then c_error "RAMDISK image not found: ${RAMDISK}" c_warning "A valid ramdisk image, which matches the device user-space" c_warning "must be deployed by the user under the required path." @@ -41,7 +42,13 @@ c_info "Generate BOOT image:" c_info " $BOOT_IMAGE" c_info "using this configuration :" c_info " KERNEL : $KERNEL" + +if [ -z "{$RAMDISK}" ]; then +c_warning " No RAMDISK provided, building image without ramdisk" +else c_info " RAMDISK : $RAMDISK" +fi + c_info " CMDLINE : $CMDLINE" c_info " ANDROID_IMAGE_BASE : $ANDROID_IMAGE_BASE" c_info " ANDROID_IMAGE_PAGESIZE : $ANDROID_IMAGE_PAGESIZE" @@ -64,6 +71,10 @@ if [ "${ANDROID_RAMDISK_OFFSET}" ]; then ANDROID_RAMDISK_OFFSET="--ramdisk_offset ${ANDROID_RAMDISK_OFFSET}" fi +if [ ! -z "${RAMDISK}" ]; then + RAMDISK_CMD="--ramdisk \"${RAMDISK}\"" +fi + ################################################################################ # Generate BOOT image ################################################################################ @@ -74,7 +85,7 @@ mkdir -p $(dirname $BOOT_IMAGE) &>/dev/null set -x "${ANDROID_SCRIPTS_PATH}/mkbootimg" \ --kernel "${KERNEL}" \ - --ramdisk "${RAMDISK}" \ + $RAMDISK_CMD \ --cmdline "${CMDLINE}" \ --base "${ANDROID_IMAGE_BASE}" \ --pagesize "${ANDROID_IMAGE_PAGESIZE}" \ @@ -85,4 +96,3 @@ set -x ${ANDROID_RAMDISK_OFFSET} \ --output "${BOOT_IMAGE}" set +x - diff --git a/tools/wltests/build b/tools/wltests/build index 8b4771f3355ab73482b632759f1b3250e54b2fde..c972e1b010dc76d4a28fd94da47ef43ae9a19051 100755 --- a/tools/wltests/build +++ b/tools/wltests/build @@ -46,14 +46,14 @@ usage() { -s, --savedefconfig make savedefconfig -t, --dtbs make dtbs -x, --clean_all make distclean, remove toolchain - --modules make modules - --modules_install make modules_install to INSTALL_MOD_PATH - --dtbo_image make dtbo.img + --modules make modules + --modules_install make modules_install to INSTALL_MOD_PATH + --dtbo_image make dtbo.img -a, --use-ccache prepend 'ccache' to CROSS_COMPILE -k, --keepconfig keep exiting .config, i.e. no other config is applied -l, --config_list merge this list of CONFIGs - --silent report only error/warning messages + --silent report only error/warning messages -h, --help print help and exit @@ -190,6 +190,7 @@ c_info "Platform configuration:" c_info " PLATFORM_NAME : ${PLATFORM_NAME}" c_info " DEFCONFIG : ${DEFCONFIG}" c_info " CONFIG_CMD : ${CONFIG_CMD}" +c_info " BUILD_FLAGS : ${BUILD_FLAGS}" c_info " ARCH : ${ARCH}" c_info " CROSS_COMPILE : ${CROSS_COMPILE}" c_info " MODULES_INSTALL_DIR : ${INSTALL_MOD_PATH}" @@ -255,7 +256,7 @@ fi if [ ! -z "${DEFCONFIG}" ] && [ "${MAKE_KEEPCONFIG}" -eq $NO ]; then c_info "Running DEFCONFIG [$DEFCONFIG]..." - (set -x; cd "${KERNEL_SRC}"; make ${DEFCONFIG}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} ${DEFCONFIG}) fi if [ ! -z "${BUILD_CONFIG_LIST}" ]; then @@ -272,7 +273,7 @@ if [ ! -z "${BUILD_CONFIG_LIST}" ]; then .config ${tmp_file}) else c_error "No merge_config.sh script found" - exit $ENOENT + exit $ENOENT fi rm -f ${tmp_file} c_info "Running oldconfig after merge of configs" @@ -287,49 +288,48 @@ fi if [ ${BUILD_IMAGE} -eq $YES ]; then c_info "Making [Image]..." - (set -x; cd "${KERNEL_SRC}"; make -j${NCPUS} "$KERNEL_IMAGE" >${OUT}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} -j${NCPUS} "${KERNEL_IMAGE}" >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${BUILD_DTBS} -eq $YES ]; then c_info "Making [dtbs]..." - (set -x; cd "${KERNEL_SRC}"; make -j${NCPUS} dtbs >${OUT}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} -j${NCPUS} dtbs >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${BUILD_DTBO_IMAGE} -eq $YES ]; then c_info "Making [dtbo.img]..." - (set -x; cd "${KERNEL_SRC}"; make -j${NCPUS} dtbo.img >${OUT}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} -j${NCPUS} dtbo.img >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${BUILD_MODULES} -eq $YES ]; then c_info "Making [modules]..." - (set -x; cd "${KERNEL_SRC}"; make -j${NCPUS} modules >${OUT}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} -j${NCPUS} modules >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${BUILD_MODULES_INSTALL} -eq $YES ]; then c_info "Making [modules_install] to [${INSTALL_MOD_PATH}] ..." - (set -x; cd "${KERNEL_SRC}"; make -j${NCPUS} modules_install >${OUT}) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} -j${NCPUS} modules_install >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${MAKE_MENUCONFIG} -eq $YES ]; then c_info "Making [menuconfig]..." - (set -x; cd "${KERNEL_SRC}"; make menuconfig) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} menuconfig) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${MAKE_SAVEDEFCONFIG} -eq $YES ]; then c_info "Making [savedefconfig]..." - (set -x; cd "${KERNEL_SRC}"; make savedefconfig) + (set -x; cd "${KERNEL_SRC}"; make ${BUILD_FLAGS} savedefconfig) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi if [ ${BUILD_NOW} -eq $YES ]; then c_info "Making default target..." - (set -x; cd "${KERNEL_SRC}" make -j${NCPUS} >${OUT}) + (set -x; cd "${KERNEL_SRC}" make ${BUILD_FLAGS} -j${NCPUS} >${OUT}) ERROR=$?; [ $ERROR -eq 0 ] || exit $ERROR fi - diff --git a/tools/wltests/platforms/.gitignore b/tools/wltests/platforms/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..47d312f1cea7581b0d749e481086ef9b39505891 --- /dev/null +++ b/tools/wltests/platforms/.gitignore @@ -0,0 +1,2 @@ +*.img +*.gz diff --git a/tools/wltests/platforms/akari_android-v4.9/build_images b/tools/wltests/platforms/akari_android-v4.9/build_images new file mode 100755 index 0000000000000000000000000000000000000000..3e14910ae7963fa601d79334b6b357aeaf842a55 --- /dev/null +++ b/tools/wltests/platforms/akari_android-v4.9/build_images @@ -0,0 +1,107 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname $(realpath -s $0)) +BASE_DIR="$SCRIPT_DIR/../.." +source "${BASE_DIR}/helpers" +source "${PLATFORM_PATH}/definitions" + +PREBUILT_ERR_MSG="\ +It can be found at \ +https://android.googlesource.com/platform/prebuilts/misc/+/master/\ +" + +################################################################################ +# Utils +################################################################################ + +check_device_info() { + ERR_MSG="\ +Update the 'definitions' file if needed, but be aware that the values must \ +be in sync with the userspace currently flashed on the device or it won't boot\ +" + if [[ -z "$ANDROID_OS_VERSION" ]]; then + c_error "Could not read Android version from device" + c_error "$ERR_MSG" + exit $FATAL_ERROR + elif [[ -z "$ANDROID_OS_PATCH_LEVEL" ]]; then + c_error "Could not read Android patch level from device" + c_error "$ERR_MSG" + exit $FATAL_ERROR + fi +} + +load_dependencies() { + if [ ! -z "$AOSP_PREBUILTS" ]; then + export DTC_EXT="$AOSP_PREBUILTS"/misc/linux-x86/dtc/dtc + export DTC_OVERLAY_TEST_EXT="$AOSP_PREBUILTS"/misc/linux-x86/libufdt/ufdt_apply_overlay + export MKDTIMG="$AOSP_PREBUILTS"/misc/linux-x86/libufdt/mkdtimg + + # Check for required tools being available + for var in DTC_EXT DTC_OVERLAY_TEST_EXT MKDTIMG; do + if [[ ! -f "${!var}" ]]; then + c_error "Could not find tool ${!var}" + c_error "Please ensure your prebuilts directory is intact" + c_error "$PREBUILT_ERR_MSG" + exit $FATAL_ERROR + fi + done + else + c_warning "\$AOSP_PREBUILTS not set" + c_warning "Please set it to your AOSP prebuilts directory" + c_warning "$PREBUILT_ERR_MSG" + c_warning "Trying to find tools from your \$PATH instead..." + + export DTC_EXT=$(which dtc) + export DTC_OVERLAY_TEST_EXT=$(which ufdt_apply_overlay) + export MKDTIMG=$(which mkdtimg) + + # Check for required tools being available + for var in DTC_EXT DTC_OVERLAY_TEST_EXT MKDTIMG; do + if [[ -z ${!var} ]]; then + c_error "Could not find all required tools" + exit $FATAL_ERROR + fi + done + fi +} + +################################################################################ +# Build all images required to test a new kernel +################################################################################ + +check_device_info +load_dependencies + +c_info "Cleaning ${ARTIFACTS_PATH}..." +rm -rf ${ARTIFACTS_PATH} + +export KCFLAGS=-mno-android +export KBUILD_DIFFCONFIG=akari_diffconfig + +# The kernel is riddled with +# #include +# that should really be +# #include "something.h" +# since those are local driver header files. +# (see https://github.com/sonyxperiadev/kernel-copyleft/tree/51.1.A.2.xxx) +# +# As a tempfix, just use an outputdir +OUTDIR="$ARTIFACTS_PATH/kernel_build" +IMG_PATH=arch/arm64/boot/"${KERNEL_IMAGE}" +export BUILD_FLAGS="CONFIG_BUILD_ARM64_DT_OVERLAY=y O=${OUTDIR}" + +./build --clean_all --image --silent; ERROR=$? +[ $ERROR -eq 0 ] || exit $ERROR + +# Move the image back to where create_boot_img.sh expects it +cp "${OUTDIR}"/"${IMG_PATH}" "${KERNEL_SRC}"/"${IMG_PATH}" + +./android/create_boot_img.sh; ERROR=$? +[ $ERROR -eq 0 ] || exit $ERROR + +DTBO_FILES="$(find $OUTDIR/arch/arm64/boot/dts -name '*.dtbo')" +"$MKDTIMG" create "$ARTIFACTS_PATH"/dtbo.img --page_size=4096 $DTBO_FILES; ERROR=$? +if [ -z $ERROR ]; then + c_error "" + exit $ERROR +fi diff --git a/tools/wltests/platforms/akari_android-v4.9/definitions b/tools/wltests/platforms/akari_android-v4.9/definitions new file mode 100644 index 0000000000000000000000000000000000000000..fda98577ff61dc3d936e69de9eba5869887cfce6 --- /dev/null +++ b/tools/wltests/platforms/akari_android-v4.9/definitions @@ -0,0 +1,55 @@ +################################################################################ +# Build definitions for the Xperia XZ2 (Akari - suitable for H8216/H8266/H8296) +################################################################################ + +PLATFORM_NAME="Akari" + +################################################################################ +# Boot Image Configuration +################################################################################ + +KERNEL_IMAGE="${KERNEL_IMAGE:-Image.gz-dtb}" +KERNEL_CMDLINE="${KERNEL_CMDLINE:-\ + androidboot.hardware=qcom\ + video=vfb:640x400,bpp=32,memsize=3072000\ + msm_rtb.filter=0x237\ + ehci-hcd.park=3\ + lpm_levels.sleep_disabled=1\ + service_locator.enable=1\ + swiotlb=2048\ + androidboot.configfs=true\ + androidboot.usbcontroller=a600000.dwc3\ + zram.backend=z3fold\ + msm_drm.dsi_display0=dsi_panel_cmd_display:config0\ + buildvariant=userdebug +}" + +ANDROID_BOOT_IMAGE="${ANDROID_BOOT_IMAGE:-boot.img}" +ANDROID_IMAGE_BASE="${ANDROID_IMAGE_BASE:-0x0}" +ANDROID_IMAGE_PAGESIZE="${ANDROID_IMAGE_PAGESIZE:-4096}" + +# Sensitive bits, manually replace if needed +ANDROID_OS_VERSION="${ANDROID_OS_VERSION:-}" +ANDROID_OS_PATCH_LEVEL="${ANDROID_OS_PATCH_LEVEL:-}" + +ANDROID_TAGS_OFFSET="${ANDROID_TAGS_OFFSET:-0x00000100}" +ANDROID_KERNEL_OFFSET="${ANDROID_KERNEL_OFFSET:-0x00008000}" + +# No ramdisk +RAMDISK_IMAGE="" + +################################################################################ +# Device Tree Configuration +################################################################################ + +# ANDROID_DTB_IMAGE="${ANDROID_DTB_IMAGE:-dts.img}" +# ANDROID_DTB_COMPRESSED="${ANDROID_DTB_COMPRESSED:-YES}" + +################################################################################ +# Toolchain Configuration +################################################################################ + +DEFCONFIG="${DEFCONFIG:-sdm845-perf_defconfig}" +CONFIG_CMD="${CONFIG_CMD:-}" +ARCH="${ARCH:-arm64}" +CROSS_COMPILE="${CROSS_COMPILE:-aarch64-linux-android-}" diff --git a/tools/wltests/platforms/akari_android-v4.9/flash_images b/tools/wltests/platforms/akari_android-v4.9/flash_images new file mode 100755 index 0000000000000000000000000000000000000000..d8948a9aa02638ee57a64e3e5518e98fb31bb99e --- /dev/null +++ b/tools/wltests/platforms/akari_android-v4.9/flash_images @@ -0,0 +1,27 @@ +#!/bin/bash + +SCRIPT_DIR=$(dirname $(realpath -s $0)) +BASE_DIR="$SCRIPT_DIR/../.." +source "${BASE_DIR}/helpers" +source "${PLATFORM_PATH}/definitions" + +MODE=${1:-FASTBOOT} +[ $MODE == FASTBOOT ] || exit $OK + +################################################################################ +# Build all images required to test a new kernel +################################################################################ + +ls *.img >/dev/null; ERROR=$? +if [ $ERROR -ne 0 ]; then + c_error "No images to flash in $PWD" + exit $ENOENT +fi + +for IMAGE in $(ls *.img); do + PARTITION=${IMAGE%%.img} + echo + c_info "Flashing [$IMAGE] on [$PARTITION] partition..." + $FASTBOOT flash $PARTITION $IMAGE; ERROR=$? + [ $ERROR -eq 0 ] || exit $ERROR +done diff --git a/tools/wltests/test_series b/tools/wltests/test_series index 2826248d477a262fa673c8b0f52e0d4b67ea1310..6aff7071821605511d51f5bf73fa930755d2cd4d 100755 --- a/tools/wltests/test_series +++ b/tools/wltests/test_series @@ -804,7 +804,7 @@ match_sha1() { # It may happen that a tag pointing to a given commit has # a different SHA1 (signed tag), so check if this this is - # the case. + # the case. TAG_NAME=$(git -C $KERNEL_SRC describe --exact-match $COMMIT_SHA1 2>/dev/null) || return $EAGAIN TAG_SHA1=$(git -C $KERNEL_SRC show-ref --hash $TAG_NAME) c_info " CommitID of local repo corresponds to tag: $TAG_NAME" @@ -893,6 +893,16 @@ test_sha1() { echo c_info "Check current kernel..." if device_in_adb; then + DEVICE_OS_VERSION=$($ADB shell getprop ro.build.version.release) + DEVICE_OS_PATCH_LEVEL=$($ADB shell getprop ro.build.version.security_patch) + + export ANDROID_OS_VERSION=${ANDROID_OS_VERSION:-$DEVICE_OS_VERSION} + export ANDROID_OS_PATCH_LEVEL=${ANDROID_OS_PATCH_LEVEL:-$DEVICE_OS_PATCH_LEVEL} + + echo + c_info "Android version : $ANDROID_OS_VERSION" + c_info "Security patch level : $ANDROID_OS_PATCH_LEVEL" + match_sha1 $COMMIT_SHA1 if [ $? -ne $OK ]; then c_info "Kernel update required!" @@ -1022,4 +1032,3 @@ done 10<$SELECTED_LIST report d_notify "Tests completed!" face-cool -