Android 4 0 software & station coexistence debugging record 2

Posted by adrianpeyton on Wed, 23 Feb 2022 01:56:33 +0100

1. Preface

Following the previous article, the relevant modifications are mainly explained here

2. Drive and tool description

The coexistence function of station and softap is realized on the premise that the driven debug mode is turned on,

Because you need to DHD the macro of debug mode in the Makefile file_ Debug is added. If the macro is not added,

When using DHD_ When the helper command enables the coexistence of station and softap, DHD will be prompted_ The helper command is invalid.

(it is estimated that the current way of realizing the coexistence function of station and softap has long been realized by broadcom in the debugging process, but it has not been announced due to the lack of performance and market demand)

The wl tool will be used to connect AP and view connection status in the current debugging process, and it will also be dhd_. Helper implicitly calls to

(I only know that dhd_helper will call wl, because if there is no wl tool, using dhd_helper will prompt that wl does not exist, and it is unclear what function to call wl to realize, because I can't see the implementation code of dhd_helper)

dhd_ The most significant function of the helper tool is to turn on the softap function on the premise of turning on the station function.

Through dhd_helper can initialize softap, including device channel, AP name, encryption method, etc. the following example is DHD_ Seven device modes of helper.

Initial AP mode with SSID: tttb_apsta
EX1: 802.11 B only, Channel 3, Open system, No encryption, without hidden SSID
dhd_helper ssid tttb_apsta hidden n bgnmode b chan 3 amode open emode none

EX2: 802.11 G only, Channel 3, Open system, WEP ASCII 5 encryption and key is 12345 with hidden SSID
dhd_helper ssid tttb_apsta hidden y bgnmode g chan 3 amode open emode wep key 12345

EX3: 802.11 B/G mixed, Channel 3, Open system, WEP HEX 10 encryption and key is 1234567890 without hidden SSID
dhd_helper ssid tttb_apsta bgnmode bg chan 3 amode open emode wep key 1234567890

EX4: 802.11 G only, Channel 3, Shared key authentication, WEP ASCII 13 encryption and key is 1234512345123 without hidden SSID
dhd_helper ssid tttb_apsta bgnmode g chan 3 amode shared emode wep key 1234567890123

EX5: 802.11 B/G mixed, Channel 3, Shared key authentication, WEP HEX 26 encryption and key is 12345678901234567890123456 without hidden SSID
dhd_helper ssid tttb_apsta bgnmode bg chan 3 amode shared emode wep key 12345678901234567890123456

EX6: 802.11 B/G mixed, Channel 3, WPA-PSK authentication, TKIP encryption and key is 12345678 without hidden SSID
dhd_helper ssid tttb_apsta bgnmode bg chan 3 amode wpapsk emode tkip key 12345678

EX7: 802.11 B/G/n mixed, Channel 3, WPA/WPA2-PSK authentication, TKIP/AES encryption and key is 12345678 without hidden SSID
dhd_helper ssid tttb_apsta bgnmode bgn chan 3 amode wpawpa2psk emode tkipaes key 12345678

3. Premise modification

For the kernel part, the bcm40181 driver needs to be compiled into ko form. The specific modifications are as follows:

/lichee/linux-3.0 Under directory, enter make ARCH=arm menuconfig,Then make the following choices
Device Drivers  --->
[*] Network device support  --->
[*]   Wireless LAN  --->
<M>   Broadcom 40181/40183 wireless cards support

There are three modifications to android, and only a brief description is given below,

The "40mbc & tap" in the "40mbc & tap" can be modified.

First: device/softwinner/crane-xxx/overlay/frameworks/base/core/res/res/values/config.xml
 Modified softap Change the interface name to wl0.1,In order to monitor wl0.1 Open the interface after it is opened dnsmasq and nat service

Second: frameworks/base/services/java/com/android/server/connectivity/Tethering.java
 Modified when wl0.1 When the interface is opened, it is forced to open nat Service to realize data forwarding function

Third: frameworks/base/wifi/java/android/net/wifi/WifiStateMachine.java
 Modified when wl0.1 When the interface is opened, the dnsmasq Services to achieve dynamic allocation IP function

4. Detailed description of current implementation steps

Make sure that the premise modification has been made, and then start the station and softap functions according to the following steps.

Step 1: after the system is started, input the following commands on the command line to load the driver and specify fw and nvram files.

insmod /system/vendor/modules/bcmdhd.ko "firmware_path=/system/vendor/modules/fw_bcm40181a2_apsta.bin nvram_path=/system/vendor/modules/bcm40181_nvram.txt"

Tip: FW_ bcm40181a2_ apsta. The bin firmware has the functions of station and softap, FW_ bcm40181a2. The bin firmware has the functions of station and wifi direct.

After the driver is loaded successfully, enter netcfg command to see wlan0 interface. The interface status is down and the IP address is 0.

Step 2: use ifconfig command to up WLAN 0.

ifconfig wlan0 up

After WLAN 0 is successfully up, you can see that the status of WLAN 0 is up and the IP address is 0 through netcfg command.

Step 3: through DHD_ The helper command also enables the softap function. The following is an example of setting the softap name to tttb_apsta, enable softap without encryption.

dhd_helper ssid tttb_apsta hidden n bgnmode b chan 3 amode open emode none

Because the android layer will listen to WL0 1. WL0 is being monitored 1 after the interface, dnsmasq and nat services will be forced to be started. Therefore, if DHD_ If the helper is executed successfully, enter the netcfg command and you will see WL0 1 has been up and has been assigned to the IP address,

At this point, the coexistence function of station and softap has been realized.

Prompt: 1. If you enter DHD_ The helper prompts that there is no such command or the permission is insufficient. Please check DHD_ Whether the helper has pushed the system and whether it has execution permission. 2. If you want to set the password and modify the channel for softap, please refer to DHD in the tool description_ helper. (Note: after an individual tries to encrypt softap, other devices cannot connect to softap)

Step 4: connect the AP through wl command. For the convenience of debugging, set the AP to non encryption mode, and then connect the AP with the following command.

wl join AP name

After performing the connection operation, you can check whether the connection is successful through the wl ssid command.

Step 5: assign IP address to wlan0 through dhcp. The relevant commands are as follows.

netcfg wlan0 up

After executing the above commands, you can see that wlan0 will be assigned to the IP address through the netcfg command. At this time, you can check whether it is connected to the Internet through the ping command.

After the above five steps are successfully executed, you can connect to softap through other devices to see whether you can surf the Internet normally. Check the coexistence function of station and softap. If you can surf the Internet normally, it indicates that the coexistence function of station and softap has been realized.

5. Existing problems

At present, although the coexistence function of station and softap has been realized, it still needs a series of improvements to be really put into the application. The performance of the coexistence of station and softap needs to be further verified.

The following is a list of personal problems:

First, at present, the coexistence of station and softap is only realized through command operation, and the open icon of softap will be displayed on the interface. Users cannot open and close wifi through the interface (at that time, the open and close wifi of the interface are false, and wifi is essentially on all the time);

==="= =" wifi broadcast messages need to be processed to make the interface display normally and make users feel no difference.

Second, after softap is set to the encryption mode, other devices will be disconnected and reconnected after connecting to the AP. From the printing point of view, the driver does not support softap to the encryption mode. At present, softap can only be set to the non encryption mode.

===The problem should be related to the support of the driver. The problem will be fed back to the agent and followed up.

Third, after the station and softap functions are turned on at the same time and run normally, they cannot pass through DHD again_ The helper command modifies the settings of softap.

==="It is most likely due to the limitation of the driver. After WLAN 0 is up and ap is connected, it cannot pass through DHD_ When the helper modifies the softap configuration, it needs to confirm with the original factory. It may be necessary to save the configuration to a file, and then restart the system to set the new configuration.

Fourth, after the coexistence of station and softap is realized, wifi will interact with both AP and other mobile devices connected to softap, which will lead to the failure of wifi and the decline of overall Internet performance.

==="It should be an essential problem. Both station and softap work in the 2.4Ghz frequency band, which will cause interference. Improve wifi chip and use dual antenna? One 2.4G, one 5G?

Topics: Linux Android