W!o+ 的《小伶鼬工坊演義》︰樹莓派 3 三兩事之 WiFi 篇

好像是不說自明的事,拿到樹莓派 3 後,首先就是下載最新版的 Raspbian ,讀讀 Release notes︰

Raspbian Jessie

Full desktop image based on Debian Jessie
Version: February 2016
Release date: 2016-02-26
Kernel version: 4.1
Release notes: Link
# Release notes
2016-02-26:
  * Support added for Pi 3, including Wifi and Bluetooth
  * Option to set wifi country code added to raspi-config
2016-02-09:
  * dtb that uses mmc sdcard driver (fixes problems experienced with certain SD cards)
2016-02-03:
……

 

照說用新的 raspi-config 設定好 WiFi 國別後,

pi@raspberrypi_WiFi

 

就該運作順暢?不過總是天不從人願!只好查之以論壇︰

RPi 3 – Very poor wifi performance

by toadstool » Wed Mar 02, 2016 1:10 pm

A fresh Raspbian Lite install on a brand new official Samsung Class 10 SD card installed in a new RPi 3.

Apt-get update and upgrade direct from the Pi (using screen and keyboard) works well – no apparent network issues.

However, ping and SSH from another host on the network to the RPi 3 shows abysmal results. Ping shows latency varying from 4.56 ms to almost 3000ms. SSH’ing in results in input latency with up to 5 seconds delay.

On the same network with RPi Zero and official RPi Broadcom USB wifi dongle there are no issues.

Router is a Buffalo N with current OpenWrt. No other hosts (including multiple various wifi devices) on the network have issues.

Could this be related to wifi chipset firmware, dynamic clocking frequency scaling or due to built in wifi being connected via SDIO?

I understand the Broadcom chipset for the built in wifi on the RPi 3 is different than the chipset in the Official USB dongle (BCM43438 cf. BCM43143) and it looks like each uses a different version of the Broadcom wifi firmware:

……

 

考之以 rpi-update 更新紀錄

# rpi-update 3月九日
firmware: vc_image: Don't mangle the pitch for deinterlace with tall …

…YUV images

See: raspberrypi/firmware#520

firmware: spdif: Allow compressed audio flag to be forced
See: raspberrypi/firmware#561

kernel: vchiq_arm: Tweak the logging output

kernel: bcm2835-sdhost: Only claim one DMA channel
kernel: bcm2835-mmc: Only claim one DMA channel
See: raspberrypi/linux#1327

kernel: Pi3 DT: Add pull-ups on the UART RX lines

kernel: config: Add module for mcp3422 ADC
See: raspberrypi/linux#1330

# WiFi 電源管理問題
kernel: brcmfmac: Disable power management
See: https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=138312

kernel: serial: Take care starting a hung-

 

總算能正常工作的了!!或許 dmesg 之訊息︰

pi@raspberrypi ~ dmesg | grep brcm [    4.858309] brcmfmac: brcmf_sdio_drivestrengthinit: No SDIO Drive strength init done for chip 43430 rev 1 pmurev 24 [    4.859922] usbcore: registered new interface driver brcmfmac [    5.058162] brcmfmac: brcmf_c_preinit_dcmds: Firmware version = wl0: Dec 15 2015 18:10:45 version 7.45.41.23 (r606571) FWID 01-cc4eda9c [    5.087066] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code [    5.508985] brcmfmac: brcmf_add_if: ERROR: netdev:wlan0 already exists [    5.509010] brcmfmac: brcmf_add_if: ignore IF event [    5.517260] brcmfmac: power management disabled [    5.785206] brcmfmac: brcmf_cfg80211_reg_notifier: not a ISO3166 code pi@raspberrypi ~ 

 

仍然 讓人有點憂慮??看來驅動程式完善還需要一點時間!!

 

假使從 iwconfig

pi@raspberrypi ~ iwconfig  wlan0     IEEE 802.11bgn  ESSID:"BUFFALO-C4ECF8_G"             Mode:Managed  Frequency:2.412 GHz  Access Point: 4C:E6:76:C4:EC:F8              Bit Rate=11 Mb/s   Tx-Power=1496 dBm              Retry short limit:7   RTS thr:off   Fragment thr:off           Power Management:on           Link Quality=56/70  Signal level=-54 dBm             Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0           Tx excessive retries:0  Invalid misc:0   Missed beacon:0  lo        no wireless extensions.  eth0      no wireless extensions.  pi@raspberrypi ~ 

 

以及 iw list ︰

pi@raspberrypi ~ iw list Wiphy phy0 	max # scan SSIDs: 10 	max scan IEs length: 2048 bytes 	Retry short limit: 7 	Retry long limit: 4 	Coverage class: 0 (up to 0m) 	Device supports roaming. 	Device supports T-DLS. 	Supported Ciphers: 		* WEP40 (00-0f-ac:1) 		* WEP104 (00-0f-ac:5) 		* TKIP (00-0f-ac:2) 		* CCMP (00-0f-ac:4) 		* CMAC (00-0f-ac:6) 	Available Antennas: TX 0 RX 0 	Supported interface modes: 		 * IBSS 		 * managed 		 * AP 		 * P2P-client 		 * P2P-GO 		 * P2P-device </pre>    <span style="color: #666699;">來看,這個 WiFi 雖可以用作『 <a style="color: #666699;" href="https://www.raspberrypi.org/forums/viewtopic.php?f=36&t=138550">AP</a> 』熱點,但是沒有『 monitor 』模式,就無法跑『地壘』這類工具軟體的哩︰ </span>     <span style="color: #808000;">不論用什麼樣的『 <a style="color: #808000;" href="http://www.freesandal.org/wp-content/uploads/金文尺.gif"><img class="alignnone size-full wp-image-39968" src="http://www.freesandal.org/wp-content/uploads/金文尺.gif" alt="金文尺" width="21" height="44" /></a> 』尺來度量,都得了解那根尺的構成,以及量到數值的意義,要如何校正資料,方能有實際的用途。為此特別介紹一個稱之為『地壘』 horst 的軟體︰</span> <h1><a href="http://www.freesandal.org/wp-content/uploads/spiralsun_small.gif"><img class="alignnone size-full wp-image-40043" src="http://www.freesandal.org/wp-content/uploads/spiralsun_small.gif" alt="spiralsun_small" width="60" height="60" /></a><a href="http://br1.einfach.org/tech/horst/">br1 blog</a></h1> <div class="description">high-tech or low-life?</div> <div class="description"></div> <div class="description"> <h2>horst</h2> <div class="entry">  ``horst'' is a small, lightweight IEEE802.11 wireless LAN analyzer with a text interface. Its basic function is similar to <a href="http://www.tcpdump.org/">tcpdump</a>, <a href="http://www.wireshark.org/">Wireshark</a> or <a href="http://www.kismetwireless.net/">Kismet</a>, but it's much smaller and shows different, aggregated information which is not easily available from other tools. It is mainly targeted at debugging wireless LANs with a focus on ad-hoc (IBSS) mode in larger mesh networks. It can be useful to get a quick overview of what's going on on all wireless LAN channels and to identify problems. <ul> 	<li>Shows signal (RSSI) values per station</li> 	<li>Calculates channel utilization (``usage'') by adding up the amount of time the packets actually occupy the medium</li> 	<li>``Spectrum Analyzer'' shows signal levels and usage per channel</li> 	<li>Graphical packet history, with signal, packet type and physical rate</li> 	<li>Shows all stations per ESSID and the live TSF per node as it is counting</li> 	<li>Detects IBSS ``splits'' (same ESSID but different BSSID - this is a common driver problem)</li> 	<li>Statistics of packets/bytes per physical rate and per packet type</li> 	<li>Has some support for mesh protocols (OLSR and batman)</li> 	<li>Can filter specific packet types, source addresses or BSSIDs</li> 	<li>Client/server support for monitoring on remote nodes</li> </ul> ``horst'' is a Linux program and can be used on any wireless LAN monitor interface. The latest version is 4.2 from Oct 1 2014.  </div> </div> ……  <span style="color: #808080;"><strong>【主畫面】</strong></span>  <a href="http://www.freesandal.org/wp-content/uploads/horst-main_0.png"><img class="alignnone size-full wp-image-40041" src="http://www.freesandal.org/wp-content/uploads/horst-main_0.png" alt="horst-main_0" width="718" height="510" /></a>  <span style="color: #808080;"><strong>【訊號‧雜訊‧歷史】</strong></span>  <a href="http://www.freesandal.org/wp-content/uploads/horst-history_1.png"><img class="alignnone size-full wp-image-40040" src="http://www.freesandal.org/wp-content/uploads/horst-history_1.png" alt="horst-history_1" width="718" height="510" /></a>  <span style="color: #808080;"><strong>【頻譜分析】</strong></span>  <a href="http://www.freesandal.org/wp-content/uploads/horst-spec1.png"><img class="alignnone size-full wp-image-40042" src="http://www.freesandal.org/wp-content/uploads/horst-spec1.png" alt="horst-spec1" width="718" height="510" /></a>  <span style="color: #808000;">以期加深讀者對無線網路的認識。由於這個程式使用 IEEE802.11 的『monitor』操作模式,讀者可用『 iw list 』來確認 USB 無線 dongle 是否具有這個模式︰</span> <pre class="lang:sh decode:true "># iw 工具安裝 pi@raspberrypi ~ sudo apt-get install iw

# 如果 iw list 顯示空行,那個 USB WiFi dongle 不具 IEEE802.11 相容模式。

pi@raspberrypi ~ $ iw list
Wiphy phy0
# ………
# USB WiFi dongle 提供哪些模式
	Supported interface modes:
		 * IBSS
		 * managed
		 * AP
		 * AP/VLAN
		 * WDS
# 有 monitor 模式
		 * monitor
		 * mesh point
	software interface modes (can always be added):
		 * AP/VLAN
		 * monitor
	valid interface combinations:
		 * #{ AP, mesh point } <= 8,
		   total <= 8, #channels <= 1

─ 摘自《勇闖新世界︰ W!o《卡夫卡村》變形祭︰圓局定向‧四