移植2.6.34内核,测试Intel e100 pci网卡时,发现这个版本的内核已经开始要求firmware和驱动分离了
没有对固件进行设置的话,网卡不能用
# ifconfig eth2 up
e100: eth2: e100_hw_init: e100_hw_init
drivers/net/e100.c e100_request_firmware 1238
e100: eth2: e100_request_firmware: Failed to load firmware "e100/d102e_ucode.bin": -22
e100: eth2: e100_open: Cannot open interface, aborting.
ifconfig: SIOCSIFFLAGS: Invalid argument
折腾了一会儿,终于搞定了。分为firmware编入内核和不编入内核两种情况。配置内核参考
The Linux kernel configuration item CONFIG_EXTRA_FIRMWARE:
prompt: External firmware blobs to build into the kernel binary
type: tristate
depends on:
defined in
found in Linux Kernels: from 2.6.27 release still available on 2.6.37 release
Help text
This option allows firmware to be built into the kernel, for the
cases where the user either cannot or doesn't want to provide it from
userspace at runtime (for example, when the firmware in question is
required for accessing the boot device, and the user doesn't want to
use an initrd).
This option is a string, and takes the (space-separated) names of the
firmware files -- the same names which appear in MODULE_FIRMWARE()
and request_firmware() in the source. These files should exist under
the directory specified by the EXTRA_FIRMWARE_DIR option, which is
by default the firmware/ subdirectory of the kernel source tree.
So, for example, you might set CONFIG_EXTRA_FIRMWARE="usb8388.bin",
copy the usb8388.bin file into the firmware/ directory, and build the
kernel. Then any request_firmware("usb8388.bin") will be
satisfied internally without needing to call out to userspace.
WARNING: If you include additional firmware files into your binary
kernel image which 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.-----------------------------------------------------------------------------
firmware编入内核:
这种方式不太符合内核GPL的初衷,不过对于在boot阶段,还没有挂载根文件系统时就要使用设备时,就成了唯一的手段。配置内核如下
Device Drivers --->
Generic Driver Options --->
固件编入内核,直接启动即可
firmware不编入内核,则配置如图
此时将firmware放置在 /lib/firmware/e100/d102e_ucode.bin
然后启动网卡,如果报错
# ifconfig eth2 up
e100: eth2: e100_hw_init: e100_hw_init
drivers/net/e100.c e100_request_firmware 1238
e100 0000:00:0f.0: firmware: requesting e100/d102e_ucode.bin
e100: eth2: e100_request_firmware: Failed to load firmware "e100/d102e_ucode.bin": -2
e100: eth2: e100_open: Cannot open interface, aborting.
ifconfig: SIOCSIFFLAGS: No such file or directory
说明没有应用程序处理内核发出的uevent,嵌入式设备通常没有udev和firmware_helper
不过busybox里的mdev灰常强大,包含了这2者的功能
echo /sbin/mdev > /proc/sys/kernel/hotplug