162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_cimenu "Firmware loader" 362306a36Sopenharmony_ci 462306a36Sopenharmony_ciconfig FW_LOADER 562306a36Sopenharmony_ci tristate "Firmware loading facility" if EXPERT 662306a36Sopenharmony_ci select CRYPTO_HASH if FW_LOADER_DEBUG 762306a36Sopenharmony_ci select CRYPTO_SHA256 if FW_LOADER_DEBUG 862306a36Sopenharmony_ci default y 962306a36Sopenharmony_ci help 1062306a36Sopenharmony_ci This enables the firmware loading facility in the kernel. The kernel 1162306a36Sopenharmony_ci will first look for built-in firmware, if it has any. Next, it will 1262306a36Sopenharmony_ci look for the requested firmware in a series of filesystem paths: 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci o firmware_class path module parameter or kernel boot param 1562306a36Sopenharmony_ci o /lib/firmware/updates/UTS_RELEASE 1662306a36Sopenharmony_ci o /lib/firmware/updates 1762306a36Sopenharmony_ci o /lib/firmware/UTS_RELEASE 1862306a36Sopenharmony_ci o /lib/firmware 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci Enabling this feature only increases your kernel image by about 2162306a36Sopenharmony_ci 828 bytes, enable this option unless you are certain you don't 2262306a36Sopenharmony_ci need firmware. 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci You typically want this built-in (=y) but you can also enable this 2562306a36Sopenharmony_ci as a module, in which case the firmware_class module will be built. 2662306a36Sopenharmony_ci You also want to be sure to enable this built-in if you are going to 2762306a36Sopenharmony_ci enable built-in firmware (CONFIG_EXTRA_FIRMWARE). 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciconfig FW_LOADER_DEBUG 3062306a36Sopenharmony_ci bool "Log filenames and checksums for loaded firmware" 3162306a36Sopenharmony_ci depends on CRYPTO = FW_LOADER || CRYPTO=y 3262306a36Sopenharmony_ci depends on DYNAMIC_DEBUG 3362306a36Sopenharmony_ci depends on FW_LOADER 3462306a36Sopenharmony_ci default FW_LOADER 3562306a36Sopenharmony_ci help 3662306a36Sopenharmony_ci Select this option to use dynamic debug to log firmware filenames and 3762306a36Sopenharmony_ci SHA256 checksums to the kernel log for each firmware file that is 3862306a36Sopenharmony_ci loaded. 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciif FW_LOADER 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ciconfig FW_LOADER_PAGED_BUF 4362306a36Sopenharmony_ci bool 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ciconfig FW_LOADER_SYSFS 4662306a36Sopenharmony_ci bool 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciconfig EXTRA_FIRMWARE 4962306a36Sopenharmony_ci string "Build named firmware blobs into the kernel binary" 5062306a36Sopenharmony_ci help 5162306a36Sopenharmony_ci Device drivers which require firmware can typically deal with 5262306a36Sopenharmony_ci having the kernel load firmware from the various supported 5362306a36Sopenharmony_ci /lib/firmware/ paths. This option enables you to build into the 5462306a36Sopenharmony_ci kernel firmware files. Built-in firmware searches are preceded 5562306a36Sopenharmony_ci over firmware lookups using your filesystem over the supported 5662306a36Sopenharmony_ci /lib/firmware paths documented on CONFIG_FW_LOADER. 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_ci This may be useful for testing or if the firmware is required early on 5962306a36Sopenharmony_ci in boot and cannot rely on the firmware being placed in an initrd or 6062306a36Sopenharmony_ci initramfs. 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci This option is a string and takes the (space-separated) names of the 6362306a36Sopenharmony_ci firmware files -- the same names that appear in MODULE_FIRMWARE() 6462306a36Sopenharmony_ci and request_firmware() in the source. These files should exist under 6562306a36Sopenharmony_ci the directory specified by the EXTRA_FIRMWARE_DIR option, which is 6662306a36Sopenharmony_ci /lib/firmware by default. 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ci For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy 6962306a36Sopenharmony_ci the usb8388.bin file into /lib/firmware, and build the kernel. Then 7062306a36Sopenharmony_ci any request_firmware("usb8388.bin") will be satisfied internally 7162306a36Sopenharmony_ci inside the kernel without ever looking at your filesystem at runtime. 7262306a36Sopenharmony_ci 7362306a36Sopenharmony_ci WARNING: If you include additional firmware files into your binary 7462306a36Sopenharmony_ci kernel image that are not available under the terms of the GPL, 7562306a36Sopenharmony_ci then it may be a violation of the GPL to distribute the resulting 7662306a36Sopenharmony_ci image since it combines both GPL and non-GPL work. You should 7762306a36Sopenharmony_ci consult a lawyer of your own before distributing such an image. 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci NOTE: Compressed files are not supported in EXTRA_FIRMWARE. 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ciconfig EXTRA_FIRMWARE_DIR 8262306a36Sopenharmony_ci string "Firmware blobs root directory" 8362306a36Sopenharmony_ci depends on EXTRA_FIRMWARE != "" 8462306a36Sopenharmony_ci default "/lib/firmware" 8562306a36Sopenharmony_ci help 8662306a36Sopenharmony_ci This option controls the directory in which the kernel build system 8762306a36Sopenharmony_ci looks for the firmware files listed in the EXTRA_FIRMWARE option. 8862306a36Sopenharmony_ci 8962306a36Sopenharmony_ciconfig FW_LOADER_USER_HELPER 9062306a36Sopenharmony_ci bool "Enable the firmware sysfs fallback mechanism" 9162306a36Sopenharmony_ci select FW_LOADER_SYSFS 9262306a36Sopenharmony_ci select FW_LOADER_PAGED_BUF 9362306a36Sopenharmony_ci help 9462306a36Sopenharmony_ci This option enables a sysfs loading facility to enable firmware 9562306a36Sopenharmony_ci loading to the kernel through userspace as a fallback mechanism 9662306a36Sopenharmony_ci if and only if the kernel's direct filesystem lookup for the 9762306a36Sopenharmony_ci firmware failed using the different /lib/firmware/ paths, or the 9862306a36Sopenharmony_ci path specified in the firmware_class path module parameter, or the 9962306a36Sopenharmony_ci firmware_class path kernel boot parameter if the firmware_class is 10062306a36Sopenharmony_ci built-in. For details on how to work with the sysfs fallback mechanism 10162306a36Sopenharmony_ci refer to Documentation/driver-api/firmware/fallback-mechanisms.rst. 10262306a36Sopenharmony_ci 10362306a36Sopenharmony_ci The direct filesystem lookup for firmware is always used first now. 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci If the kernel's direct filesystem lookup for firmware fails to find 10662306a36Sopenharmony_ci the requested firmware a sysfs fallback loading facility is made 10762306a36Sopenharmony_ci available and userspace is informed about this through uevents. 10862306a36Sopenharmony_ci The uevent can be suppressed if the driver explicitly requested it, 10962306a36Sopenharmony_ci this is known as the driver using the custom fallback mechanism. 11062306a36Sopenharmony_ci If the custom fallback mechanism is used userspace must always 11162306a36Sopenharmony_ci acknowledge failure to find firmware as the timeout for the fallback 11262306a36Sopenharmony_ci mechanism is disabled, and failed requests will linger forever. 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ci This used to be the default firmware loading facility, and udev used 11562306a36Sopenharmony_ci to listen for uvents to load firmware for the kernel. The firmware 11662306a36Sopenharmony_ci loading facility functionality in udev has been removed, as such it 11762306a36Sopenharmony_ci can no longer be relied upon as a fallback mechanism. Linux no longer 11862306a36Sopenharmony_ci relies on or uses a fallback mechanism in userspace. If you need to 11962306a36Sopenharmony_ci rely on one refer to the permissively licensed firmwared: 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci https://github.com/teg/firmwared 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ci Since this was the default firmware loading facility at one point, 12462306a36Sopenharmony_ci old userspace may exist which relies upon it, and as such this 12562306a36Sopenharmony_ci mechanism can never be removed from the kernel. 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_ci You should only enable this functionality if you are certain you 12862306a36Sopenharmony_ci require a fallback mechanism and have a userspace mechanism ready to 12962306a36Sopenharmony_ci load firmware in case it is not found. One main reason for this may 13062306a36Sopenharmony_ci be if you have drivers which require firmware built-in and for 13162306a36Sopenharmony_ci whatever reason cannot place the required firmware in initramfs. 13262306a36Sopenharmony_ci Another reason kernels may have this feature enabled is to support a 13362306a36Sopenharmony_ci driver which explicitly relies on this fallback mechanism. Only two 13462306a36Sopenharmony_ci drivers need this today: 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_ci o CONFIG_LEDS_LP55XX_COMMON 13762306a36Sopenharmony_ci o CONFIG_DELL_RBU 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci Outside of supporting the above drivers, another reason for needing 14062306a36Sopenharmony_ci this may be that your firmware resides outside of the paths the kernel 14162306a36Sopenharmony_ci looks for and cannot possibly be specified using the firmware_class 14262306a36Sopenharmony_ci path module parameter or kernel firmware_class path boot parameter 14362306a36Sopenharmony_ci if firmware_class is built-in. 14462306a36Sopenharmony_ci 14562306a36Sopenharmony_ci A modern use case may be to temporarily mount a custom partition 14662306a36Sopenharmony_ci during provisioning which is only accessible to userspace, and then 14762306a36Sopenharmony_ci to use it to look for and fetch the required firmware. Such type of 14862306a36Sopenharmony_ci driver functionality may not even ever be desirable upstream by 14962306a36Sopenharmony_ci vendors, and as such is only required to be supported as an interface 15062306a36Sopenharmony_ci for provisioning. Since udev's firmware loading facility has been 15162306a36Sopenharmony_ci removed you can use firmwared or a fork of it to customize how you 15262306a36Sopenharmony_ci want to load firmware based on uevents issued. 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci Enabling this option will increase your kernel image size by about 15562306a36Sopenharmony_ci 13436 bytes. 15662306a36Sopenharmony_ci 15762306a36Sopenharmony_ci If you are unsure about this, say N here, unless you are Linux 15862306a36Sopenharmony_ci distribution and need to support the above two drivers, or you are 15962306a36Sopenharmony_ci certain you need to support some really custom firmware loading 16062306a36Sopenharmony_ci facility in userspace. 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciconfig FW_LOADER_USER_HELPER_FALLBACK 16362306a36Sopenharmony_ci bool "Force the firmware sysfs fallback mechanism when possible" 16462306a36Sopenharmony_ci depends on FW_LOADER_USER_HELPER 16562306a36Sopenharmony_ci help 16662306a36Sopenharmony_ci Enabling this option forces a sysfs userspace fallback mechanism 16762306a36Sopenharmony_ci to be used for all firmware requests which explicitly do not disable a 16862306a36Sopenharmony_ci a fallback mechanism. Firmware calls which do prohibit a fallback 16962306a36Sopenharmony_ci mechanism is request_firmware_direct(). This option is kept for 17062306a36Sopenharmony_ci backward compatibility purposes given this precise mechanism can also 17162306a36Sopenharmony_ci be enabled by setting the proc sysctl value to true: 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci /proc/sys/kernel/firmware_config/force_sysfs_fallback 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci If you are unsure about this, say N here. 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciconfig FW_LOADER_COMPRESS 17862306a36Sopenharmony_ci bool "Enable compressed firmware support" 17962306a36Sopenharmony_ci help 18062306a36Sopenharmony_ci This option enables the support for loading compressed firmware 18162306a36Sopenharmony_ci files. The caller of firmware API receives the decompressed file 18262306a36Sopenharmony_ci content. The compressed file is loaded as a fallback, only after 18362306a36Sopenharmony_ci loading the raw file failed at first. 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ci Compressed firmware support does not apply to firmware images 18662306a36Sopenharmony_ci that are built into the kernel image (CONFIG_EXTRA_FIRMWARE). 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ciif FW_LOADER_COMPRESS 18962306a36Sopenharmony_ciconfig FW_LOADER_COMPRESS_XZ 19062306a36Sopenharmony_ci bool "Enable XZ-compressed firmware support" 19162306a36Sopenharmony_ci select FW_LOADER_PAGED_BUF 19262306a36Sopenharmony_ci select XZ_DEC 19362306a36Sopenharmony_ci default y 19462306a36Sopenharmony_ci help 19562306a36Sopenharmony_ci This option adds the support for XZ-compressed files. 19662306a36Sopenharmony_ci The files have to be compressed with either none or crc32 19762306a36Sopenharmony_ci integrity check type (pass "-C crc32" option to xz command). 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ciconfig FW_LOADER_COMPRESS_ZSTD 20062306a36Sopenharmony_ci bool "Enable ZSTD-compressed firmware support" 20162306a36Sopenharmony_ci select ZSTD_DECOMPRESS 20262306a36Sopenharmony_ci help 20362306a36Sopenharmony_ci This option adds the support for ZSTD-compressed files. 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_ciendif # FW_LOADER_COMPRESS 20662306a36Sopenharmony_ci 20762306a36Sopenharmony_ciconfig FW_CACHE 20862306a36Sopenharmony_ci bool "Enable firmware caching during suspend" 20962306a36Sopenharmony_ci depends on PM_SLEEP 21062306a36Sopenharmony_ci default y if PM_SLEEP 21162306a36Sopenharmony_ci help 21262306a36Sopenharmony_ci Because firmware caching generates uevent messages that are sent 21362306a36Sopenharmony_ci over a netlink socket, it can prevent suspend on many platforms. 21462306a36Sopenharmony_ci It is also not always useful, so on such platforms we have the 21562306a36Sopenharmony_ci option. 21662306a36Sopenharmony_ci 21762306a36Sopenharmony_ci If unsure, say Y. 21862306a36Sopenharmony_ci 21962306a36Sopenharmony_ciconfig FW_UPLOAD 22062306a36Sopenharmony_ci bool "Enable users to initiate firmware updates using sysfs" 22162306a36Sopenharmony_ci select FW_LOADER_SYSFS 22262306a36Sopenharmony_ci select FW_LOADER_PAGED_BUF 22362306a36Sopenharmony_ci help 22462306a36Sopenharmony_ci Enabling this option will allow device drivers to expose a persistent 22562306a36Sopenharmony_ci sysfs interface that allows firmware updates to be initiated from 22662306a36Sopenharmony_ci userspace. For example, FPGA based PCIe cards load firmware and FPGA 22762306a36Sopenharmony_ci images from local FLASH when the card boots. The images in FLASH may 22862306a36Sopenharmony_ci be updated with new images provided by the user. Enable this device 22962306a36Sopenharmony_ci to support cards that rely on user-initiated updates for firmware files. 23062306a36Sopenharmony_ci 23162306a36Sopenharmony_ci If unsure, say N. 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ciendif # FW_LOADER 23462306a36Sopenharmony_ciendmenu 235