user3024650
user3024650

Reputation: 19

Failing to load firmware in Android

This question can be marked as a duplicated of this "kernel module cannot find firmware file on Android device; where should it be?" but since I could not able to solve my issue I thought of posting the question.

I am working in Android LOllipop and my Kernel module, the wifi module 8192du.ko is copied to /system/lib/modules folder and the firmware rtl81992dufw.bin was copied to "/system/etc/firmware/rtlwifi/" as per the system/core/init/devices.c file.

But I am getting "E/WifiHW ( 161): Failed to open wlan fw path param (No such file or directory)" error.

int wifi_change_fw_path(const char *fwpath){
int len;
int fd;
int ret = 0;

if (!fwpath)
    return ret;
fd = TEMP_FAILURE_RETRY(open(WIFI_DRIVER_FW_PATH_PARAM, O_WRONLY));
if (fd < 0) {
    ALOGE("Failed to open wlan fw path param (%s)", strerror(errno));
    return -1;
}
len = strlen(fwpath) + 1;
if (TEMP_FAILURE_RETRY(write(fd, fwpath, len)) != len) {
    ALOGE("Failed to write wlan fw path param (%s)", strerror(errno));
    ret = -1;
}
close(fd);
return ret;}

This is my wifi.c code and I have defined the WIFI_DRIVER_FW_PATH_PARAM macro as "/system/etc/firmware/rtlwifi/".

When I copy the firmware to /system/lib/firmware/rtlwifi/ path as per the driver Makefile in kernel, I am getting Read-only filesystem error.

Both the ways I am stuck up with the firmware path issue....Any help?

Upvotes: 0

Views: 2979

Answers (2)

remcycles
remcycles

Reputation: 1543

That error message is referring to a different problem. In my hardware/libhardware_legacy/wifi/wifi.c I have:

#ifndef WIFI_DRIVER_FW_PATH_PARAM
#define WIFI_DRIVER_FW_PATH_PARAM "/sys/module/wlan/parameters/fwpath"
#endif

That sysfs entry allows the firmware to change states, I think. More info here: https://www.reddit.com/r/oneplusone/comments/3c4nen/debian_running_on_oneplus_one_lxde_desktop/

wcnss_service runs fine after all this madness and no more errors in kernel log. Now to start the WiFi card, after some more trial and error and luck, it turns out you have to write "sta" to /sys/module/wlan/parameters/fwpath echo sta > /sys/module/wlan/parameters/fwpath Then the WiFi interface is finally visible with ifconfig -a. In my case, my driver loads as /sys/module/rtl8192cu/parameters, but there is no fwpath parameter there. I'm still trying to figure out how to handle that case.

As for rtl81992dufw.bin, it may be loaded correctly by your driver 8192du.ko when insmod is run by wifi.c and the kernel loads it. Check dmesg instead of logcat to see if it's loading correctly. If not, check the driver code to see where it expects to find the firmware.

Upvotes: 1

Oleksandr Kravchuk
Oleksandr Kravchuk

Reputation: 6327

So you say that

#define WIFI_DRIVER_FW_PATH_PARAM "/system/etc/firmware/rtlwifi/"

which you pass as a path to open(). So you're trying to open folder, not file.

Upvotes: 0

Related Questions