8

I've learned that the firmware-subsystem uses udevd to copy a firmware to the created sysfs 'data' entry.

But how does this work in case of a built-in driver module where udevd hasn't started yet?

I'am using a 3.14 Kernel.

TIA!

steffenp
  • 129
  • 1
  • 8
  • 2
    Check `CONFIG_EXTRA_FIRMWARE`, `CONFIG_EXTRA_FIRMWARE_DIR` and `CONFIG_FIRMWARE_IN_KERNEL`. These kernel config option can be used to build the kernel binary with inbult firmware. And then it can be fetched by `request_firmware("firmware_name.bin")`. – Sanket Parmar Feb 12 '16 at 08:12
  • Far more interesting than loading them, is how it uses them to initialise the device. And no, I am not able to put it to words coherently at the moment. – Rui F Ribeiro Feb 12 '16 at 08:34
  • 1
    Thanks for the quick replies. @Rui F Ribeiro initialization and load onto the device is then driver depended. – steffenp Feb 12 '16 at 08:39
  • My question originates from a specific issue but I'll have to run some tests regarding @Sanket Parmar answers – steffenp Feb 12 '16 at 08:44
  • @steffenp maybe it's worth describing the specific issue then, in your question, in case it helps someone else as well when it's answered. – EightBitTony Feb 12 '16 at 10:58
  • 1
    Loading into the device, and how the device is initialized, is certainly device-dependent. How to get the firmware into the driver's hands is standarized as much as possible, for obvious reasons. – vonbrand Feb 12 '16 at 12:50
  • 1
    @EightBitTony your right. I realized that my question must rather be "is udevd really required for request_firmware()". Additionally I found this on [LKML](https://lkml.org/lkml/2013/8/5/175) – steffenp Feb 12 '16 at 13:19
  • 1
    @vonbrand exactly. Maybe this was a bit misleading: My question only refers to this 'standarized firmware loading process' provided by the kernel. – steffenp Feb 12 '16 at 13:24

2 Answers2

2

I read through the kernel sources, especially drivers/base/firmware_class.c, and discovered that

CONFIG_FW_LOADER_USER_HELPER 

would activate the udev firmware loading variant (obviously only usable for loadable modules when udev is running). But as mentioned on LKML this seems to be an obsolete method.

Furthermore firmware required by built-in modules is loaded from initramfs by fw_get_filesystem_firmware() through a kernel_read(), to be precise.

steffenp
  • 129
  • 1
  • 8
1

It is possible to build firmware images into the kernel itself by using the CONFIG_FIRMWARE_IN_KERNEL, CONFIG_EXTRA_FIRMWARE_DIR, and CONFIG_EXTRA_FIRMWARE kernel config options. This may be useful for cases where you either cannot or don't want to provide the firmware from userspace at runtime (for example, when the firmware in question is required for accessing the boot device, and you don't want to use an initrd).

Here's a more detailed explanation of the available options for firmware loading: https://wiki.tizen.org/wiki/Usage_and_Mechanism_of_kernel_function_%22request_firmware()%22#Load_firmware_from_kernel_image

Grodriguez
  • 906
  • 2
  • 11
  • 31