Loading the wifi driver wcnwcnss_wlan.o using insmod in Android (not Linux)?


#1

Is it possible to load the wifi driver at start up via init.rc or (any other method) so that the wlan0 interface is created when Andorid boots. I would like to run Android without the GUI,Display etc. Android devices use GUI to load the wifi driver activity manager (am), Package Manager (pm) etc but in my scenario these layers do not exist at boot time and I would like to be able to load the driver via command line.
I can see that wlan0 interface is not created so wpa_supplicant will not be able to talk to the driver, hal layer etc. Could someone with knowledge of WiFi stack please help me understand how the wlan0 interface could be created at boot. Please note, setprop already sets the interface name via init.rc but after boot up, ifconfig shows that this interface is not created. Running wifi scan via GUI will lead to loading the driver and creating the interface but in my scenario I do not have gui, only command line and a headless dragonbard.
How can I insmod the wifi driver? Is it possible to build the stock wifi driver as a loadable module .ko instead of the normal .o object and if yes, are there any instructions on how to build the module externally using cross_compile.
Thanks in advance.


#2

Yes, this is the usual way on Android since there is no ‘auto-loading’ support.
I suggest you to add a rule on early init to insmod the module.

You can have a look at Android documentation:
https://source.android.com/devices/architecture/kernel/modular-kernels

insmode /path/to/module.ko

Which version of Android are you running, the qcom one (downloaded from qcom page) or the Linaro one (downloaded from aosp snaphots)?


#3

I’m running qcom’s version.


#4

Adnroid builds the below wifi objects which are statically linked into the .img.
qcomwlan_secif.o , wcnss_prealloc.o , wcnss_vreg.o , wcnss_wlan.o , wcnsscore.o
Has anybody built these as ‘loadable’ modules, i.e with a .ko extension?
For example, would you know how to build “wcnss_wlan.ko”


#5

I’m not sure why you want to change that.
You have to rebuild at least the kernel, you can follow steps indicated by the qcom ‘Software Build and installation Guide’ [1]. Before building the kernel, you have to change the kernel config so that CONFIG_WCNSS=m (m for loadable module (.ko), y for built-in ‘module’).

[1] https://developer.qualcomm.com/download/db410c/linux-android-software-build-and-installation-guide.pdf


#6

Thanks Loic, I’m building the kernel now with the “CONFIG_WLAN=m”
The reason why I’m trying to do this is because I need to use insmod from the command line/ init.rc or remotely and load the driver. I don’t have GUI.


#7

Hi Loic, my kernel was built successfully in standard form.
But when i changed wlan to ‘m’ it fails to build. This is the build failure message:

HOSTLD scripts/kconfig/conf
scripts/kconfig/conf --oldconfig Kconfig
.config:1433:warning: symbol value ‘m’ invalid for WLAN

It looks like it is not possible to build wlan as a loadable *.ko module after all.
Do you know any other way to do this?


#8

Usually, you need to use a kernel config editor (like make menuconfig) in order to avoid dependencies issues.
e.g. if a module depending on yours is builtin, it requires yours to be built-in as well, or both loadable modules…
Is CONFIG_MODULE enabled?


#9

Yes and Yes.
-config_module was enabled already. Dragonboard has other *.ko modules that are dynamically loaded.
-I used “make oldconfig” to configure the new kernel.

I appreciate your thoughts, is there any other issues that might help me build a loadable WLAN module? Please note this is possible for Linux and I’ve seen wifi modules being built as *.ko for the Linux kernel. However in Android it might be not so straight forward.


#10

Yes, but this is a different driver. You also need to check that the associated Kconfig (in wireless driver directory) allows tristate for the wcnss config flag.