# SPDX-FileCopyrightText: 2013 Stefano Babic <stefano.babic@swupdate.org>
#
# SPDX-License-Identifier: GPL-2.0-only

#
# For a description of the syntax of this configuration file,
# see scripts/kbuild/config-language.txt.
#

menu "Image Handlers"

config ARCHIVE
	bool "archive"
	depends on HAVE_LIBARCHIVE
	default n
	help
	  Handler using the libarchive to extract tarballs
	  into a filesystem.

comment "archive support needs libarchive"
	depends on !HAVE_LIBARCHIVE

config LOCALE
	bool "Locale support for filenames"
	depends on ARCHIVE
	default y
	help
	  Option to remove attempts to use locale in systems
	  without locale support in toolchain.

config BOOTLOADERHANDLER
	bool "bootloader"
	default n
	help
	  Enable it to change bootloader environment
	  during the installation process.

config CFI
	bool "cfi"
	depends on MTD
	default n
	help
	  Handler to store images in flash in raw mode,
	  without UBI

config CFIHAMMING1
	bool "NAND in raw mode with 1bit Hamming OOB (TI)"
	depends on MTD
	default n
	help
	  On certain TI's omaps (for example, DM3730 or AM3517),
	  the first bootloader (MLO or SPL) must be saved with one bit
	  Hamming correction because this is requested by the SOC's ROM.
	  However, the Linux driver must use for the rest of the NAND a more
	  powerful algorithm to make data reliable, and this causes that
	  it is not possible to update SPL by letting the driver to handle
	  the OOB area. This handler raws the NAND in raw mode, computing
	  the ECC with 1 bit Hamming Code and saving it into OOB
	  (assumes sector size of 512 and page size of 2048).

	  You do not need this if you do not have an OMAP SoC.

config COPY
	bool "copy"
	default n
	help
	  This works as script and copies files / images to a
	  different destination. It requires a chained handler
	  so that it works even with flash or special devices.

config DELTA
	bool "delta"
	depends on HAVE_LIBCURL
	depends on HAVE_ZSTD
	depends on HAVE_ZCK
	select CHANNEL_CURL
	default n
	help
	  Handler to enable delta images. The handler computes the differences
	  and download the missing parts, and pass the resulting image to the
	  next handler.

config DISKPART
	bool "diskpart"
	depends on HAVE_LIBFDISK
	default n
	help
	  Handler to partition a disk, eMMC or SD

comment "diskpart support needs libfdisk"
	depends on !HAVE_LIBFDISK

config DISKPART_FORMAT
	bool "diskpart extension for creating file systems"
	depends on DISKPART
	select DISKFORMAT
	default n
	help
	  This extension allows formatting newly created partitions.

config DISKFORMAT_HANDLER
	bool "diskformat handler for creating file systems"
	select DISKFORMAT
	default n
	help
	  The diskformat handler allows creating filesystems on empty
	  partitions.

source "fs/Kconfig"

config LUASCRIPTHANDLER
	bool "Lua Script"
	depends on LUA
	default n
	help
	  Handler to be called for pre- and post scripts
	  written in Lua.

config EMBEDDED_LUA_HANDLER
	bool "Embed Lua handler in SWUpdate binary"
	depends on LUA
	default n
	help
	  Embed the Lua handler source code file into the
	  SWUpdate binary.

	  If enabled, a swupdate_handlers.lua will *not*
	  be loaded from disk at SWUpdate startup.

	  Note: Exactly one Lua source code file is embedded
	  into the binary, i.e., possible dependencies either
	  have to be deployed on the target system or put into
	  the one embedded Lua source code file.

config EMBEDDED_LUA_HANDLER_SOURCE
	string "Lua handler file"
	depends on EMBEDDED_LUA_HANDLER
	default "swupdate_handlers.lua"
	help
	  Path to the Lua handler source code file to be
	  embedded into the SWUpdate binary.


config EMMC_HANDLER
	bool "eMMC handler"
	default n
	help
	  This handler allows to switch the boot partitions via
	  the eMMC internal CSD register. One common use case is to 
	  upgrade the bootloader, using the two hardware partitions
	  with a dual-copy concept. This guarantees that the upgrade
	  is power-cut safe.

config RAW
	bool "raw"
	default n
	help
	  This is a simple handler that simply copies
	  into the destination.

config RDIFFHANDLER
	bool "rdiff"
	depends on HAVE_LIBRSYNC
	default n
	help
	  Add support for applying librsync's rdiff patches,
	  see http://librsync.sourcefrog.net/

comment "rdiff support needs librsync"
	depends on !HAVE_LIBRSYNC

config READBACKHANDLER
	bool "readback"
	depends on HASH_VERIFY
	default n
	help
	  To verify that an image was written properly, this readback handler
	  calculates the sha256 hash of a partition (or part of it) and compares
	  it against a given hash value.

	  This is a post-install handler running at the same time as
	  post-install scripts.

config REMOTE_HANDLER
	bool "Remote handler"
	depends on HAVE_LIBZEROMQ
	default n
	help
	  Sometimes the update process should be done
	  by another process, where code is already
	  provided. The remote handler let communicate
	  an external process with SWUpdate, sending
	  the image to be updated with the help of the
	  zeromq library.

comment "remote handler needs zeromq"
	depends on !HAVE_LIBZEROMQ

config SHELLSCRIPTHANDLER
	bool "shellscript"
	default n
	help
	  Handler to be called for pre- and post scripts
	  written as shell scripts. The default shell /bin/sh
	  is called.

config SWUFORWARDER_HANDLER
	bool "SWU forwarder"
	depends on HAVE_LIBCURL
	depends on HAVE_LIBWEBSOCKETS
	depends on HAVE_URIPARSER
	select CHANNEL_CURL
	default n
	help
	  This allows one to build a chain of updater. A
	  SWU can contain other SWUs for other systems.
	  The handler takes a list of URLs and forwards the
	  embedded SWU to the other devices using the
	  webserver REST API.

comment "swuforward handler needs libcurl"
	depends on !HAVE_LIBCURL

comment "swuforward handler needs websockets and uriparser"
	depends on !HAVE_LIBWEBSOCKETS || !HAVE_URIPARSER

config SSBLSWITCH
	bool "Second Stage Switcher"
	depends on MTD
	default n
	help
	  This handler allows one to switch between two software sets
	  based on an administration block stored in flash (CFI interface).
	  It works like the switch of UBI and allows one to switch in an atomic
	  way between two software sets. It can be used to reliably update
	  a second stage bootloader.

config UBIVOL
	bool "ubivol"
	default n
	depends on HAVE_LIBUBI
	depends on MTD
	help
	  ubi is the default format for NAND device.
	  Say Y if you have NAND or you use UBI on
	  your system.

comment "ubivol support needs libubi"
	depends on !HAVE_LIBUBI

config UBIATTACH
	bool "Automatically attach UBI devices"
	default y
	depends on UBIVOL
	help
	  If this option is enabled, swupdate will try to attach
	  UBI devices to all MTD devices.

	  Make sure UBIBLACKLIST or UBIWHITELIST is set correctly,
	  since attaching a UBI device will write to it if it is
	  found to be empty, and that may destroy already existing
	  content on that device.

config UBIBLACKLIST
	string "List of MTD devices to be excluded for UBI"
	depends on UBIATTACH
	help
	  Define a list of MTD devices that are excluded
	  by scan_mtd_device. The devices are still available
	  as raw devices.
	  The list can be set as a string with the mtd numbers.
	  Examples: "0 1 2"
	  This excludes mtd0-mtd1-mtd2 to be searched for UBI volumes

config UBIWHITELIST
	string "List of MTD devices that must have UBI"
	depends on UBIATTACH
	help
	  Define a list of MTD devices that are planned to have
	  always UBI. If first attach fails, the device is erased
	  and tried again.
	  The list can be set as a string with the mtd numbers.
	  Examples: "0 1 2"
	  This sets mtd0-mtd1-mtd2 to be used as UBI volumes.
	  UBIBLACKLIST has priority on UBIWHITELIST.

config UBIVIDOFFSET
	int "VID Header Offset"
	depends on UBIATTACH
	default 0
	help
	  Force UBI to set a VID header offset to be 2048 bytes
	  instead of the value reported by the kernel.
	  In other words, you may ask UBI to avoid using sub-pages.
	  This is not recommended since this will require
	  more storage overhead, but may be useful
	  if your NAND driver incorrectly reports that it can handle
	  sub-page accesses when it should not.

config UCFWHANDLER
	bool "microcontroller firmware update"
	depends on HAVE_LIBGPIOD
	default n
	help
	  Simple protocol to upgrade a microcontroller
	  via UART.

comment "Microcontroller handler depends on libgpiod"
	depends on !HAVE_LIBGPIOD

config UNIQUEUUID
	bool "uniqueuuid"
	depends on HAVE_LIBBLKID
	default n
	help
	  This handler checks that no filesystem on the device has
	  a UUID from a list (list is added as part of "properties"
	  in sw-description) for this handler.
	  This is useful for bootloader (like GRUB) that use UUID to
	  select the partition to be started, and in case two or
	  more filesystem have the same UUID, a wrong one is started.
	  This handler is a partition handler and it is guaranteed that
	  it runs before any image is installed on the device.

comment "uniqueuuid support needs libblkid"
	depends on !HAVE_LIBBLKID

endmenu
