[Hero CDMA Android Development] s0be:
This is the beginnings of work to let us use the wl12xx driver from more recent kernels with our hero kernels. Currently, I have loaded the modules, and believe they function, but have no way to test it. If you follow these steps, and enable wifi on your phone, it will reboot.

This may implode your phone into a wormhole and summon forth demons from Hell or Detroit.

** Update a change has been made in compat-wireless now, all references to the sdio module are now wl1251_sdio **

Preparation:

First, pick a location where you're going to do your work. I use /usr/src in my example. My next assumption is you have a working kernel tree and android repo sync. I used Decad3nce's htc-kernel-heroc tree for this. To get a working tree and repo you can do:

$ mkdir android
$ cd android
$ repo init -u git://android.git.kernel.org/platform/manifest.git
$ repo sync
$ git clone git://github.com/Decad3nce/htc-kernel-heroc.git htc-kernel-heroc --depth=1

The --depth=1 saves you from having to checkout the whole tree(cuts the clone time down significantly.

Next, you need to patch in the msm_wifi fix:

$ cd htc-kernel-heroc
$ wget http://bobcopeland.com/srcs/android/msm_wifi.patch
$ patch -p1 < msm_wifi.patch
patching file arch/arm/mach-msm/Kconfig
Hunk #1 succeeded at 236 with fuzz 2 (offset 158 lines).
patching file arch/arm/mach-msm/Makefile
Hunk #1 FAILED at 36.
1 out of 1 hunk FAILED -- saving rejects to file arch/arm/mach-msm/Makefile.rej
patching file arch/arm/mach-msm/msm_wifi.c

Notice, part of that patch failed. Now we go in and edit the Makefile to add this:

$ vi arch/arm/mach-msm/Makefile
# I Inserted this at line 78, but I'm pretty sure it's location is unimportant
obj-$(CONFIG_TROUT_WIFI) += msm_wifi.o

Now, you need to slightly reconfigure the kernel, to enable mac80211:

$ cd htc-kernel-heroc/
$ make UncappedStable_defconfig
#
# configuration written to .config
#
$ make CROSS_COMPILE=/usr/src/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- ARCH=arm menuconfig

You should now be in the 'menuconfig' of the kernel. Go To:

[*] Networking support --->
[*] Wireless --->

and select:

<M> Common routines for IEEE802.11 drivers
<M> Generic IEEE 802.11 Networking Stack (mac80211)

Next, we need to enable the crc7 module goto:

Library routines --->

and select:

<M> CRC7 functions

Finally, enable msm_wifi through

System Type --->
<M> Trout Wifi Gpio driver (rfkill)

Exit out of menu config (keep selecting Exit). And make sure you answer 'yes' to save your kernel configuration.

You are now ready to compile your kernel:

make CROSS_COMPILE=/usr/src/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- ARCH=arm

To speed up the compile if you have multiple CPUs, add -j<number of cpus> to the end of that (prepended with a space).

Once that is done, you're ready to compile compat-wireless. First you need to grab a tarball. I used the October 20, 2010 tarball in this example.

$ cd ..
$ wget http://wireless.kernel.org/download/compat-wireless-2.6/compat-wireless-2010-10-20.tar.bz2
$ tar xjvf compat-wireless-2010-10-20.tar.bz2
$ cd compat-wireless-2010-10-20/

Next, select only the wl12xx drivers

$ scripts/driver-select wl12xx
Processing new driver-select request...
Backup exists: Makefile.bk
Backup exists: drivers/net/wireless/Makefile.bk
Backup exists: Makefile.bk
Backup exists: net/wireless/Makefile.bk
Backup exists: drivers/net/Makefile.bk
Backup exists: drivers/ssb/Makefile.bk
Backup exists: drivers/misc/eeprom/Makefile.bk

and compile

$ make CROSS_COMPILE=/usr/src/android/prebuilt/linux-x86/toolchain/arm-eabi-4.4.0/bin/arm-eabi- ARCH=arm KLIB=/usr/src/android/htc-kernel-heroc/ KLIB_BUILD=/usr/src/android/htc-kernel-heroc/

Now, you need to push the appropriate files to your phone. Here's the list:

Kernel:
arch/arm/mach-msm/msm_wifi.ko
lib/crc7.ko

Compat:
compat/compat.ko
compat/compat_firmware_class.ko
drivers/net/wireless/wl1251/wl1251-sdio.ko
drivers/net/wireless/wl1251/wl1251.ko
net/mac80211/mac80211.ko
net/rfkill/rfkill_backport.ko
net/wireless/cfg80211.ko

These should all end up in /system/lib/modules/2.6.29-cyanogenmod/

Next we need to update the modules autoloader to load all these. Change /system/etc/init.d/04modules to have this:

MODULES="ipv6 crc7 compat compat_firmware_class rfkill_backport cfg80211 mac80211 wl1251 wl1251-sdio"

should get the driver automatically loading. Next, we need to replace wpa_supplicant with a statically compiled libnl version:

TODO

and replace the wifi gui parts with versions built to handle our non-tiwlan driver wpa_supplicant.

TODO