TS-4900 yocto wifi: Difference between revisions

From embeddedTS Manuals
No edit summary
No edit summary
Line 24: Line 24:
</source>
</source>


You can use the iwconfig command to determine if you have authenticated to an access point.  Before connecting it will show something similar to this:
Use the iwconfig command to determine authentication to an access point.  Before connecting it will show something like this:
<pre style="font-family:monospace,Courier New ;background:black; width:18cm; white-space: pre-wrap; white-space: -moz-pre-wrap; word-wrap: break-word; color:white; ">
<pre style="font-family:monospace,Courier New ;background:black; width:18cm; white-space: pre-wrap; white-space: -moz-pre-wrap; word-wrap: break-word; color:white; ">
# iwconfig wlan0
# iwconfig wlan0
Line 38: Line 38:
</pre>
</pre>


If you are connecting using WEP, you will need to define a network key:
If connecting using WEP, also specify a network key:
<source lang=bash>
<source lang=bash>
iwconfig wlan0 essid "default" key "yourpassword"
iwconfig wlan0 essid "default" key "yourpassword"
</source>
</source>


If you are connecting to WPA you will need to use wpa_passphrase and wpa_supplicant:
If connecting to a WPA network use wpa_passphrase and wpa_supplicant:
<source lang=bash>
<source lang=bash>
mkdir /etc/wpa_supplicant/
mkdir /etc/wpa_supplicant/
Line 49: Line 49:
</source>
</source>


Now that you have the configuration file, you will need to start the wpa_supplicant daemon:
After generating the configuration file the wpa_supplicant daemon can be started.
<source lang=bash>
<source lang=bash>
wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -B
wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -B
</source>
</source>


This will typically come back with:
This will come back with:
   root@ts-imx6-q:~# wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
   root@ts-imx6-q:~# wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
   Successfully initialized wpa_supplicant
   Successfully initialized wpa_supplicant
Line 66: Line 66:
   [  307.047989] wlcore: Association completed.
   [  307.047989] wlcore: Association completed.


As with open networks you can now use "iwconfig wlan0" and verify an "Access Point" is specified as well as the link quality to verify connection.
Use "iwconfig wlan0" to verify an "Access Point" is specified to verify a connection.  This will also report the link quality to the AP.


Now you are connected to the network, but this would be close to the equivalent of connecting a network cable.  To connect to the internet or talk to your internal network you will need to configure the interface.  See the [[#Configuring the Network]] for more information, but commonly you can just run:
Wireless may be associated, but this does not get an IP on the network.  To connect to the internet or talk to the internal network first configure the interface.  See the [[#Configuring the Network]], but on many networks only a DHCP client is needed:
<source lang=bash>
<source lang=bash>
udhcpc -i wlan0
udhcpc -i wlan0
</source>
</source>


You can also configure systemd to automatically set up wpa_supplicant on startup.
Systemd can also be configured to start wpa_supplicant on boot up.
<source lang=bash>
<source lang=bash>
# Assuming you used the same path for the wpa conf file as shown above
# Assuming the same path for the wpa conf file as shown above
systemctl enable wpa_supplicant@wlan0
systemctl enable wpa_supplicant@wlan0
systemctl start wpa_supplicant@wlan0
systemctl start wpa_supplicant@wlan0
</source>
</source>


Once this service is started it will bring up the wlan0 link and associate it to your access point, but you still need to configure tcp/ipYou can configure the IP settings the same way as a wired network.
Once this service is started it will bring up the wlan0 link and associate it to the specified access point.  Configure the IP settings the same way as a wired network.


In /etc/systemd/network/wlan0.network
In /etc/systemd/network/wlan0.network
Line 91: Line 91:
</source>
</source>


For a static configuration you would create a config file for that specific interface.
For a static configuration create a config file for that specific interface.
/etc/systemd/network/wlan0.network
/etc/systemd/network/wlan0.network
<source lang=ini>
<source lang=ini>

Revision as of 16:09, 10 February 2017

Yocto uses systemd to start wpa_supplicant, and networkd to get a dhcp or static IP on that network.

Scan for a network

ifconfig wlan0 up

# Scan for available networks
iwlist wlan0 scan

In this case I'm connecting to "default" which is an open network:

          Cell 03 - Address: c0:ff:ee:c0:ff:ee
                    Mode:Managed
                    ESSID:"default"
                    Channel:2
                    Encryption key:off
                    Bit Rates:9 Mb/s

To connect to this open network manually for just this boot:

iwconfig wlan0 essid "default"

Use the iwconfig command to determine authentication to an access point. Before connecting it will show something like this:

# iwconfig wlan0
wlan0     IEEE 802.11bgn  ESSID:"default"  
          Mode:Managed  Frequency:2.417 GHz  Access Point: c0:ff:ee:c0:ff:ee   
          Bit Rate=1 Mb/s   Tx-Power=20 dBm   
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=70/70  Signal level=-34 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

If connecting using WEP, also specify a network key:

iwconfig wlan0 essid "default" key "yourpassword"

If connecting to a WPA network use wpa_passphrase and wpa_supplicant:

mkdir /etc/wpa_supplicant/
wpa_passphrase the_essid the_password >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

After generating the configuration file the wpa_supplicant daemon can be started.

wpa_supplicant -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -B

This will come back with:

 root@ts-imx6-q:~# wpa_supplicant -iwlan0 -c/etc/wpa_supplicant.conf -B
 Successfully initialized wpa_supplicant
 root@ts-imx6-q:~# [  306.924691] wlan0: authenticate with 28:cf:da:b0:f5:bb
 [  306.959415] wlan0: send auth to 28:cf:da:b0:f5:bb (try 1/3)
 [  306.968137] wlan0: authenticated
 [  306.978477] wlan0: associate with 28:cf:da:b0:f5:bb (try 1/3)
 [  306.988577] wlan0: RX AssocResp from 28:cf:da:b0:f5:bb (capab=0x1431 status=0 aid=9)
 [  307.009751] wlan0: associated
 [  307.012768] IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
 [  307.047989] wlcore: Association completed.

Use "iwconfig wlan0" to verify an "Access Point" is specified to verify a connection. This will also report the link quality to the AP.

Wireless may be associated, but this does not get an IP on the network. To connect to the internet or talk to the internal network first configure the interface. See the #Configuring the Network, but on many networks only a DHCP client is needed:

udhcpc -i wlan0

Systemd can also be configured to start wpa_supplicant on boot up.

# Assuming the same path for the wpa conf file as shown above
systemctl enable wpa_supplicant@wlan0
systemctl start wpa_supplicant@wlan0

Once this service is started it will bring up the wlan0 link and associate it to the specified access point. Configure the IP settings the same way as a wired network.

In /etc/systemd/network/wlan0.network

[Match]
Name=wlan0

[Network]
DHCP=yes

For a static configuration create a config file for that specific interface. /etc/systemd/network/wlan0.network

[Match]
Name=wlan0

[Network]
Address=192.168.0.50/24
Gateway=192.168.0.1
DNS=192.168.0.1

For more information on what options are available to configure the network, see the systemd network documentation.