B2G Emulator: support wifi emulation

RESOLVED DUPLICATE of bug 991025

Status

RESOLVED DUPLICATE of bug 991025
5 years ago
4 years ago

People

(Reporter: vchang, Assigned: vchang)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(5 attachments)

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)

Updated

5 years ago
Assignee: nobody → vchang
(Assignee)

Comment 1

5 years ago
Created attachment 804332 [details] [diff] [review]
goldfishKernelConfig.diff

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.
(Assignee)

Comment 2

5 years ago
Created attachment 804366 [details] [diff] [review]
BoardConfig.diff

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 ....
(Assignee)

Comment 3

5 years ago
Created attachment 804368 [details]
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
(Assignee)

Comment 4

5 years ago
Created attachment 804369 [details] [diff] [review]
wpa_supplicant.diff

Modification for compiler error and debug message
(Assignee)

Comment 5

5 years ago
Created attachment 804370 [details] [diff] [review]
rootdir.diff

add wpa_supplicant service
(Assignee)

Comment 6

5 years ago
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"
}

Updated

5 years ago
Blocks: 932630
(Assignee)

Comment 7

4 years ago
Henry is working on this.
Status: NEW → RESOLVED
Last Resolved: 4 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 991025
You need to log in before you can comment on or make changes to this bug.