Beaglebone: wireless access to the beaglebone

Obsolete Stuff Here

2/28/2016. More internet stuff

The first thing that comes up is needing to get to the internet from the BBK.  The HORNDIS driver does not work quite the same as it used to, although it is now somewhat working.  In order to get the BBK to talk to my mac over the usb interface, I have to reboot the mac with the BBK connected.  If I break the link, I cannot seem to get it back.

In order to get the BBK to connect to the internet, osx’s internet sharing feature must be used.  Alas, the new internet sharing on osx requires that the gateway for the BBK be 192.168.2.1.  Nothing else!

So, I set up internet sharing using eth0 on the BBK.

On the BBK … edit /etc/network/interfaces.  Add/uncomment the lines:

auto eth0

iface eth0 inet static

address 192.168.2.18

netmask 255.255.255.0

gateway 192.168.2.1

Restart the network with one of the commands:

ifdown eth0

ifup eth0

or

ifconfig eth0 down

ifconfig eth0 up

This will give you eth0 talking to 192.168.2.1 and answering via 192.168.2.18.

On osx, go to system preferences -> sharing and “share your connection from” (probably Wi-Fi) “to computers using” Ethernet.  Then click the “Internet Sharing” box on the left.

When you “ssh -Y -l root 192.168.2.18” onto the BBK from now on, you should be able to access the internet.

———

How to get the usb0 interface sharing?  Apparently there’s a way!

According to this blog, you can change the usb0 interface to 192.168.2.2 (instead of 192.168.7.2) and look for 192.168.2.1 (instead of 192.168.7.1) by modifying a couple of start up files.

/etc/network/interfaces

/opt/scripts/boot/am335x_evm.sh

/etc/udhcpd.conf

If you’re going to fool with these files, I strongly suggest you make sure you can get into your BBK without 192.168.7.2!  If that’s your only access, a typo or missed segment could brick your BBK.

Here’s what the internet suggests (I have not tried this yet):

Change /etc/network/interfaces:

iface usb0 inet static

    address 192.168.7.2

    netmask 255.255.255.0

    network 192.168.7.0

    gateway 192.168.7.1

 to:

iface usb0 inet static

    address 192.168.2.2

    netmask 255.255.255.0

    network 192.168.2.0

    gateway 192.168.2.1

 Change /etc/udhcpd.conf:

start      192.168.7.1

end        192.168.7.1

interface  usb0

max_leases 1

option subnet 255.255.255.252

To:

start      192.168.2.1

end        192.168.2.1

interface  usb0

max_leases 1

option subnet 255.255.255.252

Change /opt/scripts/boot/am335x_evm.sh:

if [ ! -f /etc/udhcpd.conf ] ; then

echo “start      192.168.7.1” > /etc/udhcpd.conf

echo “end        192.168.7.1” >> /etc/udhcpd.conf

echo “interface  usb0” >> /etc/udhcpd.conf

echo “max_leases 1” >> /etc/udhcpd.conf

echo “option subnet 255.255.255.252” >> /etc/udhcpd.conf

fi

/etc/init.d/udhcpd restart

/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252

/usr/sbin/udhcpd -S /etc/udhcpd.conf

To:

if [ ! -f /etc/udhcpd.conf ] ; then

echo “start      192.168.2.1” > /etc/udhcpd.conf

echo “end        192.168.2.1” >> /etc/udhcpd.conf

echo “interface  usb0” >> /etc/udhcpd.conf

echo “max_leases 1” >> /etc/udhcpd.conf

echo “option subnet 255.255.255.252” >> /etc/udhcpd.conf

fi

/etc/init.d/udhcpd restart

 /sbin/ifconfig usb0 192.168.2.2 netmask 255.255.255.252

/usr/sbin/udhcpd -S /etc/udhcpd.conf

If this is everywhere that these numbers are entered, you should be able to share the connection in the same way as the ethernet connection is shared above.  If not, then you likely will be locked out of your BBK until you set them back.  I have not tried this yet.

———–

On another issue, the boot up script … /opt/scripts/boot/am335x_evm.sh … shows some interesting behavior related to wlan0.  I suspect that wlan0 could be tweaked to use the same code and make it actually come up reliably on boot.

—— older text below here ——

I want my beaglebone robots to connect to the internet wirelessly, so that I don’t need any tethers to the robot.

Here’s how I (finally) did it.

I connected an ASUS USB-N10 dongle to the beaglebone’s usb port.  This dongle is quoted as being low power and compatible with the beaglebone linux.

I logged into the beaglebone using another interface (ssh -l root -Y 192.168.7.2 if the default usb interface is configured).  BTW: on osx, the horndis driver appears to still be out of commission with osx ‘el capitan’ so I had to use another link.

I edited /etc/network/interfaces (sudo gedit /etc/network/interfaces) and added the following lines:

iface wlan1 inet static

address 192.168.4.18

netmask 255.255.255.0

wpa-ssid “insert your wireless router’s ssid here”

wpa-psk “insert your wireless router’s passkey here”

A quick network restart (sudo service networking restart) and I was now able to login to my beaglebone at address 192.168.4.18 from any point in my home’s wan.

NOTE: my wireless wan is on the 192.168.4.x domain.  This was my choice.  Any domain will do.  If you should choose something else, then modify the static address in the above lines.

NOTE: I could have used the dhcp; however, I wouldn’t know which ip my beaglebone is chillaxing on.  So, I chose static.  My home’s dhcp serves up addresses starting with 100, and a couple of statics are locking down the lower addresses.  18 was free, so I took it.  There’s nothing magic about that address, though.

NOTE: wpa-ssid can be found from your ipad or other wireless device.  It’s the broadcast address of your wireless router.  Open the settings on your device, go to network setup and look for names.

NOTE: wpa-psk is the passkey for your wireless router.  It is usually written on the side of the device.  My at&t 7550 router has it listed as “wifi password” on the sticker.  This is NOT your beaglebone’s root password.

———-

The above section works because my wireless network is configured to pick up devices and forward traffic through the wired connection to the rest of the internet.

However, if what you are trying to accomplish is a direct wireless connection between the beaglebone and a specific computer, then some other method is necessary (called an ad hoc network).

Some commands for the beaglebone linux that are useful:

iwlist wlan1 scan

This allows the beaglebone to find those networks in its vicinity.  Assumes that the beaglebone’s wifi is wlan1.  It may be wlan0, wlan2, …

With my mac set up in “internet sharing mode,” here’s what the above command generates:

Cell 02 – Address: A8:86:DD:A8:DA:F3

ESSID:”Mothership”

Protocol:IEEE 802.11bgn

Mode:Master

Frequency:2.462 GHz (Channel 11)

Encryption key:on

Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s

24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s

12 Mb/s; 48 Mb/s

Extra:rsn_ie=30140100000fac040100000fac040100000fac020800

IE: IEEE 802.11i/WPA2 Version 1

Group Cipher : CCMP

Pairwise Ciphers (1) : CCMP

Authentication Suites (1) : PSK

Signal level=70/100

Note the mode.  This will not receive the beaglebone on an ad hoc communication.

If you go to the osx “create network” entry in the drop down from the wifi symbol on the tool bar, you can set up an ad hoc network on the mac.  Here’s the output from the iwlist command now:

Cell 01 – Address: 0A:94:6D:D1:54:B6

ESSID:”Mothership”

Protocol:IEEE 802.11bgn

  Mode:Ad-Hoc

Frequency:2.412 GHz (Channel 1)

Encryption key:off

Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s

24 Mb/s; 36 Mb/s; 54 Mb/s; 6 Mb/s; 9 Mb/s

12 Mb/s; 48 Mb/s

Signal level=100/100

I also chose to move to channel 1 from the default channel 11.

The above is nice info, but ultimately not useful.

Modify the /etc/network/interfaces file on the beaglebone to add the following entry:

iface wlan1 inet static

address 192.168.2.18
netmask 255.255.255.0
wireless-channel 1
wireless-essid Beaglebone
wireless-mode ad-hoc

Bring the interface up with the command “sudo ipup wlan1”

Check your config with “iwconfig” and with “sudo ip addr show.”

Go back to your osx device.  Under the System Preferences -> Wi-Fi, turn wifi off and back on.

Click on the “Advanced->TCP/IP” tab and make the IP address 192.168.2.1 and the netmask 255.255.255.0.

Click “OK” to save changes and return to the Wi-Fi setup.  On the “Network Name” drop down, you should “Beaglebone” under “Computer-to-computer” networks.  Select that item and you should see Wi-Fi go over to “Connected” and green.  Yahoo.  You’re networked to the beaglebone.

Pull up a terminal and “ping 192.168.2.18.”  You should get traffic back and forth.  If so, you’re done.

Now, “ssh -Y -l root 192.168.2.18” and enter the root credentials.  You should be logged into the beaglebone and can start driving your ‘bone remotely from your mac.

This will all be needed when using c-code from the mac/ipad and from the ‘bone.  Now, in the c-code, with a tcp/ip connection, you can use sockets, open, close, read, write to pass data from one computer to the ‘bone.  Telemetry, here we come!

——–

Here’s an article on debian ad hoc networks (https://wiki.debian.org/WiFi/AdHoc)

Here’s the article that finally got this working for me (http://spin.atomicobject.com/2013/04/22/raspberry-pi-wireless-communication/).  Granted, the connection was between osx and raspberry pi; but the debian worked just the same in the case of the beaglebone.

Posted in: Robotics

Comments are closed.