#@TYPE: Machine
#@NAME: QCS605-64
#@DESCRIPTION: Machine configuration for QTI QCS605 64bit

require conf/machine/include/qcs605.inc

KERNEL_IMAGETYPE = "Image.gz-dtb"

KERNEL_DTS_NAME = "qcs605"
KERNEL_BASE = "0x80000000"
KERNEL_TAGS_OFFSET = "0x81900000"

KERNEL_CONFIG = "${@['sdm670-perf_defconfig', 'sdm670_defconfig'][d.getVar('VARIANT', True) == ('' or 'debug')]}"

KERNEL_CMD_PARAMS = "console=ttyMSM0,115200n8 earlycon=msm_geni_serial,0xA90000 androidboot.hardware=qcom androidboot.console=ttyMSM0 video=vfb:640x400,bpp=32,memsize=3072000 msm_rtb.filter=0x237 ehci-hcd.park=3 lpm_levels.sleep_disabled=1 service_locator.enable=1 firmware_class.path=/lib/firmware/updates rootfstype=ext4"

# Run fsck at boot
KERNEL_CMD_PARAMS:append = " fsck.mode=force fsck.repair=yes "

# Remove console parameters and supress systemd logs for non-debug builds.
KERNEL_CMD_PARAMS:remove = "${@bb.utils.contains_any('VARIANT', 'perf user', 'console=ttyMSM0,115200n8', '', d)}"
KERNEL_CMD_PARAMS:remove = "${@bb.utils.contains_any('VARIANT', 'perf user', 'earlycon=msm_geni_serial,0xA90000', '', d)}"
KERNEL_CMD_PARAMS:remove = "${@bb.utils.contains_any('VARIANT', 'perf user', 'androidboot.console=ttyMSM0', '', d)}"
KERNEL_CMD_PARAMS:append = "${@bb.utils.contains_any('VARIANT', 'perf user', ' quiet systemd.log_target=null', '', d)}"

# readonly-rootfs
DISTRO_FEATURES:append = " ro-rootfs"

# Generate persist image
DISTRO_FEATURES += "persist-image"

# Use systemd init manager.
DISTRO_FEATURES:remove = "sysvinit"
DISTRO_FEATURES:append = " systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
VIRTUAL-RUNTIME_dev_manager = "udev"
VIRTUAL-RUNTIME_init_manager = "systemd"

#enable selinux
DISTRO_FEATURES:append = " selinux"
DEFAULT_ENFORCING = "enforcing"

#Enable dm-verity feature for non debug builds
DISTRO_FEATURES += "${@bb.utils.contains('DEBUG_BUILD', '1', '', 'dm-verity', d)}"

# enable audio as a loadable kernel module
DISTRO_FEATURES:append = " audio-dlkm"

# Change Image features for systemd.
IMAGE_DEV_MANAGER = "udev"
IMAGE_INIT_MANAGER = "systemd"
IMAGE_INITSCRIPTS = ""

# Disable journalling for RO rootfs. Set the block size to 1024.
IMAGE_EXT4_EXTRA_OPTIONS = "${@bb.utils.contains('DISTRO_FEATURES','ro-rootfs',' -J -b 4096 ','',d)}"

# Multilib configuration
# This sets any packages preprended with lib32- to be built with
# the armv7a tuning (32 bit) instead of 64 bit aarch.
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "armv7ahf-neon"
TARGET_VENDOR_virtclass-multilib-lib32="-oe"

QPERM_FILE_pn-start-script-ab-slot-util = "${bindir}/getslotsuffix:0:1000"
QPERM_FILE_pn-system-core = "${sysconfdir}/build.prop:5002:5002"
QPERM_FILE_pn-system-prop = "/build.prop:5002:5002"

# Enable coedump
SYSTEMD_ENABLE_COREDUMP = "1"
SYSTEMD_COREDUMP_PATH = "${userfsdatadir}/coredump"

#Uncomment to Enable SNPE wrapper compilation
#DISTRO_FEATURES += "snpe-enable"

#Enable TFlite wrapper compilation
DISTRO_FEATURES += "tflite-enable"
