HamsterBear F1C200s v5.17 Linux RTL8188EUS 適配

jensenhua發表於2022-04-20

HamsterBear F1C200s v5.17 Linux RTL8188EUS 適配

  • 平臺 - F1C200s

  • Linux版本 - 5.17.2

  • Buildroot - v2022.2

底板做了USB HUB, 用的是FE1.1s,一共做了4路,其中一路拿來連wifi模組,另外
3個直接做成了USB Type-A介面
image
image

image

進入 kernel menuconfig 開啟如下選項

(該驅動位於staging下,選擇編譯進核心)

buildroot中選擇如下軟體包

(主要是net-tools iw工具包)

啟動系統後

1. 修改musb 為host模式

echo host > /sys/devices/platform/soc/1c13000.usb/musb-hdrc.1.auto/mode

[ 1379.560411] phy phy-1c13400.phy.0: Changing dr_mode to 1
[ 1380.223933] usb 1-1: new high-speed USB device number 2 using musb-hdrc
[ 1380.405841] hub 1-1:1.0: USB hub found
[ 1380.409764] hub 1-1:1.0: 4 ports detected
[ 1380.833942] usb 1-1.1: new high-speed USB device number 3 using musb-hdrc
[ 1381.146412] r8188eu: module is from the staging directory, the quality is unknown, you have been warned.
[ 1381.170314] Chip Version Info: CHIP_8188E_Normal_Chip_TSMC_D_CUT_1T1R_RomVer(0)
[ 1381.205020] EEPROM ID = 0x8129
[ 1381.212399] usbcore: registered new interface driver r8188eu

ip addr 可以看到對應wifi介面

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: usb0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether 52:8c:6f:55:1f:64 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000
    link/ether 54:ef:33:d6:5e:72 brd ff:ff:ff:ff:ff:ff

2. 連線到wifi

上電

# ifconfig wlan0 up
[ 1687.899356] R8188EU: Firmware Version 11, SubVersion 1, Signature 0x88e1
[ 1688.274263] MAC Address = 54:ef:33:d6:5e:72

掃描附近wifi

# iwlist wlan0 scan
wlan0     Scan completed :
          Cell 01 - Address: 8C:DE:F9:EC:55:8B
                    ESSID:""
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.422 GHz (Channel 3)
                    Encryption key:off
                    Bit Rates:144 Mb/s
                    Quality:0  Signal level:0  Noise level:0
          Cell 02 - Address: 96:DE:F9:EC:55:8B
                    ESSID:"kernelbot"
                    Protocol:IEEE 802.11bgn
                    Mode:Master
                    Frequency:2.422 GHz (Channel 3)
                    Encryption key:off
                    Bit Rates:144 Mb/s
                    IE: Unknown: DD820050F204104A0001101044000101103B00010310470010876543219ABCDEF012340AA3C33C838F102100067869616F6D69102300045241383110240004303030321042000531323334351054000800060050F2040001101100135849414F4D495F524F555445525F4755455354100800020000103C0001031049000600372A000120
                    Quality:0  Signal level:0  Noise level:0

連線到wifi

# iwconfig wlan0 essid kernelbot
# iwconfig
lo        no wireless extensions.

usb0      no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"kernelbot"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.422 GHz  Access Point: 96:DE:F9:EC:55:8B
          Bit Rate:72.2 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=100/100  Signal level=0 dBm  Noise level=0 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

請求ip

# udhcpc -i wlan0
udhcpc: started, v1.35.0
udhcpc: broadcasting discover
udhcpc: broadcasting select for 192.168.19.234, server 192.168.19.1
udhcpc: lease of 192.168.19.234 obtained from 192.168.19.1, lease time 43200
deleting routers
adding dns 192.168.19.1

嘗試訪問外網(沒接天線)

# ping baidu.com
PING baidu.com (220.181.38.148): 56 data bytes
64 bytes from 220.181.38.148: seq=0 ttl=50 time=201.784 ms
64 bytes from 220.181.38.148: seq=1 ttl=50 time=225.148 ms
64 bytes from 220.181.38.148: seq=2 ttl=50 time=15.126 ms
64 bytes from 220.181.38.148: seq=3 ttl=50 time=116.496 ms
64 bytes from 220.181.38.148: seq=4 ttl=50 time=115.356 ms
64 bytes from 220.181.38.148: seq=5 ttl=50 time=21.000 ms
64 bytes from 220.181.38.148: seq=6 ttl=50 time=114.353 ms
64 bytes from 220.181.38.148: seq=7 ttl=50 time=122.406 ms
^C
--- baidu.com ping statistics ---
8 packets transmitted, 8 packets received, 0% packet loss
round-trip min/avg/max = 15.126/116.458/225.148 ms

更多玩法

1. MQTT與上位機通訊

	大概業務就是 掃描感測器資料上報給上位機
	上位機也可以指定從機行為

2. 移植瀏覽器訪問網頁

3. 掛載主機NFS檔案系統

4. 做內網WEB伺服器

5. 暫時沒想到

總結以及遇到的一些問題

總結

因為一開始設計思路就比較清晰,所以整個過程還是比較順利的,底板設計的時候,因為
粗心大意連錯了線,所以又再版了。

核心 buildroot那兩塊等有空再寫詳細點。

有問題可以聯絡我郵箱(writeforever@foxmail.com)

問題

  1. 模組上電後掃描自動斷開連線
    後來發現是供電不夠,一開始一直用電腦USB介面供電,但那個最大電流貌似就500mA,
    換了個充電頭就ok了。

相關文章