#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

menuconfig BOOT_NXBOOT
	bool "NuttX bootloader"
	default n
	select BCH
	---help---
		Enable support for the minimal NuttX based bootloader.

if BOOT_NXBOOT

config NXBOOT_PRIMARY_SLOT_PATH
	string "Application firmware primary image slot path"
	default "/dev/ota0"
	---help---
		The path to the application firmware image primary slot character
		device driver. The image runs from this location.
		Default: /dev/ota0

config NXBOOT_SECONDARY_SLOT_PATH
	string "Application firmware secondary image slot path"
	default "/dev/ota1"
	---help---
		The path to the application firmware image primary slot character
		device driver. This is either update or recovery slot.
		Default: /dev/ota1

config NXBOOT_TERTIARY_SLOT_PATH
	string "Application firmware tertiary image slot path"
	default "/dev/ota2"
	---help---
		The path to the application firmware image primary slot character
		device driver. This is either update or recovery slot.
		Default: /dev/ota2

config NXBOOT_HEADER_SIZE
	hex "Application firmware image header size"
	default 0x200
	---help---
		Note that this size should be aligned with the program memory write
		page size!

config NXBOOT_PLATFORM_IDENTIFIER
	hex "A unique platform identifier"
	default 0x0
	---help---
		This is a unique platform identifier used by the bootloader to
		verify whether the image should be run on a given platform. An update
		(or even a firmware uploaded via a programmer) is rejected if the
		value in image's header doesn't match this option.

config NXBOOT_BOOTLOADER
	bool "Build nxboot bootloader application"
	default n
	select BOARDCTL
	select BOARDCTL_BOOT_IMAGE
	---help---
		This option builds and links a bootloader application. This application
		should be an entry function for NuttX. It checks for possible update/
		revert operation, performs it and boot the correct image.

if NXBOOT_BOOTLOADER

config NXBOOT_COPY_TO_RAM
	bool "Copy bootable image to RAM before calling board boot-image function"
	default n
	---help---
		The is a board and/or arch specific option that may be used when running
		directly from flash, especially if external flash, even in XIP mode, is too
		slow.
		Running from RAM usually results in faster execution but the board must, of
		course, have sufficient RAM available for the application image, stack
		and heap.

config NXBOOT_RAMSTART
	hex "Start address in RAM that the application is to be loaded"
	default 0x0
	depends on NXBOOT_COPY_TO_RAM
	---help---
		This will be board specific. A check of the board's linker script
		may be informative. For example the SAMA5D2-XULT eval board's uboot
		linker script - boards/arm/sama5/sama5d2-xult/scripts/uboot.ld - has:
		
		sdram (W!RX) : ORIGIN = 0x20008000, LENGTH = 256M - 32K

		This shows the load address to be 0x20008000 and would be the address
		to use here if the same linker script is to be be used for NXboot.

		Typically the address is the base address of the RAM to be used, plus the
		size of the NXboot image itself. The example above has reserved
		32KiB (0x8000) for this from the 256MiB available on the board at
		address 0x20000000.

config NXBOOT_SWRESET_ONLY
	bool "Perform update/revert only on SW reset"
	default n
	select BOARDCTL_RESET_CAUSE
	---help---
		This option ensures the update/revert is performed only for following
		reset causes:
			BOARDIOC_RESETCAUSE_CPU_SOFT: software reset
			BOARDIOC_RESETCAUSE_CPU_RWDT: watchdog error
			BOARDIOC_RESETCAUSE_PIN: reset button

		This way the board can keep its image (even if not confirmed) during
		for example power shutdown and perform update/revent only if expected
		based on user/maintainer input.

config NXBOOT_PREVENT_DOWNGRADE
	bool "Perform update only for newer version"
	default n
	---help---
		NXboot uses Semantic Version 2.0.0 (without build metadata). By default
		the update is performed for every version that doesn't match the
		currently running one. If NXBOOT_PREVENT_DOWNGRADE selected, update is
		performed only for newer versions (according to Semantic Version
		preference rules).

		WARNING: NXboot currently implements preferences only for
		MAJOR.MINOR.PATCH and ignores prerelease.

config NXBOOT_PROGRESS
	bool
	default n

config NXBOOT_PRINTF_PROGRESS
	bool "Enable progress messages to be sent to STDOUT"
	default y
	select NXBOOT_PROGRESS
	---help---
		This will display progress during typically lengthy operations:
			- Calculating checksums
			- copying images between slots

		Note: the NXboot binary will be approximately 2KiB larger with this enabled.

choice
	prompt "Choose preferred progress indication type"
	depends on NXBOOT_PRINTF_PROGRESS
	default NXBOOT_PRINTF_PROGRESS_PERCENT

config NXBOOT_PRINTF_PROGRESS_DOTS
	bool "Display progress using sequential dots"

config NXBOOT_PRINTF_PROGRESS_PERCENT
	bool "Display progress using percentage remaining"

endchoice

endif # NXBOOT_BOOTLOADER

endif # BOOT_NXBOOT
