| 1 |
# SPDX-License-Identifier: GPL-2.0 |
| 2 |
menu "Firmware loader" |
| 3 |
|
| 4 |
config FW_LOADER |
| 5 |
tristate "Firmware loading facility" if EXPERT |
| 6 |
select CRYPTO_LIB_SHA256 if FW_LOADER_DEBUG |
| 7 |
default y |
| 8 |
help |
| 9 |
This enables the firmware loading facility in the kernel. The kernel |
| 10 |
will first look for built-in firmware, if it has any. Next, it will |
| 11 |
look for the requested firmware in a series of filesystem paths: |
| 12 |
|
| 13 |
o firmware_class path module parameter or kernel boot param |
| 14 |
o /lib/firmware/updates/UTS_RELEASE |
| 15 |
o /lib/firmware/updates |
| 16 |
o /lib/firmware/UTS_RELEASE |
| 17 |
o /lib/firmware |
| 18 |
|
| 19 |
Enabling this feature only increases your kernel image by about |
| 20 |
828 bytes, enable this option unless you are certain you don't |
| 21 |
need firmware. |
| 22 |
|
| 23 |
You typically want this built-in (=y) but you can also enable this |
| 24 |
as a module, in which case the firmware_class module will be built. |
| 25 |
You also want to be sure to enable this built-in if you are going to |
| 26 |
enable built-in firmware (CONFIG_EXTRA_FIRMWARE). |
| 27 |
|
| 28 |
config FW_LOADER_DEBUG |
| 29 |
bool "Log filenames and checksums for loaded firmware" |
| 30 |
depends on DYNAMIC_DEBUG |
| 31 |
depends on FW_LOADER |
| 32 |
default FW_LOADER |
| 33 |
help |
| 34 |
Select this option to use dynamic debug to log firmware filenames and |
| 35 |
SHA256 checksums to the kernel log for each firmware file that is |
| 36 |
loaded. |
| 37 |
|
| 38 |
config RUST_FW_LOADER_ABSTRACTIONS |
| 39 |
bool "Rust Firmware Loader abstractions" |
| 40 |
depends on RUST |
| 41 |
select FW_LOADER |
| 42 |
help |
| 43 |
This enables the Rust abstractions for the firmware loader API. |
| 44 |
|
| 45 |
if FW_LOADER |
| 46 |
|
| 47 |
config FW_LOADER_PAGED_BUF |
| 48 |
bool |
| 49 |
|
| 50 |
config FW_LOADER_SYSFS |
| 51 |
bool |
| 52 |
|
| 53 |
config EXTRA_FIRMWARE |
| 54 |
string "Build named firmware blobs into the kernel binary" |
| 55 |
help |
| 56 |
Device drivers which require firmware can typically deal with |
| 57 |
having the kernel load firmware from the various supported |
| 58 |
/lib/firmware/ paths. This option enables you to build into the |
| 59 |
kernel firmware files. Built-in firmware searches are preceded |
| 60 |
over firmware lookups using your filesystem over the supported |
| 61 |
/lib/firmware paths documented on CONFIG_FW_LOADER. |
| 62 |
|
| 63 |
This may be useful for testing or if the firmware is required early on |
| 64 |
in boot and cannot rely on the firmware being placed in an initrd or |
| 65 |
initramfs. |
| 66 |
|
| 67 |
This option is a string and takes the (space-separated) names of the |
| 68 |
firmware files -- the same names that appear in MODULE_FIRMWARE() |
| 69 |
and request_firmware() in the source. These files should exist under |
| 70 |
the directory specified by the EXTRA_FIRMWARE_DIR option, which is |
| 71 |
/lib/firmware by default. |
| 72 |
|
| 73 |
For example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin", copy |
| 74 |
the usb8388.bin file into /lib/firmware, and build the kernel. Then |
| 75 |
any request_firmware("usb8388.bin") will be satisfied internally |
| 76 |
inside the kernel without ever looking at your filesystem at runtime. |
| 77 |
|
| 78 |
WARNING: If you include additional firmware files into your binary |
| 79 |
kernel image that are not available under the terms of the GPL, |
| 80 |
then it may be a violation of the GPL to distribute the resulting |
| 81 |
image since it combines both GPL and non-GPL work. You should |
| 82 |
consult a lawyer of your own before distributing such an image. |
| 83 |
|
| 84 |
NOTE: Compressed files are not supported in EXTRA_FIRMWARE. |
| 85 |
|
| 86 |
config EXTRA_FIRMWARE_DIR |
| 87 |
string "Firmware blobs root directory" |
| 88 |
depends on EXTRA_FIRMWARE != "" |
| 89 |
default "/lib/firmware" |
| 90 |
help |
| 91 |
This option controls the directory in which the kernel build system |
| 92 |
looks for the firmware files listed in the EXTRA_FIRMWARE option. |
| 93 |
|
| 94 |
config FW_LOADER_USER_HELPER |
| 95 |
bool "Enable the firmware sysfs fallback mechanism" |
| 96 |
select FW_LOADER_SYSFS |
| 97 |
select FW_LOADER_PAGED_BUF |
| 98 |
help |
| 99 |
This option enables a sysfs loading facility to enable firmware |
| 100 |
loading to the kernel through userspace as a fallback mechanism |
| 101 |
if and only if the kernel's direct filesystem lookup for the |
| 102 |
firmware failed using the different /lib/firmware/ paths, or the |
| 103 |
path specified in the firmware_class path module parameter, or the |
| 104 |
firmware_class path kernel boot parameter if the firmware_class is |
| 105 |
built-in. For details on how to work with the sysfs fallback mechanism |
| 106 |
refer to Documentation/driver-api/firmware/fallback-mechanisms.rst. |
| 107 |
|
| 108 |
The direct filesystem lookup for firmware is always used first now. |
| 109 |
|
| 110 |
If the kernel's direct filesystem lookup for firmware fails to find |
| 111 |
the requested firmware a sysfs fallback loading facility is made |
| 112 |
available and userspace is informed about this through uevents. |
| 113 |
The uevent can be suppressed if the driver explicitly requested it, |
| 114 |
this is known as the driver using the custom fallback mechanism. |
| 115 |
If the custom fallback mechanism is used userspace must always |
| 116 |
acknowledge failure to find firmware as the timeout for the fallback |
| 117 |
mechanism is disabled, and failed requests will linger forever. |
| 118 |
|
| 119 |
This used to be the default firmware loading facility, and udev used |
| 120 |
to listen for uvents to load firmware for the kernel. The firmware |
| 121 |
loading facility functionality in udev has been removed, as such it |
| 122 |
can no longer be relied upon as a fallback mechanism. Linux no longer |
| 123 |
relies on or uses a fallback mechanism in userspace. If you need to |
| 124 |
rely on one refer to the permissively licensed firmwared: |
| 125 |
|
| 126 |
https://github.com/teg/firmwared |
| 127 |
|
| 128 |
Since this was the default firmware loading facility at one point, |
| 129 |
old userspace may exist which relies upon it, and as such this |
| 130 |
mechanism can never be removed from the kernel. |
| 131 |
|
| 132 |
You should only enable this functionality if you are certain you |
| 133 |
require a fallback mechanism and have a userspace mechanism ready to |
| 134 |
load firmware in case it is not found. One main reason for this may |
| 135 |
be if you have drivers which require firmware built-in and for |
| 136 |
whatever reason cannot place the required firmware in initramfs. |
| 137 |
Another reason kernels may have this feature enabled is to support a |
| 138 |
driver which explicitly relies on this fallback mechanism. Only two |
| 139 |
drivers need this today: |
| 140 |
|
| 141 |
o CONFIG_LEDS_LP55XX_COMMON |
| 142 |
o CONFIG_DELL_RBU |
| 143 |
|
| 144 |
Outside of supporting the above drivers, another reason for needing |
| 145 |
this may be that your firmware resides outside of the paths the kernel |
| 146 |
looks for and cannot possibly be specified using the firmware_class |
| 147 |
path module parameter or kernel firmware_class path boot parameter |
| 148 |
if firmware_class is built-in. |
| 149 |
|
| 150 |
A modern use case may be to temporarily mount a custom partition |
| 151 |
during provisioning which is only accessible to userspace, and then |
| 152 |
to use it to look for and fetch the required firmware. Such type of |
| 153 |
driver functionality may not even ever be desirable upstream by |
| 154 |
vendors, and as such is only required to be supported as an interface |
| 155 |
for provisioning. Since udev's firmware loading facility has been |
| 156 |
removed you can use firmwared or a fork of it to customize how you |
| 157 |
want to load firmware based on uevents issued. |
| 158 |
|
| 159 |
Enabling this option will increase your kernel image size by about |
| 160 |
13436 bytes. |
| 161 |
|
| 162 |
If you are unsure about this, say N here, unless you are Linux |
| 163 |
distribution and need to support the above two drivers, or you are |
| 164 |
certain you need to support some really custom firmware loading |
| 165 |
facility in userspace. |
| 166 |
|
| 167 |
config FW_LOADER_USER_HELPER_FALLBACK |
| 168 |
bool "Force the firmware sysfs fallback mechanism when possible" |
| 169 |
depends on FW_LOADER_USER_HELPER |
| 170 |
help |
| 171 |
Enabling this option forces a sysfs userspace fallback mechanism |
| 172 |
to be used for all firmware requests which explicitly do not disable a |
| 173 |
a fallback mechanism. Firmware calls which do prohibit a fallback |
| 174 |
mechanism is request_firmware_direct(). This option is kept for |
| 175 |
backward compatibility purposes given this precise mechanism can also |
| 176 |
be enabled by setting the proc sysctl value to true: |
| 177 |
|
| 178 |
/proc/sys/kernel/firmware_config/force_sysfs_fallback |
| 179 |
|
| 180 |
If you are unsure about this, say N here. |
| 181 |
|
| 182 |
config FW_LOADER_COMPRESS |
| 183 |
bool "Enable compressed firmware support" |
| 184 |
help |
| 185 |
This option enables the support for loading compressed firmware |
| 186 |
files. The caller of firmware API receives the decompressed file |
| 187 |
content. The compressed file is loaded as a fallback, only after |
| 188 |
loading the raw file failed at first. |
| 189 |
|
| 190 |
Compressed firmware support does not apply to firmware images |
| 191 |
that are built into the kernel image (CONFIG_EXTRA_FIRMWARE). |
| 192 |
|
| 193 |
if FW_LOADER_COMPRESS |
| 194 |
config FW_LOADER_COMPRESS_XZ |
| 195 |
bool "Enable XZ-compressed firmware support" |
| 196 |
select FW_LOADER_PAGED_BUF |
| 197 |
select XZ_DEC |
| 198 |
default y |
| 199 |
help |
| 200 |
This option adds the support for XZ-compressed files. |
| 201 |
The files have to be compressed with either none or crc32 |
| 202 |
integrity check type (pass "-C crc32" option to xz command). |
| 203 |
|
| 204 |
config FW_LOADER_COMPRESS_ZSTD |
| 205 |
bool "Enable ZSTD-compressed firmware support" |
| 206 |
select ZSTD_DECOMPRESS |
| 207 |
help |
| 208 |
This option adds the support for ZSTD-compressed files. |
| 209 |
|
| 210 |
endif # FW_LOADER_COMPRESS |
| 211 |
|
| 212 |
config FW_CACHE |
| 213 |
bool "Enable firmware caching during suspend" |
| 214 |
depends on PM_SLEEP |
| 215 |
default y if PM_SLEEP |
| 216 |
help |
| 217 |
Because firmware caching generates uevent messages that are sent |
| 218 |
over a netlink socket, it can prevent suspend on many platforms. |
| 219 |
It is also not always useful, so on such platforms we have the |
| 220 |
option. |
| 221 |
|
| 222 |
If unsure, say Y. |
| 223 |
|
| 224 |
config FW_UPLOAD |
| 225 |
bool "Enable users to initiate firmware updates using sysfs" |
| 226 |
select FW_LOADER_SYSFS |
| 227 |
select FW_LOADER_PAGED_BUF |
| 228 |
help |
| 229 |
Enabling this option will allow device drivers to expose a persistent |
| 230 |
sysfs interface that allows firmware updates to be initiated from |
| 231 |
userspace. For example, FPGA based PCIe cards load firmware and FPGA |
| 232 |
images from local FLASH when the card boots. The images in FLASH may |
| 233 |
be updated with new images provided by the user. Enable this device |
| 234 |
to support cards that rely on user-initiated updates for firmware files. |
| 235 |
|
| 236 |
If unsure, say N. |
| 237 |
|
| 238 |
endif # FW_LOADER |
| 239 |
endmenu |