Raspbian findings so far

It’s been a couple weeks of playing with the Pi 2 and it’s defacto OS- raspbian.  My installation is based on the debian wheezy build which is also known as Debian 7.  I’m content for now, but would really like to find a RedHat based distribution that works as I’m much more familiar with that.  I tried Pidora but I couldn’t even get a boot screen with that image. I’m also looking into upgrading raspbian to Jessie (aka Debian 8).

 

Anyway- on to the findings.  So I had a TON of issues with something that really shouldn’t have been an issue.  I was trying to configure a static IP on my eth0 interface and for some ungodly reason it just wouldn’t take across reboots.  I finally wound up configuring the MAC address of the Pi’s NIC in my dhcp server and set the interface to DHCP.  It will always lease the same address this way but it’s a kludge and I’d like to get it working properly.  I did the same for the Ralink wifi usb adapter for the time being.  You’d think that the following config would git ‘r done but for some reason it didn’t:

 

/etc/network/interfaces:

auto lo
iface lo inet loopback

auto eth0
allow-hotplug eth0
iface eth0 inet static
 address 192.168.1.20
 netmask 255.255.255.0
 gateway 192.168.1.1

 

I don’t see any evidence that NetworkManager is installed in the Raspbian image I’m using so I don’t think it’s that.  If anyone has had issues like this- post a comment and let me know what you did to fix it.

 

The second thing I’ve been running into is also related to networking.  My Ralink adapter for some reason likes to disconnect every so often:

Jun 8 00:05:10 mypi kernel: [425582.545653] usb 1-1.4: USB disconnect, device number 6
Jun 8 00:05:11 mypi kernel: [425583.546048] usb 1-1.4: new high-speed USB device number 7 using dwc_otg
Jun 8 00:05:11 mypi kernel: [425583.663302] usb 1-1.4: New USB device found, idVendor=148f, idProduct=5370
Jun 8 00:05:11 mypi kernel: [425583.663320] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jun 8 00:05:11 mypi kernel: [425583.663332] usb 1-1.4: Product: 802.11 n WLAN
Jun 8 00:05:11 mypi kernel: [425583.663343] usb 1-1.4: Manufacturer: Ralink
Jun 8 00:05:11 mypi kernel: [425583.663354] usb 1-1.4: SerialNumber: 1.0
Jun 8 00:05:11 mypi kernel: [425583.756056] usb 1-1.4: reset high-speed USB device number 7 using dwc_otg

 

When it does this, it drops from the wifi network and doesn’t come back unless I unplug the adapter and plug it back in, or if I reboot the Pi.  To get around this, I’ve done a few things:

  • set wireless-power to off in /etc/network/interfaces
  • created a script that checks every minute to see if wlan0 has an IP address.  If not, it downs and ups the interface.

Here’s my current interfaces file:

auto lo
iface lo inet loopback

#auto eth0
#allow-hotplug eth0
#iface eth0 inet dhcp

auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa.conf
wireless-power off

 

Here’s the script I put into cron:

#!/bin/bash

datestamp=`/bin/date '+%D %T'`
result=`/sbin/ifconfig $1 | /bin/grep "inet addr:"`
logfile=/var/log/wifi/connection_status

if [ -z $1 ]
then
        echo "usage: $0 {interface}"
        exit
fi

if [ ! -z "$result" ]
then
        echo "=== [$datestamp] ===" >> $logfile
        echo "Found an IP on [$1].  No action taken." >> $logfile
        echo "===================================================================" >> $logfile
else
        echo "=== [$datestamp] ===" >> $logfile
        echo "No IP on interface [$1].  Restarting interface [$1]." >> $logfile
        echo >> $logfile
        echo "Stopping $1." >> $logfile
        /sbin/ifdown $1 &>> $logfile
        echo  >> $logfile
        echo "Starting $1." >> $logfile
        /sbin/ifup $1 &>> $logfile
        echo "===================================================================" >> $logfile
fi

 

And here’s the crontab entry I used (root crontab):

*/1 * * * * /usr/local/bin/check-wifi.sh wlan0

 

The script is a bit verbose but I used it to debug the connection so I want to know what’s going on. I’m hoping this will work cause I really like being able to stick this thing anywhere in range of the wifi signal where I can provide power.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s