[[labs.beatcraft.com]]~
[[Raspberry Pi]]~
[[Raspbian]]~

#contents
* Using Planex GW-450D on Raspberry Pi 2 (self-compiling)[#nc9dccde]
>
This article explains how to connect [[11ac Planex GW-450D:http://www.planex.co.jp/products/gw-450d/] with Raspberry Pi 2 and how to use it on Raspbian.~
~
To follow the directions, which are described in [[Raspberry Pi 2 kernel self-compile]], complete kernel compile and boot from the new kernel, first. Then, following this article, please build the driver of GW-450D.~
~
** Obtaining the source code [#n0633bb2]
>
Obtain the source code of driver from the site of [[planex:http://www.planex.co.jp/support/download/gw-450d/driver_linux.shtml]].~
To download the source code of driver, you need to agree the license agreement. Using the command of wget, the source code cannot be downloaded on Raspbian directly. Download it by a browser on PC, and copy the source code to Raspberry Pi 2, applying the command of scp.~

** Unzipping (Extraction) [#a14c0541]
>
Unzip the source code archive.~
Because the source code of driver has been compressed twice, please decompress the downloaded zip file with zip, then decompress the extracted bzip2 file with tar.~
 pi@raspberrypi ~ $ cd src/
 pi@raspberrypi ~/src $ unzip gw-450d_driver_linux_v3002.zip
 pi@raspberrypi ~/src $ mv gw- 450d_driver_linux_v3002/mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2 .
 pi@raspberrypi ~/src $ tar xvf mt7610u_wifi_sta_v3002_dpo_20130916.tar.bz2
 pi@raspberrypi ~/src $ cd mt7610u_wifi_sta_v3002_dpo_20130916/

** patch [#tfd3b83f]
>
Please add a patch. The patch is listed at the [[website:http://neuralassembly.blogspot.jp/2015/09/raspberry-pi-2-kernel-416-5ghzwifigw.html]], which provides detail explanation for how to use a 5GHz WiFi support dongle, GW-450D, on kernel 4.1.6 of Raspberry Pi 2.~
 pi@raspberrypi ~/src/mt7610u_wifi_sta_v3002_dpo_20130916 $ wget https://raw.githubusercontent.com/neuralassembly/raspi/master/gw-450d/gw-450d-rpi-kernel41.patch
 pi@raspberrypi ~/src/mt7610u_wifi_sta_v3002_dpo_20130916 $ patch -p0 < gw-450d-rpi-kernel41.patch
 patching file common/rtusb_dev_id.c
 patching file include/os/rt_linux.h
 patching file os/linux/config.mk
 patching file os/linux/rt_linux.c
 patching file sta/sta_cfg.c
 patching file common/cmm_info.c

**Build [#e7e733a0]
>
Let's start the build process.~
As the build process is completed, m7650u_sta.ko is generated.
 pi@raspberrypi ~/src/mt7610u_wifi_sta_v3002_dpo_20130916 $ sudo -s
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# time make   2>&1 | tee make.log
   ~~ Skipping ~~
   Building modules, stage 2.
   MODPOST 1 modules
   CC      /home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/mt7650u_sta.mod.o
   LD [M]  /home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/mt7650u_sta.ko
make[1]: Leaving directory '/usr/src/linux'
 cp -f /home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916/os/linux/mt7650u_sta.ko /tftpboot 2>/dev/null || :
 
 real    7m18.044s
 user    6m45.910s
 sys     0m20.800s
~
The size of module is 18M.~
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# ls -alh os/linux/mt7650u_sta.ko
 -rw-r--r-- 1 root root 18M Nov  5 20:12 os/linux/mt7650u_sta.ko

** Installation [#rac50ea1]
>
Do not apply the command of make install. Please copy it and apply the command of depmod.~
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# cp -p os/linux/mt7650u_sta.ko /lib/modules/4.1.10-v7+/kernel/drivers/net/wireless/
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# depmod -a

**Placing configuration file [#nc0322b1]
>
Create a directory where the configuration file is stored. The file lists the configuration of driver.~
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# mkdir -p /etc/Wireless/RT2870STA
 root@raspberrypi:/home/pi/src/mt7610u_wifi_sta_v3002_dpo_20130916# cp RT2870STA.dat /etc/Wireless/RT2870STA/

** Checking load [#x82e4bc9]
>
As kernel module is installed and GW-450D is inserted to Raspberry Pi 2, mt7650u_stako is loaded and the network interface, ra*, is created.~
 root@raspberrypi:~# lsmod
 Module                  Size  Used by
 cfg80211              410393  0
 rfkill                 15913  1 cfg80211
 mt7650u_sta           906627  1
 bcm2835_gpiomem         2860  0
 uio_pdrv_genirq         2924  0
 uio                     7784  1 uio_pdrv_genirq
 i2c_dev                 5610  0
 snd_bcm2835            19808  3
 snd_pcm                73405  1 snd_bcm2835
 snd_timer              17657  1 snd_pcm
 snd                    50337  9 snd_bcm2835,snd_timer,snd_pcm
 fuse                   79934  3
 ipv6                  336324  34

>
 root@raspberrypi:~# iwconfig
 ra0       Ralink STA  ESSID:""  Nickname:"MT7610U_STA"
           Mode:Auto  Frequency=2.412 GHz  Access Point: Not-Associated
           Bit Rate:1 Mb/s
           RTS thr:off   Fragment thr:off
           Encryption key:off
           Link Quality=10/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
 
 lo        no wireless extensions.
 
 eth0      no wireless extensions.

**Configuring network [#p748e913]
>
Create a configuration item, ra0, below wlan0, which is listed on /etc/network/interfaces. Configure SSID and passphrase for the targeted access point.~
 # vi /etc/network/interfaces
  (Please provide the information)
 allow-hotplug ra0
 auto ra0
 iface ra0 inet manual
 wpa-ssid "your-ssid"
 wpa-psk "your-passwd"

**Editing the configuration file [#wf90ab69]
>
wpa_supplicant automatically configures the settings of authentication method and encryption scheme, and the network configuration, which is done in the previous section, and is supposed to connect the access point. However, depending on the configuration of an access point, it may reject the connection. If rejection happens, must set up authentication method and encryption scheme in the configuration file, explicitly.~
 SSID=
 AuthMode=WPA2PSK
 EncrypType=TKIP
~
SSID is kept empty since it is configured at the network configuration.~
The values, which AuthMode can configure, are: WEPAUTO, OPEN, SHARED, WPAPSK, WPA2SK, and WPANONE.~
The values, which EncrypType can configure, are: NONE, WEP, TKIP, and AES.~
~
The details of configurable values of other configuration items, which are listed on /etc/Wireless/RT2870STA/RT2870STA.dat, are written in mt7610u_wifi_sta_v3002_dpo_20130916/doc/README_STA_usb. This is located in the driver source archive.~

**Rebooting [#la663bba]
>
As the configuration is completed and the system is rebooted, it obtains IP address as it is shown below.~
 root@raspberrypi:~# ifconfig
 eth0      Link encap:Ethernet  HWaddr b8:27:eb:c2:87:00
           inet addr:192.168.0.145  Bcast:192.168.0.255  Mask:255.255.255.0
           inet6 addr: fe80::ba27:ebff:fec2:8700/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:70510 errors:0 dropped:10715 overruns:0 frame:0
           TX packets:5921 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:12997010 (12.3 MiB)  TX bytes:927393 (905.6 KiB)
 
 lo        Link encap:Local Loopback
           inet addr:127.0.0.1  Mask:255.0.0.0
           inet6 addr: ::1/128 Scope:Host
           UP LOOPBACK RUNNING  MTU:65536  Metric:1
           RX packets:8 errors:0 dropped:0 overruns:0 frame:0
           TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:0
           RX bytes:1104 (1.0 KiB)  TX bytes:1104 (1.0 KiB)
 
 ra0       Link encap:Ethernet  HWaddr 00:22:cf:ed:11:cd
           inet addr:192.168.0.152  Bcast:192.168.0.255  Mask:255.255.255.0
           inet6 addr: fe80::1fef:b53:2e47:12de/64 Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
           RX packets:237874 errors:0 dropped:8164 overruns:0 frame:0
           TX packets:1756 errors:0 dropped:0 overruns:0 carrier:0
           collisions:0 txqueuelen:1000
           RX bytes:46173923 (44.0 MiB)  TX bytes:117107 (114.3 KiB)

>
 root@raspberrypi:~# iwconfig
 ra0       Ralink STA  ESSID:"Beatcraft2"  Nickname:"MT7610U_STA"
           Mode:Managed  Frequency=2.442 GHz  Access Point: 00:3A:9D:91:93:BE
           Bit Rate=54 Mb/s
           RTS thr:off   Fragment thr:off
           Encryption key:00D4-3E01-8CE2-6AE9-69D8-32D7-92E1-7C02 [3]   Security mode:open
           Link Quality=98/100  Signal level:-46 dBm  Noise level:-49 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.

**Troubleshooting [#a123b842]
>
As the connection is failed, please check the status by analyzing the logs of wpa_supplicant and dhcpcd, which are stored in /var/log/syslog.~
As the connection is successfully established, the log shown below is output.~
 Oct 16 19:15:08 raspberrypi kernel: [   14.122857] cfg80211: Calling CRDA to update world regulatory domain
 Oct 16 19:15:08 raspberrypi wpa_supplicant[480]: ra0: WPA: Key negotiation completed with 00:3a:9d:91:93:be [PTK=TKIP GTK=TKIP]
 Oct 16 19:15:08 raspberrypi wpa_supplicant[480]: ra0: CTRL-EVENT-CONNECTED - Connection to 00:3a:9d:91:93:be completed [id=0 id_str=]
 Oct 16 19:15:08 raspberrypi dhcpcd[591]: ra0: carrier acquired
 Oct 16 19:15:08 raspberrypi dhcpcd[551]: dhcpcd[591]: ra0: carrier acquired
 Oct 16 19:15:08 raspberrypi dhcpcd[591]: ra0: IAID cf:ed:11:cd
 Oct 16 19:15:08 raspberrypi dhcpcd[551]: dhcpcd[591]: ra0: IAID cf:ed:11:cd
 Oct 16 19:15:08 raspberrypi dhcpcd[591]: ra0: rebinding lease of 192.168.0.152
 Oct 16 19:15:08 raspberrypi dhcpcd[551]: dhcpcd[591]: ra0: rebinding lease of 192.168.0.152
 Oct 29 19:15:08 raspberrypi dhcpcd[591]: ra0: soliciting an IPv6 router
 Oct 29 19:15:08 raspberrypi dhcpcd[551]: dhcpcd[591]: ra0: soliciting an IPv6 router
~
To find out the causes of failure, first, erase the items of ra0, which is listed at /etc/network/interfaces. Then, manually configure r0 step by step.~
~
If the authentication process fails at wpa_supplicant, create a wpa_supplicant.conf, which is used for a testing process. Please apply the command line below, create wpa_supplicant.conf.~
 root@raspberrypi:~# wpa_passphrase your-ssid your-passwd > wpa_supplicant.conf
~
Please add the configuration of authentication method and encryption scheme to the outputted wpa_supplicant.conf.~
 network={
         proto=RSN
         key_mgmt=WPA-PSK
         pairwise=TKIP         
         ssid="your-ssid"
         #psk="your-passwd"
         psk=bfc743cad6d376b47075c9f336e03c7e852e11ba22230edfc3deb6de9f414bf0
 }
~
Adding the information mentioned above to the configuration file, please select this file as the configuration file. Please execute wpa_supplicant at the foreground, check the status of authentication.~
 root@raspberrypi:~# wpa_supplicant -D nl80211,wext -i ra0 -c wpa_supplicant.conf -dd
 ~~ Skipping ~~
 ra0: State: COMPLETED -> GROUP_HANDSHAKE
 WPA: Group Key - hexdump(len=32): [REMOVED]
 ra0: WPA: Installing GTK to the driver (keyidx=1 tx=0 len=32)
 WPA: RSC - hexdump(len=6): 0f 11 00 00 00 00
 wpa_driver_wext_set_key: alg=2 key_idx=1 set_tx=0 seq_len=6 key_len=32
 ra0: WPA: Sending EAPOL-Key 2/2
 WPA: KCK - hexdump(len=16): [REMOVED]
 WPA: Derived Key MIC - hexdump(len=16): a0 9a 5f e1 4b cb 62 f9 11 fc d1 95 bd 9c ed c0
 ra0: WPA: Group rekeying completed with 00:3a:9d:91:93:be [GTK=TKIP]
 ra0: Cancelling authentication timeout
 ra0: State: GROUP_HANDSHAKE -> COMPLETED
 EAPOL: startWhen --> 0
 EAPOL: disable timer tick
~
If this authentication process is successfully completed, the status of authentication is shown as above. Please try to reset the authentication file until complete the setting of the authentication file.~
As the setting-up of configuration file is completed, applying the command line below, let wpa_supplicant be executed in background.~
 root@raspberrypi:~# wpa_supplicant -D nl80211,wext -i ra0 -c wpa_supplicant.conf -B
~
If dhcpcd is running, IP address may already be obtained. Please apply the command line below, make sure whether IP address is obtained or not.~
 root@raspberrypi:~# /etc/init.d/dhcpcd status 
 &#9679; dhcpcd.service - LSB: IPv4 DHCP client with IPv4LL support
    Loaded: loaded (/etc/init.d/dhcpcd)
    Active: active (running) since Thu 2015-10-16 20:48:57 JST; 36s ago
   Process: 2896 ExecStop=/etc/init.d/dhcpcd stop (code=exited, status=0/SUCCESS)
   Process: 3000 ExecStart=/etc/init.d/dhcpcd start (code=exited, status=0/SUCCESS)
    CGroup: /system.slice/dhcpcd.service
            mq3024 /sbin/dhcpcd
 
 Oct 16 20:48:57 raspberrypi dhcpcd[3000]: dhcpcd[3005]: forked to background...4
 Oct 16 20:48:57 raspberrypi dhcpcd[3005]: forked to background, child pid 3024
 Oct 16 20:48:57 raspberrypi systemd[1]: Started LSB: IPv4 DHCP client with I....
 Oct 16 20:48:57 raspberrypi dhcpcd[3024]: ra0: rebinding lease of 192.168.0.152
 Oct 16 20:48:57 raspberrypi dhcpcd[3024]: ra0: soliciting an IPv6 router
 Oct 16 20:49:02 raspberrypi dhcpcd[3024]: ra0: leased 192.168.0.152 for 4320...s
 Oct 16 20:49:02 raspberrypi dhcpcd[3024]: ra0: adding route to 192.168.0.0/24
 Oct 16 20:49:02 raspberrypi dhcpcd[3024]: ra0: adding default route via 192....4
 Oct 16 20:49:09 raspberrypi dhcpcd[3024]: eth0: no IPv6 Routers available
 Oct 16 20:49:09 raspberrypi dhcpcd[3024]: ra0: no IPv6 Routers available
Hint: Some lines were ellipsized, use -l to show in full.

 Hint: Some lines were ellipsized, use -l to show in full.
~
If IP address is not obtained, please execute dhclient at the foreground, and analyze the current status.~
 root@raspberrypi:~# dhclient -d ra0
 Internet Systems Consortium DHCP Client 4.3.1
 Copyright 2004-2014 Internet Systems Consortium.
 All rights reserved.
 For info, please visit https://www.isc.org/software/dhcp/ 
 
 Listening on LPF/ra0/00:22:cf:ed:11:cd
 Sending on   LPF/ra0/00:22:cf:ed:11:cd
 Sending on   Socket/fallback
 DHCPREQUEST on ra0 to 255.255.255.255 port 67
 DHCPACK from 192.168.0.254
 bound to 192.168.0.158 -- renewal in 18949 seconds.

If IP address is successfully obtained, the log shown above appears.

** Reference [#z0fae66a]
>
-Refer to the article [[Let GW-450D, a5GHz-support WiFi dongle,  work on Raspberry Pi 2 + kernel 4.1.6:http://neuralassembly.blogspot.jp/2015/09/raspberry-pi-2-kernel-416-5ghzwifigw.html]], let Raspbian, which runs on Raspberry Pi 2, work with GW-450D.~
-[[Rebuild kernel of Raspberry Pi 2 and use GW-450D on it:http://blog.mamemomonga.com/2015/02/raspberry-pi2gw-450d.html]]~
-[[Use GW-450D (a 802.11ac support Wireless LAN Dongle) of Planex on Raspberry Pi 2 + NOOBS:http://qiita.com/tsukaman/items/44abe042d2184c021b4b]]~
-[[As RASPBERRY Pi 2 boots, spontaneously start GW-450D of Planex automatically:http://qiita.com/moutend/items/1fe67d1917ff25df198c]]~


*Revision History [#f6a80772]
>
- 2016-02-16 This article is initially published.

Front page   Edit Diff Backup Upload Copy Rename Reload   New List of pages Search Recent changes   RSS of recent changes