Donnerstag, 15. Januar 2015

gpsd on archlinux

As of 20150115 gpsd is not running out of the box on ArchlinuxARM on my RaspberryPI.

The reason i found is that the system.d service file of gpsd is pointing to a none existing gpsd configuration file.
To make gpsd work with a GPS connected to USB you need to do the following.

Install gpsd with

pacman -S gpsd

Plug in the GPS and check for the device with

ls -l /dev/tty*

in my case the device is registered as /dev/ttyACM0

Edit the gpsd configuration file


change the device line according to the device name as found before.


Change the gpsd systemd service file to point to correct configuration


needs to be changed to

Description=GPS (Global Positioning System) Daemon

ExecStart=/usr/bin/gpsd -N $GPSD_OPTIONS $DEVICES


start and enable gpsd.service to start it automatically at boot

systemctl start gpsd.service
systemctl enable gpsd.service

if you start now e.g. cgps you should see data from your gps.

have fun!

- dk7xe -

Dienstag, 6. Januar 2015

Wireless AP on RaspberryPi / ArchLinux

I'm using one of my RaspberryPi devices as a "Development Environment" where i test new things on. Most of the times i'm doing this while being on the train from/to office. To be able to access the Pi without a cable connection i have set up a wireless software access point.
This post describes how to do that on the Pi under ArchLinux.

All you need is a working WLAN card that can act as AP, a working LAN network connection on the PI and some time to configure the software ;-)

Since i like to access the PI only i am not going into details of IP routing. Means LAN (eth0) and WLAN (wlan0) will be separated.
In the guide below it's assumed that eth0 (LAN port) get's a dynamic IP adress when connected to a network. wlan0 (wireless lan) has a fixed ip address of
The host name of the Raspberry Pi device in this guide is "flypi".

With ip link we check if the wireless adapter is present and its device name:

[root@flypi ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:c8 brd ff:ff:ff:ff:ff:ff
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
    link/ether xx:xx:xx:xx:xx:5f brd ff:ff:ff:ff:ff:ff
[root@flypi ~]# 

In my case the device is registered as wlan0.

Set fixed IP address for the wireless network

This is done based on the 5.2 Static IP address - network configuration guide on arch linux wiki.

The steps below are described in section 5.2.2 Persistent configuration on boot using systemd to make the configuration permanent.

1) Create a configuration file for the systemd service, replace wlan0 with the proper network interface name if different:

Content of net-config-wlan0
2) Create a network start script: 
Content of
ip link set dev "$1" up
ip addr add ${address}/${netmask} broadcast ${broadcast} dev "$1"

[[ -z ${gateway} ]] || { 
  ip route add default via ${gateway}
3) Create a network stop script: 
Content of
ip addr flush dev "$1"
ip route flush dev "$1"
ip link set dev "$1" down

4) Make both scripts executable:
chmod +x /usr/local/bin/net-{up,down}.sh

5) Create a systemd service file for starting/stopping the WLAN0 network.

Content of network@.service
Description=Network connectivity (%i)

ExecStart=/usr/local/bin/ %i
ExecStop=/usr/local/bin/ %i

6) Enable and start the network.
systemctl enable network@wlan0
systemctl start network@wlan0

If you ping now on the PI to you should get a response.

DHCP/DNS Server on WLAN0

To be able to access the network from clients without fixed IP settings we need a dhcp server running on the PI.

dnsmasq is a lightweight tool that serves that functionality plus provides dns capability.

1) Install dnsmasq package with

pacman -S dnsmasq

2) do a backup of the dhcp config file with 

cp /etc/dnsmasq.conf /etc/dnsmasq.conf.backup

3) Edit the configuration file 


Content of dnsmasq.conf (changed lines only)

# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
# Or you can specify which interface _not_ to listen on
# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.

If you like to get for specific clients always the same IP adress you can mention this here. e.g.

# Always allocate the host with Ethernet address 11:22:33:44:55:66
# The IP address

4) change the hosts file to allow name resolution in the network.


Content of hosts file to do name resolution for the Rapberry Pi.
In my case i like to have is accessible with name "

# /etc/hosts: static lookup table for host names

#<ip-address>    <>    <hostname>    localhost.localdomain    localhost
::1        localhost.localdomain    localhost    flypi.flyingpi        flypi
# End of file
5) enable / start dhcp (and dns)
systemctl enable dnsmasq
systemctl start dnsmasq

Set up WLAN software AP 

Hostapd provides the functionality to act as software WLAN AccesPoint.
To support WPA2 encryption the wpa_supplicant package is need.

Further information can be found on Archlinux Wiki - Software Access Point.
1) install hostapd and wpa_supplicant

pacman -S hostapd
pacman -S wpa_supplicant
Important to know for the configuration is that the SSID/password needs to be exactly the same in hostapd.conf and wpa_supplicant.conf and password needs to be at minimum 8 characters.

2) Edit the hostapd config file


Content of hostapd.conf
 Adjust interface, ssid, channel, country_code and wpa_passphrase according your needs.



wpa_pairwise=TKIP CCMP

# some laptops will only connect if the mode is set to b

# required for full speed

3) Edit the wpa_supplicant config file

ssid needs to be the same than ssid , psk needs to be the same than wpa_passphrase in hostapd.conf.

Content of wpa_supplicant.conf


4) Create a systemd service file to start hostapd automatically

Content of hostapd.service
Description=Hostapd IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticat$

ExecStart=/usr/bin/hostapd /etc/hostapd/hostapd.conf -P /run/ -B


5) Enable and start hostapd with
systemctl enable hostapd.service
systemctl start hostapd.service 

Now you should be able to access the WLAN wlantest and connect to your PI on IP172.16.0.1

Have fun!

- dk7xe -