Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Wow this is very useful information and it led me to the solution for my problem when making a custom USB kernel module for a device requiring firmware.</p> <p>Basically, every Ubuntu brings a new rehash of hal,sysfs,devfs,udev,and so on...and things just change. In fact I read they stopped using hal.</p> <p>So let's reverse engineer this yet again so it's pertinent to the latest [Ubuntu] systems.</p> <p>On Ubuntu Lucid (the latest at time of writing), <code>/lib/udev/rules.d/50-firmware.rules</code> is used. This file calls the binary <code>/lib/udev/firmware</code>, where magic happens.</p> <p>Listing: /lib/udev/rules.d/50-firmware.rules</p> <pre><code># firmware-class requests, copies files into the kernel SUBSYSTEM=="firmware", ACTION=="add", RUN+="firmware --firmware=$env{FIRMWARE} --devpath=$env{DEVPATH}" </code></pre> <p>The magic should be something along these lines (source: <a href="http://lwn.net/Kernel/LDD3/" rel="noreferrer"><em>Linux Device Drivers, 3rd Ed., Ch. 14: The Linux Device Model</a></em>):</p> <ul> <li>echo 1 to <code>loading</code></li> <li>copy firmware to <code>data</code></li> <li>on failure, echo -1 to <code>loading</code> and halt firmware loading process</li> <li>echo 0 to <code>loading</code> (signal the kernel)</li> <li>then, a specific kernel module receives the data and pushes it to the device</li> </ul> <p>If you look at Lucid's source page for udev, in <code>udev-151/extras/firmware/firmware.c</code>, the source for that firmware /lib/udev/firmware binary, that's exactly what goes on.</p> <p>Excerpt: Lucid source, udev-151/extras/firmware/firmware.c</p> <pre><code> util_strscpyl(datapath, sizeof(datapath), udev_get_sys_path(udev), devpath, "/data", NULL); if (!copy_firmware(udev, fwpath, datapath, statbuf.st_size)) { err(udev, "error sending firmware '%s' to device\n", firmware); set_loading(udev, loadpath, "-1"); rc = 4; goto exit; }; set_loading(udev, loadpath, "0"); </code></pre> <p>Additionally, many devices use an Intel HEX format (textish files containing checksum and other stuff) (wiki it i have no reputation and no ability to link). The kernel program ihex2fw (called from Makefile in kernel_source/lib/firmware on .HEX files) converts these HEX files to an arbitrary-designed binary format that the Linux kernel then picks up with <code>request_ihex_firmware</code>, because they thought reading text files in the kernel was silly (it would slow things down).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload