kernel module cannot find firmware file on Android

2019-03-31 07:42发布

问题:

I am having trouble placing firmware properly on an Android device, I keep getting:

<3>[ 3590.997375] usb 3-1.4: ath9k_htc: Firmware - htc_7010.fw not found

If on a standard linux machine running Ubuntu, I place htc_7010.fw in /lib/firmware then I do not get this error.

However, if I place this firmware in /lib/firmware on Android, I still get the error. I have tried all of the following directories and still receive the error:

/lib/firmware
/etc/firmware
/system/lib/modules
/system/lib/firmware
/system/etc

No such luck... what dictates where the firmware should be, and how could I determine which directories it is scanning for the firmware?

回答1:

On Android (ICS anyways) it has its own daemon/service (or whatever you want to call it) to manage hotplug events, including firmware requests. In <android>/system/core/init/devices.c, there are two #defines that specify locations where firmware will be checked:

#define FIRMWARE_DIR1   "/etc/firmware"
#define FIRMWARE_DIR2   "/vendor/firmware"

On my initial build of the ICS filesystem, /etc/firmware didn't exist (and the etc directory seems to be a symbolic link created at boot/init time). The directory I had to place firmware in on my NFS mounted rootfs was <mount point>/system/etc/firmware

After doing this, request_firmware() calls from my module successfully completed.



回答2:

I had a similar problem with my firmware named : down3.bin
(Beforehand, I had insert my module "io_ti.ko" with # insmod of course)

When I plugged my device (USB-RS232 converter, Digi International EdgeportTI1 port adapter) on my Android tablet (Samsung Galaxy Tab 2), he was unable to find his firmware in "linux android adapted directories". So, like you, I tried to put my "down3.bin" in:

/lib/firmware
/etc/firmware
/system/lib/modules
/system/lib/firmware
/system/etc

with :# dmesg I still had error :

<6>[00000.00000] io_ti 1-1:1.0 : Edgeport TI 1 port adapter converter detected
<6>[00000.00000] Failed to load image "edgeport/down3.bin" err-2
<6>[00000.00000] io_ti:probe of 1-1:1.0 failed with error -5
err -2 = [ENOENT] = No such file or directory.

In fact, like you mentionned :

In <android>/system/core/init/devices.c, there are two #defines that specify locations where firmware will be checked:

#define FIRMWARE_DIR1   "/etc/firmware"
#define FIRMWARE_DIR2   "/vendor/firmware"

- So you have to put your firmware in one of these directories. It worked properly for me, hopefully.




回答3:

The kernel executes a user-space script to load the firmware. Check if you have the script on the right location.

  1. Check the which location the kernel looks for the script. / # cat /proc/sys/kernel/hotplug. The default location is "/sbin/hotplug".
  2. Check if you have the script, the kernel is looking for, in this location. On android the script should be "/system/busybox/sbin/mdev", so you can set "/proc/sys/kernel/hotplug" to this, if it is not.