linux: allow firmware to be included in kernel
PATCH v3 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).
---
v2->v3:
Rebase onto master, take master's dependency of linux-firmware in all cases where enabled.
v1->v2:
Add warning for GPL implications of building a blog into kernel.
linux/Config.in | 20 ++++++++++++++++++++ linux/linux.mk | 4 ++++ 2 files changed, 24 insertions(+)
linux/Config.in +20 -0
@@ -470,6 +470,26 @@ 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. + + 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. + +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 +4 -0
@@ -372,6 +372,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) endef
Signature · 1 line
2.17.1
PATCH v3 1/1 linux: allow firmware to be included in kernel
Sam, All,
+Peter
On 2021-04-23 13:58 -0500, Sam Voss spake thusly:
Quoted 6 lines
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).
I'm a bit late to the party, but still...
Peter already provided a patch to ease including FW blobs in the kernel, see commits:
- af49734349c package/linux-firmware: also install into images for early loading support
- dacf9d78f22 linux: build after linux-firmware if enabled for early loading support
See below for further comments...
Quoted 32 lines
Signed-off-by Sam Voss <[email protected]>---
v2->v3:
Rebase onto master, take master's dependency of linux-firmware in all cases where enabled.
v1->v2:
Add warning for GPL implications of building a blog into kernel.linux/Config.in | 20 ++++++++++++++++++++ linux/linux.mk | 4 ++++ 2 files changed, 24 insertions(+)linux/Config.in +9
-0@@ -470,6 +470,26 @@ 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. + + 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
linux/Config.in config BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF · line 491
Quoted 10 lines
linux/Config.in +10
-0+ 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. + +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.
These two are just copies of the kernel config options. We can't reasonably have a Buildroot option for each of the kernel option. See further below, too...
Quoted 8 lines
linux/Config.in +0
-0# Linux extensions source "linux/Config.ext.in"linux/linux.mk +0
-0
linux/linux.mk define LINUX_KCONFIG_FIXUP_CMDS · line 378
Quoted 7 lines
linux/linux.mk +4
-0@@ -372,6 +372,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"))
So this is going against the spirit of af49734349c, which suggests that FW blobs be used out f BIANRIES_DIR, because they may be missing from TARGET_DIR eventually (e.g. on a second call to make during development)
And then, what prevents you from carrying that list in your kernel configuration (or configuration fragment)?
CONFIG_FIRMWARE_IN_KERNEL=y CONFIG_EXTRA_FIRMWARE="your list of stuff" CONFIG_EXTRA_FIRMWARE_DIR="$(BR_BINARIES_DIR)"
(BR_BINARIES_DIR is documented. Not. Patch welcome. ;-] )
(Aside: I'm always of the position that a configuration for a project is not limited to the Buildroot configuration, by far, but includes the config files for other components, post scripts, etc... and what can go in those does not belong to the Buildroot configuration.)
Leaving this pending in case other maintainers see differently, but if this is applied, this should at the very least change to look for FW blobs in BINARIES_DIR.
Regards,
Yann E. MORIN.
Quoted 10 lines
linux/linux.mk +0
-0$(call KCONFIG_DISABLE_OPT,CONFIG_GCC_PLUGINS) $(PACKAGES_LINUX_CONFIG_FIXUPS) endefSignature · 6 lines
2.17.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v3 1/1 linux: allow firmware to be included in kernel
Sam, All,
On 2021-04-24 10:09 +0200, Yann E. MORIN spake thusly:
Quoted 7 lines
On 2021-04-23 13:58 -0500, Sam Voss spake thusly:
Quoted 6 lines
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).
[--SNIP--]
Quoted 2 lines
These two are just copies of the kernel config options. We can't reasonably have a Buildroot option for each of the kernel option.
After reviewing this with other maintainers, and seeing that this is already pretty trivial to carry those options directly in the kernel's configuration, we've concluded that we do not need to have those two options in the Buildroot configuration.
Thanks!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 561 099 427 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH v3 1/1 linux: allow firmware to be included in kernel
Yann,
Quoted 11 lines · Yann E. MORIN
Sam, All,
On 2021-04-24 10:09 +0200, Yann E. MORIN spake thusly:
Quoted 7 lines
On 2021-04-23 13:58 -0500, Sam Voss spake thusly:
Quoted 6 lines
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).
Quoted 8 lines
[--SNIP--]
Quoted 2 lines
These two are just copies of the kernel config options. We can't reasonably have a Buildroot option for each of the kernel option.
After reviewing this with other maintainers, and seeing that this is already pretty trivial to carry those options directly in the kernel's configuration, we've concluded that we do not need to have those two options in the Buildroot configuration.
Honestly, BR_BINARIES_DIR is exactly what was missing that drove me to add this in the first place, because it didn't make sense having to have a buildroot-specific relative path in the kernel configuration for these items. Now that I know this exists, I'm fine with using that instead.
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.