Saturday, October 22, 2016

OrangePi Lite - armbian wifi/wlan setup

Orange Pi Lite:
While not listed on www.orangepi.org/ it is available on www.aliexpress.com/ for $14.44 incl. shipping.

I selected this model because it has build-in Wifi. I don't have an network cable at the printer and therefore I will use Wifi.

Armbian:
Availabe at www.armbian.com/ as desktop or server version, I selected the server version without X server.
Version used: Armbian_5.20_Orangepilite_Debian_jessie_3.4.112.7z

Initial setup:
Download the armbian image archive and write the unpacked image to a microSD card (I used Etcher www.etcher.io to write the image). Then put the card into the orangepi, connect a usb keyboard and a HDMI display, and power it up.
It will show a boot prompt shortly, do not log in! armbian is setting up disk size and a swap partition in the background, you'll have to wait a few minutes (depending on the microSD card speed) until it reboots. Then you can log in as root with the password 1234. It will promt you to change the root password and to set up an additional user. I selected the login name 'user'.

Wifi setup:
The first thing you might want to setup if Wifi, and then you can do all further configuration over ssh, and it has quite a few steps, in my case the SSID in named 'mySSIDhere', just replace it with yours:
Test if the wlan adapter is working at all:
root@orangepilite:~# iw dev
 phy#0
     Interface wlan0
         ifindex 3
         type managed
 root@orangepilite:~# 
Set your country specific WLAN profile (for the UK it's GB, as in this example). A list of all country codes is at the time of writing available at en.wikipedia.org/wiki/ISO_3166-1_alpha-2 - otherwise google for ' ISO / IEC 3166 alpha2 country code' (replace with your country code):
root@orangepilite:~# iw reg set GB

Bring the adapter up:
root@orangepilite:~# ip link set dev wlan0 up 
Scan for access points (without the grep it will display a lot more info):
root@orangepilite:~# iw dev wlan0 scan | grep SSID
     SSID: mySSIDhere
If your access point isn't using encryption you can connect already:
root@orangepilite:~# iw dev wlan0 connect mySSIDhere 
Check a few times until the connection is there, either it says 'Not connected' or it shows an info like this:
root@orangepilite:~# iw dev wlan0 link
 Connected to 00:00:00:00:00:00 (on wlan0)
     SSID: mySSIDhere
     freq: 2472
     signal: -72 dBm
     tx bitrate: 150.0 MBit/s
 root@orangepilite:~#
Get an IP addresss over DHCP (I'm assuming you're using DHCP on your Wifi network, as most users do):
root@orangepilite:~# dhclient -v wlan0 


If your access point is configured with WPA it's a little bit more complicated, replace myPasswordHere with the actual password:
root@orangepilite:~# wpa_passphrase mySSIDhere myPasswordHere >/root/wpa.conf
 
   root@orangepilite:~# cat /root/wpa.conf
   network={
       ssid="mySSIDhere"
       #psk="myPasswordHere"
       psk=04817c03bb5fd9d1c6d561a881f192da77501b47d0ac80598eb44191c603c516
   }
   root@orangepilite:~#  
 Check a few times until the connection is there, either it says 'Not connected' or it shows an info like this:
root@orangepilite:~# iw dev wlan0 link
   Connected to 00:00:00:00:00:00 (on wlan0)
       SSID: mySSIDhere
       freq: 2472
       signal: -72 dBm
       tx bitrate: 150.0 MBit/s
   root@orangepilite:~#
Get an IP addresss over DHCP (I'm assuming you're using DHCP on your Wifi network, as most users do):
root@orangepilite:~# dhclient -v wlan0 


Now it's time to test if ssh is working, figure out your ip address with ifconfig and test ssh. I got IP address 192.168.0.5 and connected with it:
ifconfig wlan0 
 wlan0 Link encap:Ethernet HWaddr 00:00:00:00:00:00 
 inet addr:192.168.0.5 Bcast:192.168.0.255 Mask:255.255.255.0 
 [...] 
  
 root@orangepilite:~# ssh 192.168.0.5 
 root@192.168.1.108's password: 

  ___                               ____  _   _     _ _
 / _ \ _ __ __ _ _ __   __ _  ___  |  _ \(_) | |   (_) |_ ___
| | | | '__/ _` | '_ \ / _` |/ _ \ | |_) | | | |   | | __/ _ \
| |_| | | | (_| | | | | (_| |  __/ |  __/| | | |___| | ||  __/
 \___/|_|  \__,_|_| |_|\__, |\___| |_|   |_| |_____|_|\__\___|
                       |___/
  
 Welcome to ARMBIAN Debian GNU/Linux 8 (jessie) 3.4.112-sun8i 
 System load: 0.02 Up time: 2 hours Local users: 3 
 Memory usage: 12 % of 494Mb IP: 192.168.1.108 
 CPU temp: 61°C 
 Usage of /: 9% of 15G 
  
 root@orangepilite:~#

Now you can switch to your PC and connect with ssh (on Windows you can use putty (free, www.putty.org), MobaXter (free for personal use, mobaxterm.mobatek.net), SecureCRT ($99, www.vandyke.com) or any other ssh client).

The most important thing is to write the Wifi settings into the configuration file '/etc/network/interfaces', so here it goes (without the use of editors like vi or nano). :
root@orangepilite:~# cat /root/wpa.conf
network={
        ssid="mySSIDhere"
        #psk="myPasswordHere"
        psk=04817c03bb5fd9d1c6d561a881f192da77501b47d0ac80598eb44191c603c516
}
Prepare a text document that you can easily copy and paste with the following contents (replacing the text behind wpa-ssid and wpa-psk with the values from your '/root/wpa.conf':
echo "# Local loopback
auto lo
iface lo inet loopback

# Wlan

auto wlan0
iface wlan0 inet dhcp
        wpa-ssid        mySSIDhere
        wpa-psk         04817c03bb5fd9d1c6d561a881f192da77501b47d0ac80598eb44191c603c516
" > /etc/network/interfaces
Then select it all, copy it and paste it over to your ssh session:
root@orangepilite:~# echo "# Local loopback
auto lo
iface lo inet loopback

# Wlan
auto wlan0

iface wlan0 inet dhcp
        wpa-ssid        mySSIDhere
        wpa-psk         04817c03bb5fd9d1c6d561a881f192da77501b47d0ac80598eb44191c603c516" > /etc/network/interfaces
root@orangepilite:~#

The county code is to be written to a config file '/etc/default/crda' as well, so here it goes (replace with your country code):
 root@orangepilite:~# echo "REGDOMAIN=GB" > /etc/default/crda

All config files are written, so it's time to reboot in order to test it:
root@orangepilite:~# sync
root@orangepilite:~# reboot
If you didn't make any errors you can connect with ssh to the orangepi after this reboot.

2 comments:

  1. With Armbian 5.69 the location of /root/wpa.conf changed to /wpa_supplicant.conf and needs two additional lines:
    ctrl_interface=/run/wpa_supplicant
    update_config=1

    ReplyDelete