# SPDX-License-Identifier: GPL-2.0-only

source "common/boards/Kconfig"

config CC_IS_GCC
	def_bool $(success,test "$(cc-name)" = GCC)

config GCC_VERSION
	int
	default $(cc-version) if CC_IS_GCC
	default 0

config CC_IS_CLANG
	def_bool $(success,test "$(cc-name)" = Clang)

config CLANG_VERSION
	int
	default $(cc-version) if CC_IS_CLANG
	default 0

config CLANG_RUNTIME_DIR
	string
	depends on CC_IS_CLANG
	default "$(clang-runtime-dir)"

config GREGORIAN_CALENDER
	bool

config HAS_KALLSYMS
	bool

config HAS_MODULES
	bool

config HAS_DMA
	bool
	help
	  This allows you to run "make ARCH=sandbox allyesconfig".

	  Drivers that depend on a DMA implementation can depend on this
	  config, so that you don't get a compilation error.

config GENERIC_GPIO
	bool

config BLOCK
	bool

config BLOCK_WRITE
	bool

config BLOCK_STATS
	bool

config FILETYPE
	bool

config BINFMT
	bool
	select FILETYPE

config UIMAGE
	select UNCOMPRESS
	select CRC32
	bool

config FITIMAGE
	bool
	select OFTREE
	select DIGEST

config FITIMAGE_SIGNATURE
	bool
	select CRYPTO_BUILTIN_KEYS

config LOGBUF
	bool

config STDDEV
	bool

config CDEV_ALIAS
	bool

config MENUTREE
	bool
	select GLOB
	select GLOB_SORT

config BAREBOX_UPDATE_IMX_NAND_FCB
	bool
	depends on ARCH_IMX7 || ARCH_IMX6 || ARCH_IMX28
	depends on BAREBOX_UPDATE
	depends on MTD_WRITE
	depends on NAND_MXS
	select BCH if ARCH_IMX6
	default y

config UBIFORMAT
	bool
	select LIBSCAN
	select LIBUBIGEN
	depends on MTD_UBI
	default y

config BOOT
	select GLOB
	bool

config FASTBOOT_BASE
	bool

menu "General Settings"

config LOCALVERSION
	string "Local version - append to the version string"
	help
	  Append an extra string to the end of your version string.
	  The string you set here will be appended after the contents of
	  any files with a filename matching localversion* in your
	  object and source tree, in that order. Your total string can
	  be a maximum of 64 characters.

config LOCALVERSION_AUTO
	bool "Automatically append version information to the version string"
	default y
	help
	  This will try to automatically determine if the current tree is a
	  release tree by looking for git tags that belong to the current
	  top of tree revision.

	  A string of the format -gxxxxxxxx will be added to the localversion
	  if a git-based tree is found. The string generated by this will be
	  appended after any matching localversion* files, and after the value
	  set in CONFIG_LOCALVERSION.

	  (The actual string used here is the first eight characters produced
	  by running the command:

	    $ git rev-parse --verify HEAD

	  which is done within the script "scripts/setlocalversion".)

config HAS_INSECURE_DEFAULTS
	bool
	help
	  This is selected by options that have potentially insecure defaults.
	  Extra care needs to be taken when these options are not disabled
	  in secure booted systems.

	  Any option selecting this should include in its help text
	  an explanation of the security considerations.

config INSECURE
	bool "enable convenient defaults that are unsuitable for secure-booting systems"
	default y
	select HAS_INSECURE_DEFAULTS
	help
	  Say n here when barebox is part of a secure boot chain and you
	  want to disable defaults that may compromise the boot chain.

	  This option is a moving target. Currently it:

	    - changes the default of global.env.autoprobe to 1

config BANNER
	bool "display banner"
	default y

config MEMINFO
	bool "display memory info"
	default y

config MEMTEST
	bool

config ENVIRONMENT_VARIABLES
	bool "environment variables support"

config GLOBALVAR
	bool "global environment variables support"
	default y if !SHELL_NONE
	select FNMATCH
	help
	  Global environment variables begin with "global.". Unlike normal
	  shell variables they have the same values in all contexts. Global
	  variables are used to control several aspects of the system behaviour.
	  If unsure, say yes here.

config NVVAR
	bool "Non volatile global environment variables support"
	default y if !SHELL_NONE && ENV_HANDLING
	depends on GLOBALVAR
	select FNMATCH
	help
	  Non volatile environment variables begin with "nv.". They behave like
	  global variables above, but when CONFIG_ENV_HANDLING is enabled, they
	  can be stored in the environment storage with 'saveenv' and thus
	  persisted over restarts. nv variables are coupled with global
	  variables of the same name. Setting "nv.foo" results in "global.foo"
	  changed also (but not the other way round: setting "global.foo" leaves
	  "nv.foo" untouched). The idea is that nv variables can store defaults
	  while global variables can be changed during runtime without changing
	  the default.

menu "memory layout"

source "pbl/Kconfig"

config MMU
	bool "Enable MMU"
	depends on !CPU_ARM946E
	help
	  Saying yes here enables the MMU. This is useful on some architectures
	  to enable the data cache which depends on the MMU. See Documentation/mmu.txt
	  for further information.

config MMUINFO
	bool

config HAVE_CONFIGURABLE_TEXT_BASE
	bool

config TEXT_BASE
	depends on HAVE_CONFIGURABLE_TEXT_BASE
	prompt "TEXT_BASE"
	hex
	range 0 0xffffffff
	default ARCH_TEXT_BASE
	help
	  The 32-bit address barebox gets linked at. This is forced
	  to zero for relocatable barebox and fixed up at runtime,
	  so barebox is executable on arbitrary addresses (given
	  sufficient alignment).

config BAREBOX_MAX_IMAGE_SIZE
	prompt "Maximum size of barebox"
	hex
	default 0xffffffff
	help
	  Define the maximum size of barebox

config BAREBOX_MAX_PBL_SIZE
	depends on PBL_IMAGE
	prompt "Maximum pre-bootloader size"
	hex
	default 0xffffffff
	help
	  On some hardware the ROM code can load the pbl into SRAM, but not
	  the whole image. This option specifies how big the pbl may get.

config BAREBOX_MAX_BARE_INIT_SIZE
	prompt "Maximum bare_init size"
	hex
	default 0xffffffff
	help
	  Define the maximum size of bare_init
	  this will allow your bare_init to fit in SRAM as example
	  ARCH can overwrite it via ARCH_BAREBOX_MAX_BARE_INIT_SIZE

config HAVE_CONFIGURABLE_MEMORY_LAYOUT
	bool

choice
	prompt "select memory layout"
	depends on HAVE_CONFIGURABLE_MEMORY_LAYOUT
	default MEMORY_LAYOUT_DEFAULT

config MEMORY_LAYOUT_DEFAULT
	bool "use default memory layout"
	help
	  select this option to use bareboxs standard memory layout:

	  stack
	  -----
	  malloc heap
	  -----
	  TEXT_BASE

config MEMORY_LAYOUT_FIXED
	bool "manually assign a memory layout"
	help
	  select this option to manually assign stack base and malloc
	  heap base

endchoice

config STACK_BASE
	depends on MEMORY_LAYOUT_FIXED
	hex
	prompt "STACK_BASE"

config STACK_SIZE
	hex
	default 0x8000
	prompt "Stack size"

config MALLOC_BASE
	depends on MEMORY_LAYOUT_FIXED
	hex
	prompt "MALLOC_BASE"

config MALLOC_SIZE
	hex
	default 0x400000
	prompt "malloc area size"

config SCRATCH_SIZE
	hex
	default 0x8000
	prompt "Scratch size"

config MALLOC_ALIGNMENT
	hex
	default 8

endmenu

config BROKEN
	bool

config EXPERIMENTAL
	bool
	prompt "Prompt for experimental code"

choice
	prompt "malloc implementation"
	default MALLOC_TLSF

config MALLOC_TLSF
	bool "tlsf"

config MALLOC_DUMMY
	bool "dummy malloc"
	depends on SHELL_NONE
	help
	  select this option to use a dummy malloc implementation. With this
	  memory is never freed. This is suitable for well tested noninteractive
	  environments only.

config MALLOC_LIBC
	bool "libc malloc"
	depends on SANDBOX
	help
	  select this option to use the libc malloc implementation in the sandbox.
	  This is benefecial for testing with external memory integrity tools.

endchoice

config MODULES
	depends on HAS_MODULES
	depends on EXPERIMENTAL
	select HAS_INSECURE_DEFAULTS
	bool "module support"
	modules
	help
	  This option enables support for loadable modules via insmod. Module
	  support is quite experimental at the moment. There is no convenient
	  way to compile modules and the list of exported symbols to actually
	  make use of modules is short to nonexistent.

	  As modules can't be signed, loading external modules is not
	  recommended for secure systems.

config KALLSYMS
	depends on HAS_KALLSYMS
	bool "kallsyms"
	help
	  With Kallsyms enabled all symbols are compiled into the barebox image.
	  This is useful to print a nice backtrace when an exception occurs.

config RELOCATABLE
	depends on PPC || ARM || RISCV
	bool "generate relocatable barebox binary"
	help
	  A non relocatable barebox binary will run at it's compiled in
	  link address in RAM. This leads to smaller image sizes but may
	  put barebox just in the middle of RAM. With this option enabled
	  instead barebox can determine this address at runtime and thus
	  allowing it to relocate to the end of the available RAM. This
	  way you have the whole memory in a single piece.

choice
	prompt "Configure action on fatal error"
	default PANIC_RESET

	config PANIC_POWEROFF
		bool "power off the system"
		help
		  This option shuts down the system in case of a
		  fatal error, so that you have to power it on manually.
		  This is probably NOT a good idea for an embedded
		  system where you want the system to reboot
		  automatically as fast as possible, but it may be
		  useful in emulation, because the system returns
		  to parent shell immediately.

	config PANIC_HANG
		bool "hang the system"
		help
		  This option enables stop of the system in case of a
		  fatal error, so that you have to reset it manually.
		  This is probably NOT a good idea for an embedded
		  system where you want the system to reboot
		  automatically as fast as possible, but it may be
		  useful during development since you can try to debug
		  the conditions that lead to the situation.

	config PANIC_RESET
		bool "reset the system"
		help
		  This option enables reset of the system in case of a
		  fatal error, so you don't have to reset it manually.
		  This is the recommended configuration in production.

endchoice

config PROMPT
	string
	prompt "barebox command prompt"
	default "barebox:"

config BAUDRATE
	int
	prompt "Default baudrate"
	default 115200

config SIMPLE_READLINE
	bool
	default y
	depends on !CMDLINE_EDITING

config BAREBOX_CMDLINE
	bool
	help
	  Support a barebox command line when running virtualized.
	  The commands are appended onto /cmdline, which is sourced
	  after sourcing all init scripts.

config CBSIZE
	int
	prompt "Buffer size for input from the Console"
	default 1024

config FIRMWARE
	bool

choice
	prompt "Select your shell"

	config SHELL_HUSH
		bool "hush parser"
		select ENVIRONMENT_VARIABLES
		select COMMAND_SUPPORT
		select PARAMETER
		select BINFMT
		select STDDEV
		select GLOB
		help
		  Enable hush support. This is the most advanced shell available
		  for barebox.

	config SHELL_SIMPLE
		bool "Simple parser"
		select ENVIRONMENT_VARIABLES
		select COMMAND_SUPPORT
		select PARAMETER
		select STDDEV
		select CMD_SETENV
		select GLOB
		help
		  simple shell. No if/then, no return values from commands, no loops

	config SHELL_NONE
		bool "no shell (noninteractive build)"
		help
		  No shell at all. This means no shell is started and your board has
		  to overwrite the barebox_main function pointer which is then called
		  at the end of the barebox startup process.
endchoice

config MAXARGS
	int
	depends on SHELL_SIMPLE
	prompt "max. Number of arguments accepted for monitor commands"
	default 16

config GLOB
	bool
	select FNMATCH
	prompt "globbing support"
	help
	  If you want to use wildcards like * or ? say y here.

	  Globbing can be used in the HUSH shell, but is also used
	  internally in the menutree command.

config GLOB_SORT
	select QSORT
	bool
	prompt "glob sort support"
	depends on GLOB

config PROMPT_HUSH_PS2
	string
	depends on SHELL_HUSH
	prompt "hush PS2"
	default "> "

config HUSH_FANCY_PROMPT
	bool
	depends on SHELL_HUSH
	select PROCESS_ESCAPE_SEQUENCE
	prompt "allow fancy hush prompts"
	help
	  Allow to set PS1 from the command line. PS1 can have several escaped commands
	  like \h for the 'model' string or \w for the current working directory.

config CMDLINE_EDITING
	depends on !SHELL_NONE
	bool
	prompt "Enable command line editing"

config AUTO_COMPLETE
	bool
	depends on CMDLINE_EDITING
	prompt "Enable auto completion"

config MENU
	bool
	prompt "Menu Framework"
	depends on !SHELL_NONE
	select PROCESS_ESCAPE_SEQUENCE
	help
	  a menu framework that allow us to create list menu to simplify
	  barebox and make it more user-friendly

config PASSWORD
	bool
	prompt "Password Framework"
	select DIGEST
	help
	  allow you to have password protection framework

config PASSWORD_DEFAULT
	string
	prompt "Password default file"
	depends on PASSWORD
	help
	  Set this to a file which is used as default password file. This file
	  has to contain the passwd encoded with the selected password digest.
	  i.e.:
	  echo -ne "MyPassword" | md5sum | while read a b; do echo $a > passwdfile; done


if PASSWORD

choice
	prompt "passwd checksum"

config PASSWD_SUM_MD5
	bool "MD5"
	select DIGEST_MD5_GENERIC

config PASSWD_SUM_SHA1
	bool "SHA1"
	select DIGEST_SHA1_GENERIC

config PASSWD_SUM_SHA256
	bool "SHA256"
	select DIGEST_SHA256_GENERIC

config PASSWD_SUM_SHA512
	bool "SHA512"
	select DIGEST_SHA512_GENERIC

config PASSWD_CRYPTO_PBKDF2
	bool "PBKDF2"
	select CRYPTO_PBKDF2

endchoice

endif

config ERRNO_MESSAGES
	bool
	prompt "print error values as text"
	default y

config TIMESTAMP
	bool
	default y
	depends on UIMAGE
	select GREGORIAN_CALENDER
	prompt "print timestamp information from uImages"
	help
	  When CONFIG_TIMESTAMP is selected, the timestamp
	  (date and time) of an uImage is printed by image
	  commands like bootm or uimage.

menuconfig BOOTM
	default y if COMMAND_SUPPORT
	bool "bootm support"

config BOOT_OVERRIDE
	bool "Support partial override of boot entries"
	depends on BOOTM
	help
	  Allow overriding of bootm image, oftree and initrd by passing
	  -o as an argument to the boot command.

config BOOTM_SHOW_TYPE
	bool
	depends on BOOTM && UIMAGE
	prompt "show uImage information"
	help
	  Displays some tags from the uImage:

	  - OS type
	  - architecture,
	  - type
	  - compression method.

config BOOTM_VERBOSE
	bool
	prompt "verbose support"
	depends on BOOTM
	help
	  Adds the verbose (-v switch) command line option.

config BOOTM_INITRD
	bool
	prompt "initial RAM disk (initrd) support"
	depends on BOOTM
	help
	  Adds support for initial RAM disk and this two command line options:

	  -r INITRD  specify an initrd image
	  -L ADDR    specify initrd load address

config BOOTM_OFTREE
	def_bool y
	depends on BOOTM && HAVE_ARCH_BOOTM_OFTREE
	select OFTREE
	prompt "device tree (oftree) support"
	help
	  Add support to pass a device tree (a.k.a Open Firmware Tree, oftree). Adds
	  this command line option:

	  -o DTS  specify device tree

config BOOTM_OFTREE_FALLBACK
	def_bool y
	# We intentionally don't depend on BOOTM_OFTREE, because many boards
	# don't enable it and instead rely on OFTREE being selected...
	depends on BOOTM && HAVE_ARCH_BOOTM_OFTREE && OFTREE
	prompt "pass along barebox' own DT as fallback"
	help
	  Say y here to substitute in the barebox device tree, when no kernel
	  device tree was supplied. If unsure, say n.

	  It's recommended to boot a kernel with the device tree that was
	  shipped with it as DT binding breakage is not an infrequent
	  occurrence.

	  This especially applies to A/B boot setups, where each kernel
	  should have its own DT, so fallback restores the system cleanly
	  to the old state.

config BOOTM_UIMAGE
	def_bool y
	prompt "support the legacy uImage format"
	select UIMAGE
	depends on BOOTM
	help
	  Support using uImages. This format has been superseded
	  by FIT images and is not as frequently used nowadays.

config BOOTM_OFTREE_UIMAGE
	bool
	prompt "support passing device tree (oftree) uImages"
	depends on BOOTM_OFTREE && BOOTM_UIMAGE
	help
	  Support using oftree uImages. Without this only raw oftree
	  blobs can be used.

config BOOTM_AIMAGE
	bool
	prompt "Android image support"
	depends on BOOTM && ARM
	help
	  Support using Android Images.

config PE
	bool "PE/COFF Support" if COMPILE_TEST

config ELF
	bool "ELF Support" if COMPILE_TEST

config BOOTM_FITIMAGE
	bool
	prompt "FIT image support"
	select FITIMAGE
	depends on BOOTM
	help
	  Support using Flattened Image Tree (FIT) images. FIT is an image
	  format introduced by U-Boot. A FIT image contains one or multiple
	  kernels, device trees and initrds. The FIT image itself is a flattened
	  device tree binary. Have a look at the u-boot source tree
	  in the "doc/uImage.FIT" folder for more information:
	  http://git.denx.de/?p=u-boot.git;a=tree;f=doc/uImage.FIT

config BOOTM_FITIMAGE_SIGNATURE
	bool
	prompt "support verifying signed FIT images"
	depends on BOOTM_FITIMAGE
	select FITIMAGE_SIGNATURE
	help
	  Support verifying signed FIT images. This requires FIT images
	  as described in:
	  https://docs.u-boot.org/en/stable/usage/fit/signature.html
	  Additionally the barebox device tree needs a /signature node with the
	  public key needed to approve the image's signature.

config BOOTM_FITIMAGE_PUBKEY_ENV
	bool "Specify path to public key in environment"
	depends on BOOTM_FITIMAGE_SIGNATURE
	help
	  If this option is enabled the path to the device tree snippet
	  containing the public key for verifying FIT images signature is taken
	  from make's build-time environment, which can allow for better
	  integration with some build systems.

	  The environment variable has the same name as the corresponding
	  Kconfig variable:

	  CONFIG_BOOTM_FITIMAGE_PUBKEY

if BOOTM_FITIMAGE_SIGNATURE && !BOOTM_FITIMAGE_PUBKEY_ENV

config BOOTM_FITIMAGE_PUBKEY
	string "Path to dtsi containing pubkey"
	default "../fit/pubkey.dtsi"
	depends on BOOTM_FITIMAGE_SIGNATURE
	help
	  Set Path to a dts snippet which holds the public keys for FIT images. The
	  snippet can then be included in a device tree with
	  "#include CONFIG_BOOTM_FITIMAGE_PUBKEY".

	  This snippet is usually generated by decompiling a device tree produced
	  by mkimage. An alternative is CONFIG_CRYPTO_PUBLIC_KEYS, which takes a list
	  of PEM files or PKCS#11 URIs (with optional key name hints, see its help
	  text).

endif

config BOOTM_FORCE_SIGNED_IMAGES
	bool
	prompt "Force booting of signed images"
	depends on BOOTM_FITIMAGE_SIGNATURE
	help
	  With this option enabled only signed images can be booted, unsigned images
	  are refused to boot. Effectively this means only FIT images can be booted
	  since they are the only supported image type that support signing.

config BOOTM_OPTIONAL_SIGNED_IMAGES
	def_bool !BOOTM_FORCE_SIGNED_IMAGES
	select HAS_INSECURE_DEFAULTS
	depends on BOOTM
	help
	  With this option enabled, barebox can be reconfigured to not verify signed
	  images. It's the board code's responsibility to call the function
	  bootm_force_signed_images() when secure booted to ensure that runtime
	  reconfiguration is no longer possible.

config BLSPEC
	depends on FLEXIBLE_BOOTARGS
	depends on !SHELL_NONE
	select BOOT
	select BOOTM
	select OFTREE
	bool
	prompt "Support bootloader spec"
	help
	  Enable this to let barebox support the UAPI bootloader spec,
	  see: https://uapi-group.org/specifications/specs/boot_loader_specification/
	  The bootloader spec is a standard interface between the bootloader
	  and the kernel. It allows the bootloader to discover boot options
	  on a device and it allows the Operating System to install / update
	  kernels.

config FLEXIBLE_BOOTARGS
	bool
	prompt "flexible Linux bootargs generation"
	depends on GLOBALVAR
	help
	  Select this to get a more flexible bootargs generation. With this
	  option the bootargs are concatenated together from global variables
	  beginning with 'global.linux.bootargs.' and 'global.linux.mtdparts.'
	  This allows for more flexible scripting since with it it's possible
	  to replace parts of the bootargs string without reconstructing it
	  completely.

config ROOTWAIT_BOOTARG
	def_bool y
	prompt "fixup 'rootwait' into kernel command-line when needed"
	depends on FLEXIBLE_BOOTARGS
	help
	  Adds a rootwait= argument into the kernel command-line argument
	  for boot media that requires it, like USB, SD/MMC or NFS.
	  The duration chosen is controlled by the linux.rootwait
	  parameter and defaults to 10 seconds. Setting the variable
	  to 0 will wait indefinitely.

config MMCBLKDEV_ROOTARG
	bool
	prompt "Support 'root=mmcblkXpN' cmdline appending"
	depends on FLEXIBLE_BOOTARGS
	depends on MCI
	depends on OFTREE
	help
	  Enable this option to append 'root=mmcblkXpN' to the cmdline instead
	  of 'root=PARTUUID=XYZ'. Don't enable this option if your used linux
	  kernel doesn't contain commit [1]. The first linux kernel release
	  containing that commit is v5.10-rc1.

	  The appending only happens if barebox' 'linux.bootargs.bootm.appendroot'
	  variable is set or the used blspec entry contains 'linux-appendroot'.

	  Note: It is crucial that the kernel device tree and the barebox device
	  tree use the same mmc aliases.

	  [1] fa2d0aa96941 ("mmc: core: Allow setting slot index via device tree
	      alias")

config BAREBOX_UPDATE
	bool "In-system barebox update infrastructure"

config SYSTEM_PARTITIONS
	bool "Generic system partitions support"
	depends on GLOBALVAR
	help
	  System partitions are a generic way for boards to specify the
	  partitions that should be exported for flashing.
	  Board drivers that set this directly will select this option
	  automatically.
	  Say y here if this should be configurable over the
	  global.system.partitions device parameter as well.

config IMD
	select CRC32
	bool "barebox metadata support"

config IMD_ENDIANNESS
	bool "add endianness record to metadata"
	depends on IMD
	depends on SYS_SUPPORTS_LITTLE_ENDIAN && SYS_SUPPORTS_BIG_ENDIAN
	default y

choice
	prompt "console support"
	default CONSOLE_FULL

config CONSOLE_FULL
	bool
	prompt "full"
	help
	  This option enables full console support capable of
	  handling multiple consoles. Also the full console support
	  is able to store the output which comes before a console
	  is registered in a circular buffer which will be printed
	  once the first console is registered. Recommended for most
	  usecases.

config CONSOLE_SIMPLE
	bool
	prompt "simple"

config CONSOLE_NONE
	bool
	prompt "none"

endchoice

choice
	prompt "Console activation strategy"
	depends on CONSOLE_FULL
	default CONSOLE_ACTIVATE_ALL_FALLBACK

config CONSOLE_ACTIVATE_FIRST
	bool
	prompt "activate first console on startup"
	help
	  Select this to activate the first registered console.
	  On many systems, devices are probed in no strict order,
	  so you probably should say n here if you are probing
	  from device tree and have more than one console.

config CONSOLE_ACTIVATE_ALL
	bool
	prompt "activate all consoles on startup"
	help
	  Enabling this options activates all consoles on startup, so
	  you will get output and a prompt on all consoles simultaneously.
	  Only the first registered console will have the full startup
	  log though.

	  If you have consoles that aren't meant for barebox log output
	  (e.g. a connected MCU), you will want to say n here and use
	  CONFIG_ACTIVATE_ALL_FALLBACK or CONFIG_CONSOLE_ACTIVATE_NONE instead.

config CONSOLE_ACTIVATE_ALL_FALLBACK
	bool
	prompt "activate all consoles as fallback"
	help
	  This option is similar to CONFIG_CONSOLE_ACTIVATE_NONE in that it
	  leaves consoles disabled on startup. If by the end of barebox
	  startup, no consoles have been activated via board code, device
	  tree or environment, barebox will enable all registered consoles
	  as fallback, so the user has a chance to see output.

	  This will be indicated by a fat error, so the user knows that
	  the configuration needs to be fixed. If you don't see any
	  output at all, consider trying again after enabling
	  CONFIG_CONSOLE_ACTIVATE_ALL, so consoles are activated immediately
	  at registration time and/or with CONFIG_DEBUG_LL, so barebox output
	  is written even before console drivers were registered.

config CONSOLE_ACTIVATE_NONE
	prompt "leave all consoles disabled"
	bool
	help
	  Leave all consoles disabled on startup. Board code, environment
	  or the device tree /chosen/stdout-path property will be responsible
	  for enabling a console. Otherwise you'll get a working barebox,
	  you just won't see anything.

endchoice

config CONSOLE_ALLOW_COLOR
	prompt "Allow colored console output during boot"
	bool
	help
	  If enabled, colored output is allowed during boot. This is the
	  compile time default for colored console output. After boot it
	  can be controlled using global.allow_color.

config CONSOLE_FLUSH_LINE_BREAK
	bool "Flush consoles on new line" if COMPILE_TEST
	help
	  Many serial drivers configure and use hardware FIFOs as not to
	  delay the boot. When debuging some king of bugs, such as clock
	  issues that hang the SoC, this can falsify debugging output,
	  because the UART doesn't output a submitted message fully, before
	  the SoC hangs. This option will flush serial FIFOs when processing
	  the new line feed characters.

config CONSOLE_DISABLE_INPUT
	prompt "Disable input on all consoles by default (non-interactive)"
	def_bool CONSOLE_NONE
	help
	  If enabled, all consoles are initially configured to not accept any input,
	  making the consoles effectively non-interactive.
	  The active device parameter can be used to override this on a per-console
	  basis.
	  CAUTION: this will also disable input devices by default, since they are
	  registered as consoles.

config PBL_CONSOLE
	depends on PBL_IMAGE && !SANDBOX
	depends on !CONSOLE_NONE
	bool "Enable console support in PBL"
	help
	  This enables printf/pr_* support in the PBL to get more
	  informational output earlier during startup. Note that
	  printf/pr_* need a valid C environment, so the binary
	  must be running at the address it's linked at and bss must
	  be cleared. On ARM that would be after setup_c().

source "common/ratp/Kconfig"

config PARTITION
	bool
	prompt "Enable Partitions"

config PARTITION_MANIPULATION
	bool "Runtime reparsing of partition table" if COMPILE_TEST
	help
	  Say y here to have barebox reparse the partition table automatically
	  when it's rewritten. This is useful when using the parted command
	  or when writing full disk images that change the existing partitions.

	  Reparsing the partition table will delete existing partitions and thus
	  may break users that don't do proper reference counting. For this
	  reason, this option is currently disabled by default.

source "common/partitions/Kconfig"

config ENV_HANDLING
	select CRC32
	select HAS_INSECURE_DEFAULTS
	bool "Support environment files storage"
	default y if !SHELL_NONE
	help
	  Enabling this option will give you environment files which can be stored
	  over reboots. The "saveenv" command will store all files under /env/ to
	  the persistent environment, the "loadenv" command (also executed during
	  startup) will bring them back. If unsure, say yes.

	  As the environment is not cryptographically verified, an attacker with
	  raw access to the environment storage may set any nv variable and
	  inject shell scripts to be run by barebox.

	  In general, secure systems should rely exclusively on the barebox
	  built-in environment, disable the mutable environment and use the
	  barebox-state framework for persisting a fixed set of variables.

	  A safe use of the mutable environment may be possible if board code only
	  mounts it after verifying a JSON Web Token that enables a debug mode.

config DEFAULT_ENVIRONMENT
	select CRC32
	bool
	default y if ENV_HANDLING
	prompt "Compile in default environment"
	help
	  Enabling this option will give you a default environment when
	  the environment found in the environment sector is invalid or when
	  CONFIG_ENV_HANDLING is not enabled.

choice
	prompt "default compression for in-barebox binaries" if PBL_IMAGE
	default DEFAULT_COMPRESSION_NONE
	default DEFAULT_COMPRESSION_LZO if LZO_DECOMPRESS
	default DEFAULT_COMPRESSION_XZ if XZ_DECOMPRESS
	default DEFAULT_COMPRESSION_GZIP if ZLIB
	default DEFAULT_COMPRESSION_LZ4 if LZ4_DECOMPRESS
	default DEFAULT_COMPRESSION_BZIP2 if BZLIB
	help
	  For barebox builds without a prebootloader, select here the default
	  compression for in-barebox binary files. barebox itself can't be
	  compressed without a prebootloader, but for example the default
	  environment will be compressed with this compression type.

config DEFAULT_COMPRESSION_GZIP
	bool "gzip"
	depends on !PBL_IMAGE && ZLIB

config DEFAULT_COMPRESSION_BZIP2
	bool "bzip2"
	depends on !PBL_IMAGE && BZLIB

config DEFAULT_COMPRESSION_LZO
	bool "lzo"
	depends on !PBL_IMAGE && LZO_DECOMPRESS

config DEFAULT_COMPRESSION_LZ4
	bool "lz4"
	depends on !PBL_IMAGE && LZ4_DECOMPRESS

config DEFAULT_COMPRESSION_XZ
	bool "xz"
	depends on !PBL_IMAGE && XZ_DECOMPRESS

config DEFAULT_COMPRESSION_NONE
	bool "no compression"

endchoice

config DEFAULT_ENVIRONMENT_GENERIC_NEW
	bool "Generic environment template"
	depends on DEFAULT_ENVIRONMENT
	depends on SHELL_HUSH
	select BOOTM
	select COMMAND_SUPPORT
	select CMD_GETOPT
	select GLOB
	select GLOB_SORT
	select GLOBALVAR
	select CMD_GLOBAL
	select CMD_AUTOMOUNT
	select CMD_BASENAME
	select CMD_READLINK
	select CMD_DIRNAME
	select CMD_TEST
	select NVVAR
	select CMD_NV
	select FLEXIBLE_BOOTARGS
	select CMD_BOOT
	select NET_CMD_IFUP if NET
	select CMD_IP_ROUTE_GET if NET
	select CMD_HOST if NET
	help
	  With this option barebox will use the files found under
	  defaultenv/defaultenv-2-base/ in the source tree as a template for
	  the defaultenv. The directories specified in DEFAULT_ENVIRONMENT_PATH
	  will be added to the default environment. If a file is present in
	  both locations, the file from DEFAULT_ENVIRONMENT_PATH will overwrite
	  that from the template.

config DEFAULT_ENVIRONMENT_GENERIC
	bool "Generic environment template (old version)"
	depends on DEFAULT_ENVIRONMENT
	depends on !DEFAULT_ENVIRONMENT_GENERIC_NEW
	depends on SHELL_HUSH
	select COMMAND_SUPPORT
	select GLOBALVAR
	select CMD_GETOPT
	select CMD_CRC
	select CMD_CRC_CMP
	select CMD_GLOBAL
	help
	  Note: this option is not recommended for new boards; use
	  DEFAULT_ENVIRONMENT_GENERIC_NEW instead.

	  With this option barebox will use the old generic default environment
	  found under defaultenv/defaultenv-1/ in the source tree.
	  The directory given with DEFAULT_ENVIRONMENT_PATH
	  will be added to the default environment. This should
	  at least contain a /env/config file.
	  This will be able to overwrite the files from defaultenv.

config DEFAULT_ENVIRONMENT_GENERIC_NEW_MENU
	bool
	depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
	depends on CMD_MENUTREE
	default y
	help
	  Extend the defaultenv template with a menu that is displayed at boot.
	  The menu files are taken from defaultenv/defaultenv-2-menu/.

config DEFAULT_ENVIRONMENT_GENERIC_NEW_DFU
	bool
	depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
	depends on USB_GADGET_DFU
	default y
	help
	  Extend the defaultenv template with the 'dfu' boot entry, which
	  allows uploading the kernel and oftree over USB via the dfu protocol.

config DEFAULT_ENVIRONMENT_GENERIC_NEW_REBOOT_MODE
	bool "Generic reboot-mode handlers in the environment"
	depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
	depends on REBOOT_MODE

config DEFAULT_ENVIRONMENT_GENERIC_NEW_IKCONFIG
	bool "Ship .config as /env/data/config"
	depends on DEFAULT_ENVIRONMENT_GENERIC_NEW
	help
	  This option embeds the used barebox Kconfig .config file into the
	  environment as /env/data/config. This will increase barebox' image
	  size. If unsure, say n here.

config DEFAULT_ENVIRONMENT_PATH
	string
	depends on DEFAULT_ENVIRONMENT
	prompt "Default environment path"
	help
	  Space separated list of paths from which the default environment will
	  be taken. Relative paths will be relative to the barebox top-level
	  directory, but absolute paths are fine as well.

config HAS_SCHED
	bool

config POLLER
	bool "generic polling infrastructure"
	select HAS_SCHED

config BTHREAD
	bool "barebox co-operative (green) thread infrastructure"
	select HAS_SCHED
	depends on ARCH_HAS_SJLJ
	help
	  barebox threads are lightweight cooperative (green) threads that are
	  scheduled within delay loops and the console idle to asynchronously
	  execute actions, like checking for link up or feeding a watchdog.

config TLV
	bool "barebox TLV support"
	depends on OFDEVICE
	help
	  barebox TLV is a scheme for storing factory data on non-volatile
	  storage. Unlike state, it's meant to be read-only.

config TLV_DRV
	bool "barebox TLV generic driver"
	depends on TLV
	default y
	help
	  barebox,tlv devices in the device tree will be matched against
	  a compatible decoder via the 4-byte magic header.

config TLV_BAREBOX
	bool "barebox TLV common format"
	depends on TLV
	depends on PARAMETER
	select PRINTF_HEXSTR
	default y
	help
	  Decoder support for the common barebox TLV format.

config STATE
	bool "generic state infrastructure"
	select CRC32
	select ENVIRONMENT_VARIABLES
	select OFTREE
	select PARAMETER
	imply STATE_DRV
	imply CMD_STATE
	help
	  barebox state is a generic framework for atomic power fail-safe
	  variable storage and retrieval. It can be used to safely maintain
	  data over reboots and to exchange information with Linux, e.g.
	  for redundant boot with bootchooser.

config STATE_CRYPTO
	bool "HMAC based authentication support"
	depends on STATE
	select CRYPTO_KEYSTORE
	select DIGEST
	select DIGEST_HMAC_GENERIC
	help
	  This option enables HMAC based authentication support for
	  the state's header and data. This means the state framework
	  can verify both the data integrity and the authentication of
	  the state's header and data.

	  Don't forget to select a hash algorithm in the
	  crypto/digests menu.

	  See Documentation/devicetree/bindings/barebox/barebox,state.rst
	  for more information.

config STATE_BACKWARD_COMPATIBLE
	bool "backward compatible 'direct' storage backend"
	depends on STATE
	help
	  With this option enabled, the 'direct' storage backend keeps backward
	  compatibility with the state framework of barebox <= v2016.08.0. Newer
	  revisions expect an additional 'meta header' and fail otherwise.

config BOOTCHOOSER
	bool "bootchooser infrastructure"
	select BOOT
	select BOOTM
	select ENVIRONMENT_VARIABLES
	select OFTREE
	select PARAMETER

config BOOT_DEFAULTS
	bool "default boot targets"
	select BOOT
	select CDEV_ALIAS
	default BLSPEC && OFDEVICE
	help
	  Say y here to enable a number of default boot targets that
	  determine at runtime what to do. An example is the bootsource
	  target, which will expand to the device that barebox has
	  booted from if that could be determined.

config BAREBOX_DT_2ND
	bool "Consume DT bindings relevant only when barebox is booted by barebox"
	depends on OFDEVICE
	default BOARD_GENERIC_DT
	help
	  Barebox fixes up a number of device tree properties into the kernel
	  device tree that it does not itself consume.
	  Say y here for barebox to not only provide, but also consume
	  these device tree bindings.

	  This is currently:

	    /chosen/bootsource: Maintain the bootsource, even if SoC
	    bootsource info is lost.

	  If unsure, say n.

config RESET_SOURCE
	bool "detect Reset cause"
	depends on GLOBALVAR
	help
	  Provide a global variable at runtime which reflects the possible cause
	  of the reset and why the bootloader is currently running. It can be
	  useful for any kind of system recovery or repair.

config MACHINE_ID
	bool "compute unique machine-id"
	depends on FLEXIBLE_BOOTARGS
	depends on HAVE_DIGEST_SHA1
	help
	  Compute a persistent machine-specific id and store it to $global.machine_id.
	  The id is a hash of device-specific information added via
	  machine_id_set_hashable(). If multiple sources are available, the
	  information provided by the last call prior to the late initcall
	  set_machine_id() is used to generate the machine id from. Thus when
	  updating barebox the machine id might change.

	  global.bootm.provide_machine_id may be used to automatically set
	  the linux.bootargs.machine_id global variable with a value of
	  systemd.machine_id=${global.machine_id}

	  Note: if no hashable information is available no machine id will be passed
	  to the kernel.

config SERIAL_NUMBER_FIXUP_SYSTEMD_HOSTNAME
	bool "append board serial number to systemd.hostname= fixup"
	depends on FLEXIBLE_BOOTARGS
	help
	  When a systemd.hostname= kernel command line argument is
	  fixed up, append a `-${global.serial_number}' suffix.

	  This option without effect if global.bootm.provide_hostname
	  is unset.

config SYSTEMD_OF_WATCHDOG
	bool "inform devicetree-enabled kernel of used watchdog"
	depends on WATCHDOG && OFTREE && FLEXIBLE_BOOTARGS
	help
	  Sets the linux.bootargs.dyn.watchdog global variable with a value of
	  systemd.watchdog_device=/dev/WDOG if barebox succeeded in enabling
	  the watchdog WDOG prior to boot. WDOG is the alias of the watchdog
	  in the kernel device tree. If the kernel is booted without a device
	  tree or with one that lacks aliases, nothing is added.

config EXTERNAL_DTS_FRAGMENTS
	string "external dts file fragments"
	depends on OFTREE
	help
	  List of dts fragment files that will be appended to Barebox's device
	  tree(s) source when building the dtb file(s).  If multiple files are
	  listed, they will be appended in order.  Relative filenames will use
	  the dtc include search path.

	  A preprocessor macro based on the name of the main dts will be
	  defined, which allows the dts fragments to be based on which image of
	  a multi image build they are being used in. Given the dts filename
	  used for a board is "foo-board.dts" the external dts usage can be
	  limited to that board with

	  #ifdef foo_board_dts
	  ...
	  #endif

	  It is not intended that this is put into Barebox' defconfig files.
	  Instead, it's an external build system's job, like Yocto or buildroot,
	  to add dts fragments from outside the Barebox source tree into the
	  Barebox build.

menu "OP-TEE loading"

config HAVE_OPTEE
	bool
	help
	  This symbol is selected by configuration where barebox either
	  starts OP-TEE or runs while OP-TEE is running. Actual
	  bidirectional communication with OP-TEE is enabled via
	  CONFIG_OPTEE.

config OPTEE_SIZE
	hex
	default 0x02000000
	prompt "OP-TEE Memory Size"
	depends on HAVE_OPTEE
	help
	  Size to reserve in main memory for OP-TEE, including its shared memory.
	  Can be larger than the actual size used by OP-TEE, this is used to prevent
	  barebox from using or speculating into this area.
	  On i.MX, this should be at least OP-TEE CFG_TZDRAM + CFG_SHMEM_SIZE.
	  The name of the CFG_ options may differ on other platforms.

config OPTEE_SHM_SIZE
	hex
	default 0x400000
	prompt "OP-TEE Shared Memory Size"
	depends on HAVE_OPTEE
	help
	  Size to reserve in main memory for static OP-TEE shared memory
	  communication. The OP-TEE shared memory starts directly after
	  the OPTEE TZDRAM region. It should be chosen to be equivalent
	  to CFG_SHMEM_SIZE in OP-TEE.

	  This value can be used for fixing up the OP-TEE OF node.

	  A shared memory size of 0 means that only dynamic shared memory
	  will be supported for communication with OP-TEE. This is the only
	  mode supported by barebox anyway, but support needs to be enabled
	  in OP-TEE at compile-time.

config BOOTM_OPTEE
	bool
	prompt "support booting OP-TEE"
	depends on BOOTM && ARM32
	select HAVE_OPTEE
	select HAS_INSECURE_DEFAULTS
	help
	  OP-TEE is a trusted execution environment (TEE). With this option
	  enabled barebox supports starting optee_os as part of the bootm command.
	  Instead of the kernel bootm starts the optee_os binary which then starts
	  the kernel in nonsecure mode. Pass the optee_os binary with the -t option
	  or in the global.bootm.tee variable.

	  This mode of late loading OP-TEE just before the kernel is deprecated
	  in favor of early loading OP-TEE in the PBL (CONFIG_PBL_OPTEE).
	  Early-loading greatly reduces the attack surface and is the only mode
	  supported outside of ARMv7.

config PBL_OPTEE
	bool "Enable OP-TEE early start"
	depends on ARM
	select HAVE_OPTEE
	help
	  Allows starting OP-TEE during lowlevel initialization of the PBL.
	  Requires explicit support in the board's lowlevel file (for ARM32)
	  or the generic SoC support (for ARM64).

	  OP-TEE versions older than 3.11.0 do not support jumping back from OP-TEE
	  to barebox in THUMB2 mode. Make sure you do not compile barebox in THUMB2
	  mode for OP-TEE versions older than this.

endmenu

config FILETYPE_STRINGS
	bool "Print file types as strings"
	default y
	depends on FILETYPE
	help
	  Say yes here to include strings for filetypes in barebox. If disabled file
	  types will be printed as numbers only.

if FASTBOOT_BASE

menu "Android Fastboot"

config FASTBOOT_SPARSE
	bool
	select IMAGE_SPARSE
	prompt "Enable Fastboot sparse image support"
	help
	  Sparse images are a way for the fastboot protocol to write
	  images that are bigger than the available memory. If unsure,
	  say yes here.

config FASTBOOT_CMD_OEM
	bool
	prompt "Enable OEM commands"
	select HAS_INSECURE_DEFAULTS
	help
	  This option enables the fastboot "oem" group of commands. They allow to
	  executing arbitrary barebox commands and should be disabled in secure
	  environments.

endmenu

endif

endmenu

source "common/Kconfig.debug"

config DDR_SPD
	bool
	select CRC_ITU_T
