linux: allow firmware to be included in kernel
PATCH 1/1 linux: allow firmware to be included in kernel
Add functionality to use the kernel's built-in options to allow binary blobs to be included with the kernel. This is equivalent to the blobs existing in /lib/firmware, however are available earlier in the boot process. This may be useful in situations where a device probes before the rootfs is fully available (such as a squashfs not being loaded before a usb device probing).
--- linux/Config.in | 13 +++++++++++++ linux/linux.mk | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-)
linux/Config.in +13 -0
@@ -479,6 +479,19 @@ config BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". +config BR2_LINUX_KERNEL_EXTRA_FIRMWARE + bool "Build firmware binaries into the kernel" + help + Include the firmware from linux-firmware into the kernel + using the CONFIG_EXTRA_FIRMWARE option. + +config BR2_LINUX_KERNEL_EXTRA_FIRMWARE_BINARIES + string "External firmware blobs to build into the kernel binary" + depends on BR2_LINUX_KERNEL_EXTRA_FIRMWARE + help + Space delimited list of firmware to be built into the kernel. + These files must exist in the target's /lib/firmware. + # Linux extensions source "linux/Config.ext.in"
linux/linux.mk +6 -1
@@ -78,7 +78,8 @@ LINUX_MAKE_ENV = \ LINUX_INSTALL_IMAGES = YES LINUX_DEPENDENCIES += host-kmod \ - $(if $(BR2_PACKAGE_INTEL_MICROCODE),intel-microcode) + $(if $(BR2_PACKAGE_INTEL_MICROCODE),intel-microcode) \ + $(if $(BR2_LINUX_KERNEL_EXTRA_FIRMWARE),linux-firmware) # Starting with 4.16, the generated kconfig paser code is no longer # shipped with the kernel sources, so we need flex and bison, but
@@ -384,6 +385,10 @@ define LINUX_KCONFIG_FIXUP_CMDS $(call KCONFIG_ENABLE_OPT,CONFIG_FB) $(call KCONFIG_ENABLE_OPT,CONFIG_LOGO) $(call KCONFIG_ENABLE_OPT,CONFIG_LOGO_LINUX_CLUT224)) + $(if $(BR2_LINUX_KERNEL_EXTRA_FIRMWARE), + $(call KCONFIG_ENABLE_OPT,CONFIG_FIRMWARE_IN_KERNEL) + $(call KCONFIG_SET_OPT,CONFIG_EXTRA_FIRMWARE,$(BR2_LINUX_KERNEL_EXTRA_FIRMWARE_BINARIES)) + $(call KCONFIG_SET_OPT,CONFIG_EXTRA_FIRMWARE_DIR,"$(TARGET_DIR)/lib/firmware")) $(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS) $(PACKAGES_LINUX_CONFIG_FIXUPS)
Signature · 1 line
2.17.1
PATCH 1/1 linux: allow firmware to be included in kernel
Hello Sam,
Quoted 8 lines · On Thu, 22 Apr 2021 15:24:52 -0500 Sam Voss <[email protected]>…
Add functionality to use the kernel's built-in options to allow binary blobs to be included with the kernel. This is equivalent to the blobs existing in
/lib/firmware, however are available earlier in the boot process. This may be useful in situations where a device probes before the rootfs is fully available (such as a squashfs not being loaded before a usb device probing).Signed-off-by Sam Voss <[email protected]>
Including firmware in the kernel itself has some serious licensing
implications: it only works for firmware files that have a license that is compatible with the GPL. If their license is not GPL-compatible, then you cannot redistribute your kernel image.
Here is the help text of the corresponding option in the Linux kernel:
WARNING: If you include additional firmware files into your binary kernel image that are not available under the terms of the GPL, then it may be a violation of the GPL to distribute the resulting image since it combines both GPL and non-GPL work. You should consult a lawyer of your own before distributing such an image.
I am not a lawyer, but I think the wording is a bit unfortunate: I think if the firmware is under a license that is compatible with the GPL, it is fine. But if it has a non GPL-compatible license, it's a no-go.
So I would be OK to include this, but with the appropriate warning in the Buildroot options.
Best regards,
Thomas
Signature · 3 lines
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
PATCH 1/1 linux: allow firmware to be included in kernel
Hey Thomas,
Quoted 28 lines · Thomas Petazzoni
Hello Sam,
Quoted 8 lines · On Thu, 22 Apr 2021 15:24:52 -0500 Sam Voss <[email protected]>…
Add functionality to use the kernel's built-in options to allow binary blobs to be included with the kernel. This is equivalent to the blobs existing in
/lib/firmware, however are available earlier in the boot process. This may be useful in situations where a device probes before the rootfs is fully available (such as a squashfs not being loaded before a usb device probing).Signed-off-by Sam Voss <[email protected]>Including firmware in the kernel itself has some serious licensing
implications: it only works for firmware files that have a license that is compatible with the GPL. If their license is not GPL-compatible, then you cannot redistribute your kernel image.Here is the help text of the corresponding option in the Linux kernel:
WARNING: If you include additional firmware files into your binary kernel image that are not available under the terms of the GPL, then it may be a violation of the GPL to distribute the resulting image since it combines both GPL and non-GPL work. You should consult a lawyer of your own before distributing such an image.
Quoted 4 lines
I am not a lawyer, but I think the wording is a bit unfortunate: I think if the firmware is under a license that is compatible with the GPL, it is fine. But if it has a non GPL-compatible license, it's a no-go.
I completely agree with everything you said here - I had investigated (based on the kernels warning text) my use case, but had not considered wanting to propagate that warning out into the buildroot option as well
Quoted 3 lines
So I would be OK to include this, but with the appropriate warning in the Buildroot options.
I'll add that warning and send a v2 here momentarily.
Thanks for the quick review,
Signature · 13 lines
Sam Voss | Sr. Software Engineer | Commercial Avionics COLLINS AEROSPACE 400 Collins Road NE, Cedar Rapids, Iowa 52498, USA Tel: +1 319 263 4039 sam.voss at collins.com | collinsaerospace.com CONFIDENTIALITY WARNING: This message may contain proprietary and/or privileged information of Collins Aerospace and its affiliated companies. If you are not the intended recipient, please 1) Do not disclose, copy, distribute or use this message or its contents. 2) Advise the sender by return email. 3) Delete all copies (including all attachments) from your computer. Your cooperation is greatly appreciated.