Closed Bug 908553 Opened 11 years ago Closed 10 years ago

B2G Emulator: support wifi emulation

Categories

(Firefox OS Graveyard :: Wifi, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 991025

People

(Reporter: vchang, Assigned: vchang)

References

Details

Attachments

(5 files)

Clone from bug 852583. 
Kernel build instructions:

  1) cd B2G_SOURCE_TOP
  2) . build/envsetup.sh
  3) lunch 1
  4) cd KENER_SOURCE_TOP
  5) ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh \
     --out=${ANDROID_BUILD_TOP}/prebuilts/qemu-kernel/arm \
     --armv7 --verbose

To build goldfish kernel (not goldfish_armv7):

  5) ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh \
     --out=${ANDROID_BUILD_TOP}/prebuilts/qemu-kernel/arm \
     --config=goldfish --verbose

You may omit --verbose to disable the noises. And to config the kernel based on either goldfish_defconfig or goldfish_armv7_defconfig, append --menuconfig like:

  5) ${ANDROID_BUILD_TOP}/external/qemu/distrib/build-kernel.sh \
     --out=${ANDROID_BUILD_TOP}/prebuilts/qemu-kernel/arm \
     --armv7 --menuconfig

Note that you may need libncurse5-dev:amd64 for kernel menuconfig, however B2G needs libncurse5-dev:i386 and they can't co-exist on debian-based distros.

Looking at the page related to mac80211_hwsim. Not sure if we can use it to emulate wifi.
Assignee: nobody → vchang
This kernel config helps to turn on MAC80211_HWSIM, NL80211, MAC80211 kernel modules. With MAC80211_HWSIM Wi-Fi driver, we can see wlan0 and wlan1 network interfaces. My idea is to bind wpa_supplicant to wlan0 and bind hostapd to wlan1. 
So that we can test Wi-Fi station and Wi-Fi hotspot functionality at the same time.
Attached patch BoardConfig.diffSplinter Review
First, we need to build wpa_supplicant_8 in emulator. 

With the help of below commands, I can turn on Wi-Fi from the settings app. 

adb shell rm -r /data/system
adb shell rm -r /data/misc/wifi/wpa_supplicant
adb shell rm -r /system/etc/wifi
adb shell setprop wifi.interface wlan0
adb remount
adb shell mkdir /system/etc/wifi/
adb push wpa_supplicant.conf /system/etc/wifi/
adb shell mkdir /data/misc/wifi/wpa_supplicant
adb shell chown wifi.wifi /data/misc/wifi/wpa_supplicant
adb shell mkdir /data/misc/wifi/sockets
adb shell chown wifi.wifi /data/misc/wifi/sockets
adb shell mkdir /data/system/
adb shell chown wifi.wifi /data/system
adb shell ln -s /data/misc/wifi/wpa_supplicant /data/system/wpa_supplicant  

We should write these to init.goldfish.rc or something ....
Attached file hostapd.conf
Try to start hostapd. We have to issue netd command to start hostapd later. 
adb push hostapd.conf /data/misc/wifi/
adb shell /system/bin/hostapd -e /data/misc/wifi/entropy.bin /data/misc/wifi/hostapd.conf
Modification for compiler error and debug message
Attached patch rootdir.diffSplinter Review
add wpa_supplicant service
The other ways to run wpa_supplicant and hostapd in emulator is to use driver_test.c.
Modify the BoardConfig.mk to 
+WPA_SUPPLICANT_VERSION := VER_0_8_X
+BOARD_WPA_SUPPLICANT_DRIVER := TEST
+BOARD_HOSTAPD_DRIVER := TEST

hostapd configuration file: 
channel=1
driver=test
interface=ap1
logger_stdout=-1
logger_stdout_level=0
debug=2
dump_file=/data/misc/wifi/hostapd.dump
test_socket=DIR:/data/misc/wifi/
ssid=jkm-test-psk
wpa=1
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
wpa_passphrase=12345678

wpa_supplicant configuration file: 

driver_param=test_socket=/data/misc/wifi/AP-02:dd:1d:a7:2c:ec test_dir=/data/misc/wifi/
network={
    ssid="jkm-test-psk"
    key_mgmt=WPA-PSK
    psk="12345678"
}
Blocks: 932630
Henry is working on this.
Status: NEW → RESOLVED
Closed: 10 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: