#@TYPE: Machine
#@DESCRIPTION: Machine configuration for QTI nf-64
require conf/machine/include/qcs40x.inc
# TARGET TO SUPPORT 64-bit kernel
DISTRO = "qsap"

#boot image
BOOTIMAGE_TARGET = "boot.img"

#EXT4 FILES NAME
CACHEIMAGE_TARGET    = "cache.img"
PERSISTIMAGE_TARGET  = "persist.img"
RECOVERYIMAGE_TARGET = "recoveryfs.img"
SYSTEMIMAGE_TARGET   = "system.img"
SYSTEMRWIMAGE_TARGET = "systemrw.img"
USERDATAIMAGE_TARGET = "usrdata.img"

#recovery images
RECOVERYFS_SQUASHFS_IMAGE = "${DEPLOY_DIR_IMAGE_NAND}/recoveryfs.squash"
RECOVERYFS_SQUASHFS_UBI_IMAGE = "${DEPLOY_DIR_IMAGE_NAND}/recoveryfs.ubi"

#defconfig to be used for nf-64
KERNEL_CONFIG = "${@['vendor/qcs403-perf_defconfig', 'vendor/qcs403_defconfig'][d.getVar('VARIANT', True) == ('' or 'debug')]}"

# Sizes for EXT4 (in bytes)
SYSTEM_SIZE_EXT4 ?= "${@bb.utils.contains('DEBUG_BUILD', '1', '5368709120', '681574400', d)}"
SYSTEMRW_SIZE_EXT4 ?= "8388608"
USERDATA_SIZE_EXT4 ?= "5014746624"
CACHE_SIZE_EXT4 ?= "80000000"

#Deploy PATH for ext4 images
DEPLOY_DIR_IMAGE_EMMC = "${DEPLOY_DIR_IMAGE}/emmc-ext4"

#Enable verity feature
DISTRO_FEATURES += "dm-verity"

#verity required paths.
#Verity is supported only for emmc.
VERITY_IMAGE_DIR      = "${DEPLOY_DIR_IMAGE_EMMC}/verity"
SPARSE_SYSTEM_IMG     = "${DEPLOY_DIR_IMAGE_EMMC}/${SYSTEMIMAGE_TARGET}"

PAGE_SIZE ?= '4096'
PRODUCT_TYPE = "speaker"

#Target to support NAND build also.
DISTRO_FEATURES += "nand-boot"
DISTRO_FEATURES_NATIVE:append = " nand-boot "

#enable syslg error in nightfury device
PACKAGECONFIG:append_pn-adk-utils = " syslog error"
#NAND PARAMETERS
#Final system partition name.
OUTPUT_FILE_FINAL_SQUASHFS_UBI = "${DEPLOY_DIR_IMAGE_NAND}/system.ubi"
UBIFS_UBI_IMAGE      = "system-ubifs.ubi"
#system volume name
SQUASHFS_SYS_VOLUME = "system.squash"
# usrfs volume.
USR_IMAGE_BASENAME  = "userdata"
# persist volume = "persist.ubifs"
OUTPUT_FILE_PERSIST_UBIFS = "${DEPLOY_DIR_IMAGE_NAND}/persist.ubifs"
#Final system partition name.
OUTPUT_FILE_FINAL_SQUASHFS_UBI = "${DEPLOY_DIR_IMAGE_NAND}/system.ubi"
# Max supported inodes
EXTRA_IMAGECMD ?= "-N 2048"
#UBINIZE Args
UBINIZE_ARGS ?= "-m 4096 -p 256KiB -s 4096"
#MKUBIFS Args
MKUBIFS_ARGS ?= "-m 4096 -e 253952 -c 2146 -F"
# Limiting squashfs rootfs size to 110MiB (size should be multiple of LEB, LEB is 253952 bytes)
SYSTEM_SQUASHFS_VOLUME_SIZE = "125829120"
#Volume sizes
CACHE_VOLUME_SIZE ?= "81MiB"
SYSTEMRW_VOLUME_SIZE ?= "6MiB"
PERSIST_VOLUME_SIZE ?= "12MiB"
#Deploy path for ubi images
DEPLOY_DIR_IMAGE_NAND = "${DEPLOY_DIR_IMAGE}/nand-squashfs"


MACHINE_MNT_POINTS = "/firmware /persist /cache /dsp /bt_firmware"

# Set ab-boot-support feature for native tools as well,
# as some native tools have workflow chnages for AB builds.
DISTRO_FEATURES += "ab-boot-support"
DISTRO_FEATURES_NATIVE:append = " ab-boot-support "

# Formats of root filesystem images.
IMAGE_FSTYPES += "ubi ext4"

#Disable ssd listener
DISTRO_FEATURES:append = " no-ssd-listener-support"

#Disable rpmb listener
DISTRO_FEATURES:append = " no-rpmb-listener-support"

# enable audio as a loadable kernel module
DISTRO_FEATURES:append = " audio-dlkm"
DISTRO_FEATURES:append = " persist-volume"
DISTRO_FEATURES:append = " nand-squashfs"
DEFAULTTUNE = "aarch64"
MKUBIFS_PERSIST_ARGS = "-m 4096 -e 253952 -c 2146 -F"
RECOVERY_IMAGE = "0"

KERNEL_IMAGETYPE = "Image.gz-dtb"

require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "armv7ahf-neon"
TARGET_VENDOR_virtclass-multilib-lib32="-oe"

# Flag to Enable QPermissions
QPERMISSIONS_ENABLE = "1"

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"
QPERM_FILE_pn-alm         = "/persist/data:1000:1000"
#Config to be used for persist.ext4
PERSISTFS_CONFIG = "-C ${WORKDIR}/persist_fsconfig.conf"
MAKEEXT4_MOUNT_OPT = "-a /"

#no-test-bundle ensures reduced size package installation.
#qti-audiopd ensures audiopd is supported by adsp"
#systemd-minimal ensures reduced system size package installation.
DISTRO_FEATURES:append = " no-test-bundle qti-audiopd systemd-minimal"

#qti-cdsp ensures cdsp subsystem is supported.
#wlan ensures wlan functionality is supported.
#wlan-1x1 ensures wlan chip is 1x1, enable it only if wlan is enabled
MACHINE_FEATURES:append = " qti-cdsp wlan wlan-1x1 "

#wlan-perf build wlan driver with perf config
DISTRO_FEATURES:append  = " ${@bb.utils.contains("MACHINE_FEATURES", "wlan", "wlan-perf", "", d)} "

PREFERRED_PROVIDER_virtual/libgles1 = "adreno"
PREFERRED_PROVIDER_virtual/libgles2 = "adreno"
PREFERRED_PROVIDER_virtual/egl      = "adreno"
PREFERRED_VERSION_libdrm = "2.4.83"

# Enable coedump
SYSTEMD_ENABLE_COREDUMP = "1"
SYSTEMD_COREDUMP_PATH = "/var/tmp"

#Enable factory storage
DISTRO_FEATURES:append = "factory-storage"
