#
# Copyright (c) 2022 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_SIZE_OPTIMIZATIONS=y
CONFIG_MAIN_STACK_SIZE=20480
CONFIG_MBEDTLS_CFG_FILE="mcuboot-mbedtls-cfg.h"
CONFIG_PCD_APP=y
CONFIG_PARTITION_MANAGER_ENABLED=y
CONFIG_BOARD_ENABLE_CPUNET=n
CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
CONFIG_BOOT_MAX_IMG_SECTORS=2048

# Enable serial debug for MCUBOOT
CONFIG_SERIAL=y
CONFIG_CBPRINTF_NANO=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
CONFIG_LOG=y
CONFIG_UART_NRFX=y

# External Flash
CONFIG_GPIO=y
CONFIG_SPI=y
CONFIG_SPI_NOR=y
CONFIG_SPI_NOR_SFDP_DEVICETREE=y
CONFIG_MULTITHREADING=y
# Change default flash erase size for flexible flash layout
CONFIG_SPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_BOOT_ERASE_PROGRESSIVELY=y
CONFIG_SOC_FLASH_NRF_EMULATE_ONE_BYTE_WRITE_ACCESS=y
CONFIG_FPROTECT=y

# The following configurations are required to support simultaneous multi-image update
CONFIG_PCD_APP=y
CONFIG_UPDATEABLE_IMAGE_NUMBER=2
CONFIG_BOOT_UPGRADE_ONLY=y

# The network core cannot access external flash directly. The flash simulator must be used to
# provide a memory region that is used to forward the new firmware to the network core
CONFIG_FLASH_SIMULATOR=y
CONFIG_FLASH_SIMULATOR_DOUBLE_WRITES=y
CONFIG_FLASH_SIMULATOR_STATS=n

# Enable custom command to erase settings partition
CONFIG_ENABLE_MGMT_PERUSER=y
CONFIG_BOOT_MGMT_CUSTOM_STORAGE_ERASE=y
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

# TODO:Below configs are not required by mcuboot in order to reduce footprint of mcuboot
# Should be moved from board file to prj.conf
CONFIG_NFCT_PINS_AS_GPIOS=n
CONFIG_I2S=n
CONFIG_NRFX_I2S=n
CONFIG_NRFX_CLOCK=n
CONFIG_I2C=n
CONFIG_NRFX_TWIM1=n
CONFIG_NEWLIB_LIBC=n
CONFIG_FPU=n
CONFIG_FPU_SHARING=n
CONFIG_DISK_DRIVERS=n
CONFIG_DISK_DRIVER_SDMMC=n
CONFIG_ADC=n
CONFIG_FILE_SYSTEM=n
CONFIG_FAT_FILESYSTEM_ELM=n
CONFIG_FS_FATFS_LFN=n
CONFIG_FS_FATFS_LFN_MODE_STACK=n
CONFIG_FS_FATFS_EXFAT=n
CONFIG_BT=n
CONFIG_HW_CODEC_CIRRUS_LOGIC=n
CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y
