Texas Instruments wl1251 is the wifi chip used in recent HTC phones.
Two drivers are available for the WL1251:
- Written by TI and GPL'd, but uses its own custom wireless stack
- Well-tested and integrated with Android (shipped on all Android phones to date)
- Located in system/wlan/ti in the Android source tree
- Still under development, but uses Linux wireless stack
- Not as refined/well-tested with Android
Loading the TIWLAN driver is done in two steps:
- Load the module (wlan.ko)
- Use wlan_loader to load the firmware file (Fw1251r1c.bin), the ini file (tiwlan.ini), and the calibration file
The calibration is a 752-byte file that is burned into the device's NAND flash at the factory, and contains the WiFi MAC address, among other things. Every model puts the calibration at a different offset in the flash, and the OS is responsible for extracting it from flash and presenting it to wlan_loader.
Shipping Android phones do this by making the calibration available at '/proc/calibration'.
For community Android distributions, 'dd' is typically used to extract the calibration from the NAND flash. This requires that CONFIG_MTD and CONFIG_MTD_MSM_NAND are set. The calibration file starts with the header 0x02 0x11 0x56 0x06 0x1C 0x06. Inside the entire NAND flash (which can be 256MB or greater), this header might be found more than once. In the case of the DIAM500, the header is found twice, and the second occurrence is the correct calibration file.
For the DIAM500 (CDMA Touch Diamond), the following 'dd' lines will extract working calibration. Two commands are needed because a limited range of block sizes can be used when reading from the MTD device.
dd if=/dev/mtd/mtd0ro of=/sdcard/tempcal bs=8192 count=1 skip=4048 dd if=/sdcard/tempcal of=/sdcard/calibration bs=1 count=752 skip=64
The firmware is a file that is uploaded to the WL12xx by wlan_loader. It is shipped with the OS; Windows Mobile keeps it in \windows. Different versions have shipped with various devices:
md5sum size name description 7be50ef3cafa7f948b1065e3b2dc0e7c 194188 Fw1251r1c.bin, used on G1 and G2 f226c365fadc368f94614af2af698e6f 193216 Fw1251r1c.bin, used on X1 ebf5c2036d37bc56b4d41ddcbda4311e 185388 Fw1251r1c.bin, used on raph100,diam100,blac100
Actually make it work with wl12xx
Get the firmware from your current windows mobile (post the md5sum here, if it does not match the values above), then get calibration (as stated above). You'll have then to build wl12xx, with either a recent kernel or the "compat wireless" thing, see link about wl12xx driver. Now boot your phone on linux, load the wl1251_sdio driver and its dependencies into the kernel.
Then mount debugfs somewhere, and write 1 to debugfs/htcraphaelmmc_dbg/wifi_cd to "activate" the wifi card. Looking at dmesg will give you wl12xx error about firmware not available.
Now write 0 to the wifi_cd file do disable the wifi card, and push your firmware in /lib/firmware/wl1251-fw.bin
Reenable wifi card, driver will load. Do ifconfig wlanX up (X depends on udev's behaviour). It will say no such file or directory and dmesg will say you need nvs file, it's the calibration file you extracted, put it in /lib/firmware/wl1251-nvs.bin
Disable and reenable card, do ifconfig wlanX up, then write 1 to debugfs/htcraphaelmmc_dbg/wifi_pwr
Now, just enjoy. This long way gave me a lot of success, but sometimes, it will initiate with just putting files and then loading driver. We have to figure out the initiation correctly.
tested on diam100. Here is a script, please note it is REALLY slow, you might want to try to improve timings, but please note that theses ones won't always work, pick 10seconds to be sure.
#!/bin/sh insmod rfkill_backport.ko insmod cfg80211.ko insmod lib80211.ko insmod lib80211_crypt_ccmp.ko insmod lib80211_crypt_tkip.ko insmod lib80211_crypt_wep.ko insmod mac80211.ko insmod wl1251.ko insmod wl1251_sdio.ko mkdir /dbgfs mount -tdebugfs none /dbgfs echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_cd sleep 5 echo 0 > /dbgfs/htcraphaelmmc_dbg/wifi_cd mkdir /lib/firmware cp wl1251-fw.bin /lib/firmware echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_cd sleep 5 ifconfig wlan0 up ifconfig wlan1 up ifconfig wlan2 up sleep 5 echo 0 > /dbgfs/htcraphaelmmc_dbg/wifi_cd cp wl1251-nvs.bin /lib/firmware echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_cd sleep 5 ifconfig wlan0 up ifconfig wlan1 up ifconfig wlan2 up sleep 5 echo 1 > /dbgfs/htcraphaelmmc_dbg/wifi_pwr umount /dbgfs rmdir /dbgfs