[Galaxy S II Q&A, Help & Troubleshooting] aidfarh:
I'm compiling a kernel for the I9100G. I've downloaded the latest source from Samsung and added some drivers that were missing from the package. After a few tries, I managed to get my phone to boot. Everything seems to be working except for Wifi.

The symptom: Every time I turn on the Wifi it seems to scan for a few seconds, but then turns itself off. Here's a snippet of the logcat covering the time I try to turn on the wifi:

D/WifiService( 1679): setWifiEnabled: true
D/WifiService( 1679): ****************setWifiEnabled(), allowWifi****************true
E/WifiSettingButton( 1791): onReceive()-S:2
I/WifiHW ( 1679): [WIFI] Load Driver
E/WifiHW ( 1679): module is samsung
I/WifiHW ( 1679): [WiFi.c] insmod() Start!!
I/WifiHW ( 1679): [WiFi.c] start init_module() Start!!
V/WifiSettings( 3177): resetRetryDialogVariable
I/ActivityManager( 1679): Start proc com.schwimmer.android.wifistatus for broadcast com.schwimmer.android.wifistatus/.WifiStatusReceiver: pid=3569 uid=10452 gids={1015}
I/StatusBarManagerService( 1679): ADD-null , 0x7f020000
D/Beautiful Widgets( 1835): WIFI_STATE_CHANGED_ACTION
I/WindowOrientationListener( 1679): orientation = 5.365884 Tilt = 53.00611 -- 0 , 5 , 7
W/DiskCache( 3540): rename to = /mnt/sdcard/Android/data/com.cooliris.media/cache/local-meta-cache/index
I/CacheService( 3540): Preparing DiskCache for all thumbnails.
D/dalvikvm( 3442): GC_CONCURRENT freed 339K, 46% free 3414K/6215K, external 0K/512K, paused 2ms+2ms
W/DiskCacheSEC( 3540): enter writeIndex 106
W/DiskCacheSEC( 3540): Create TempFile = /sdcard/DiskCacheIndex-1409040773.tmp
V/DiskCacheSEC( 3540): [SE Lab.] writeindex(): id= -1119846364 / mntTime= 1317589132716
V/DiskCacheSEC( 3540): [SE Lab.] writeindex(): id= 2052120067 / mntTime= 1319028831430
V/DiskCacheSEC( 3540): [SE Lab.] writeindex(): id= 1149784819 / mntTime= 1319824382708
V/DiskCacheSEC( 3540): [SE Lab.] writeindex(): id= 338429904 / mntTime= 1319824382707
D/DiskCacheSEC( 3540): Wrote index with 106 records.
W/DiskCacheSEC( 3540): rename to = /mnt/sdcard/Android/data/com.cooliris.media/cache/local-image-thumbs/index
I/TIMECHECK( 3540): END thumbnails.
I/ActivityManager( 1679): No longer want com.mediawoz.goweather (pid 3301): hidden #26
D/Tethering( 1679): eth0 is not a tetherable iface, ignoring
I/WifiHW ( 1679): [WIFI] DRIVER OK
I/WifiHW ( 1679): wifi_start_supplicant: Enter
D/WifiHW ( 1679): /data/wifi/bcm_supp.conf exits
I/WifiHW ( 1679): wifi_start_supplicant: Exit. supp_status=running
W/WifiService( 1679): ---- Check wifi direct setting. It is unchecked.
I/WifiHW ( 1679): wifi_connect_to_supplicant: enter
I/WifiHW ( 1679): wifi_connect_to_supplicant: supp_conn_status(transit)
E/WifiHW ( 1679): Unable to access IFACE_DIR /No such file or directory
E/WifiHW ( 1679): wifi_connect_to_supplicant: ifname(eth0)
I/wpa_supplicant( 3592): Interface eth0 set UP - success
V/SettingsProvider( 1679): secure <- value=1 name=wifi_on
V/SettingsProvider( 1679): property: sys.settings_secure_version=1
V/SettingsProvider( 1679): notifying: content://settings/secure/wifi_on
E/WifiSettingButton( 1791): onReceive()-S:3
E/AlarmManagerService( 1679): android_server_AlarmManagerService_set to type=2, 121.781000000
E/wpa_supplicant( 3592): Failed to initialize control interface 'eth0'.
E/wpa_supplicant( 3592): You may have another wpa_supplicant process already running or the file was
E/wpa_supplicant( 3592): left by an unclean termination of wpa_supplicant in which case you will need
E/wpa_supplicant( 3592): to manually remove this file before starting wpa_supplicant again.
I/wpa_supplicant( 3592): CTRL-EVENT-STATE-CHANGE id=-1 state=0 BSSID=00:00:00:00:00:00
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
I/WindowOrientationListener( 1679): orientation = 4.798251 Tilt = 53.126266 -- 0 , 5 , 8
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
I/WindowOrientationListener( 1679): orientation = 4.523258 Tilt = 53.586506 -- 0 , 5 , 8
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
I/StatusBarPolicy( 1791): onDataActivity-D:0
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
D/dalvikvm( 2999): GC_CONCURRENT freed 219K, 46% free 3166K/5831K, external 0K/0K, paused 2ms+3ms
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant:ctrl_conn is NULL!!
E/WifiHW ( 1679): wifi_connect_to_supplicant: Unable to open connection to supplicant on "eth0": No such file or directory
D/WifiSettings( 3177): updateAccessPoints(), WifiConfigureation list updated
D/WifiSettings( 3177): updateAccessPoints(), ScanResult list updated
V/WifiSettings( 3177): resetRetryDialogVariable

Here's a snippet of the dmesg log:

4>[ 122.551971] wlan_setup_power: on
<7>[ 122.552001] wlan_setup_power: wlan enable GPIO value(104)=1
<4>[ 122.552032] omap_hsmmc_force_presence_change_for_wlan: enter
<7>[ 122.552093] omap_hsmmc_force_presence_change_for_wlan: mmc detect change called, omap_hsmmc_host_pub=ee207e40
<4>[ 122.554626]
<4>[ 122.554626] Dongle Host Driver, version 5.90.100.133 (WFD)
<4>[ 122.554656] Compiled in drivers/net/wireless/bcm4330/src on Oct 29 2011 at 13:35:55
<3>[ 122.591705] cpu_up CPU1: Booted secondary processor
<6>[ 122.756225] omap4_duty_enter_heating enter at ()
<4>[ 123.091857] [MMC] IRQ Status is 18000
<4>[ 123.097167] [MMC] IRQ Status is 18000
<4>[ 123.106048] [MMC] IRQ Status is 18000
<4>[ 123.121765] mmc2: queuing unknown CIS tuple 0x80 (7 bytes)
<4>[ 123.166748] mmc2: queuing unknown CIS tuple 0x80 (3 bytes)
<6>[ 123.179382] mmc2: new high speed SDIO card at address 0001
<4>[ 123.183563] dhd_customer_oob_irq_map: customer specific Host GPIO number is (81), flag=0x2
<4>[ 123.184020] F1 signature read @0x18000000=0x16834330
<4>[ 123.188293] DHD: dongle ram size is set to 294912(orig 294912)
<4>[ 123.188415] CHIP VER = [3]

<4>[ 123.221405] dhdsdio_download_nvram: firmware image path = /system/etc/wifi/bcm4330_sta.bin
<4>[ 123.221466] dhdsdio_download_nvram: nvram vars file path = /system/etc/wifi/nvram_net.txt
<4>[ 123.222259] dhdsdio_write_vars: Download, Upload and compare of NVRAM succeeded.
<4>[ 123.412200] MAC (OTP) : [78:D6:F0:A5:45:00]

<4>[ 123.412231] MAC (FILE): [78:D6:F0:A5:45:00] [1]

<4>[ 123.412933] Firmware version = wl0: Aug 19 2011 10:29:30 version 5.90.100.270 (BTAMP WFD)
<4>[ 123.412963]
<4>[ 123.415222] POWER_VAL = 1

<4>[ 123.482330] ABB: TRANXDONE timed out waiting for OPP change
<4>[ 123.496215] dhd_preinit_ioctls: KEEP Alive time is 45s
<4>[ 123.498992] eth0: Broadcom Dongle Host Driver MAC=78:D6:F0:A5:45:00
<4>[ 123.499053] Enter wl_control_wl_start
<4>[ 123.499084] Exited wl_control_wl_start
<4>[ 123.501770] wl_iw_iscan_set_scan_broadcast_prep: First Brodcast scan was forced
<4>[ 123.503845] +++: Set Broadcast ISCAN
<4>[ 123.581146] eth0: SIOCSIWMODE MODE 2
<4>[ 123.581176] eth0: SIOCSIWMODE MODE 2 SSS
<4>[ 123.581512] eth0: SIOCSIWCOMMIT
<4>[ 123.581878] eth0: SIOCGIWRANGE
<4>[ 123.584228] eth0: SIOCGIWMODE
<4>[ 123.584808] eth0: SIOCSIWAP
<4>[ 123.591796] ABB: TRANXDONE timed out waiting for OPP change
<4>[ 123.607147] eth0: SIOCSIWAUTH, IW_AUTH_WPA_ENABLED(7), paramval = 0x1
<4>[ 123.607177] eth0: SIOCSIWENCODEEXT
<4>[ 123.607635] eth0: SIOCSIWENCODEEXT
<4>[ 123.608001] eth0: SIOCSIWENCODEEXT
<4>[ 123.608337] eth0: SIOCSIWENCODEEXT
<4>[ 123.608703] eth0: SIOCSIWAUTH, IW_AUTH_TKIP_COUNTERMEASURES(4), paramval = 0x0
<4>[ 123.609222] eth0: SIOCSIWAUTH, IW_AUTH_DROP_UNENCRYPTED(5), paramval = 0x1
<4>[ 123.618835] eth0: SIOCSIWAUTH, IW_AUTH_WPA_ENABLED(7), paramval = 0x0
<4>[ 123.619659] eth0: SIOCSIWAUTH, IW_AUTH_DROP_UNENCRYPTED(5), paramval = 0x0
<4>[ 123.620025] eth0: SIOCSIWAUTH, IW_AUTH_TKIP_COUNTERMEASURES(4), paramval = 0x0
<4>[ 123.647033] eth0: SIOCGIWMODE
<4>[ 123.647613] eth0: SIOCSIWAP
<4>[ 124.594421] Enter wl_control_wl_start
<4>[ 124.594482] Exited wl_control_wl_start
<4>[ 124.598785] Send Event ISCAN complete

From what I can gather, it seems the wifi driver managed to load itself up, however, it failed to connect to the supplicant service and then was turned off. Can someone please tell me what is happening and how I can fix it? Thanks in advance.