[Xoom Android Development] bigrushdog:
Module Management

Let's talk about what modules are.

Simply put, a kernel is a big blob of drivers in a single image. Modules are those same drivers but compiled to be "built out" of the primary zImage. There are a few reasons why modules are useful. Most devices have very limited boot partition. That means that the kernel, which is inside the boot image, must be limited in size as well. So when you need extra drivers, modules do the trick. Also, modules allow you to control what drivers are installed at what time. For example, if you want to run a USB Wireless Dongle, you may wish to remove the Android Wifi driver ( bcmdhd.ko ) so that Android Wireless services are disabled. Using modules, in conjunction with a USB Host Cable, and a Motorola Xoom ( running Eos preferable ;D ), we now have an extraordinarily powerful mobile device.​

How do I know what modules I need? There's too many!

That all depends on the piece of hardware you want to use or some feature you wish to utilize. You need to know what "chipset" your hardware has. I will begin cataloging what modules work with different hardware. IT IS HIGHLY ADVISED THAT YOU ONLY LOAD THE MODULE STACKS YOU NEED! IT IS LIKELY YOU DON'T HAVE ENOUGH ROOM ON THE SYSTEM PARTITION TO LOAD ALL THESE! Later, I'll work out a scheme to efficiently load modules from the Data partition.

​

Module Stacks

Often, the driver you wish to use is dependent on other modules. So how do you know what modules you need to complete your driver stack? When the kernel is compiled, the Makefile determines what other modules you need based on the drivers you have selected. Let's look at an example using the USB Wireless Dongle group.​

adb shell
lsmod

rndis_wlan 23105 0 - Live 0xbf1ee000
zd1211rw 47819 0 - Live 0xbf33b000
zd1201 17003 0 - Live 0xbf330000
zaurus 2190 0 - Live 0xbf32a000
rtl8192cu 84308 0 - Live 0xbf2b4000
rtlwifi 58705 1 rtl8192cu, Live 0xbf29d000
rtl8192c_common 49260 1 rtl8192cu, Live 0xbf26b000
rtl8187 48197 0 - Live 0xbf258000
eeprom_93cx6 1127 1 rtl8187, Live 0xbf0af000
rtl8150 8803 0 - Live 0xbf24f000
rt2800usb 9831 0 - Live 0xbf238000
rt2800lib 36395 1 rt2800usb, Live 0xbf228000
rt2500usb 16115 0 - Live 0xbf21e000
rt2x00usb 7451 3 rt73usb,rt2800usb,rt2500usb, Live 0xbf216000
rt2x00lib 29250 5 rt73usb,rt2800usb,rt2800lib,rt2500usb,rt2x00usb, Live 0xbf205000
mac80211 201396 8 zd1211rw,rtl8192cu,rtlwifi,rtl8187,rt2800lib,rt2x00usb,rt2x00lib,at76c50x_usb, Live 0xbf00f000

You can use the shell command "lsmod" to display all loaded module stacks.

The bottom row is the full USB Wireless Stack, all modules dependent on the mac80211 wireless subsystem. I'll use the driver rtl8192cu as an example in the following dependency stack.

rtl8192cu ----> rtlwifi ----> mac80211 ----> ( inside kernel ) cfg80211
|
|
|
|----> rtl8192c_common

So, in this case, you will need your driver, rtl8192cu, along with rtl8192c_common, rtlwifi and mac80211. Remember, only load the modules you need.​

How To Install Modules

The easiest way to install modules is to uses an init.d script so the modules load on boot. Such a script is included in the Development Overlay in the tools section in the first post. It looks like this

#!/system/bin/sh
#
# Load any extra modules

MODPATH=/system/lib/modules/

for i in `ls $MODPATH`
do
modprobe `basename $i .ko` >/dev/null 2>&1
done
exit 0

Or you can load them manually one by one thru a shell. I'll use rtl8187 as an example.

cd /system/lib/modules
modprobe rtl8187

"modprobe" is the command that loads modules. Modprobe is the prefered method over "insmod" as modprobe will load the driver and automatically load any dependencies the driver has.​

​