Tuesday, December 10, 2013

Beaglebone Black and Astrophotography: Phase 1: Configuring the BBB

Goals for Phase 1
Boot Linux on BBB.
Activate WiFi access.
Activate webcam.

Parts list for Phase 1
Beaglebone Black (BBB)
4-Port powered USB hub
USB WiFi adapter with Access Point capability
5V 2A PSU
Ethernet cable
USB webcam
HDMI to mini-HDMI cable (optional)
8GB+ microSD card

I purchased my Beaglebone Black version A3, PSU, and USB WiFi adapter from Adafruit, and they were quickly delivered.  The BBB comes with a USB to mini USB cable.  The USB hub, webcam (a Logitech C300), and microSD (32GB UHS-I Class 10) were ordered via Amazon.com.  I had an ethernet cable sitting around.

Useful online tutorials
The following are some resources that I found useful for setting up my BBB.
http://learn.adafruit.com/beaglebone
http://derekmolloy.ie/category/embedded-systems/beaglebone/
Plus others

Boot Linux on BBB
Technically, you can just power-up the BBB, and Linux will boot.  However, after a bit of playing, I found out that the Angstrom Linux distribution that was preinstalled on my BBB's eMMC memory was from 2012.  So, I wanted to get updated...
[edit 2013/12/12: due to size limitations of the eMMC memory, you will need to boot off the microSD and install your software there.  Follow these instructions for resizing your microSD boot partition]

I started by using Debian linux (3.2.51-1) via Virtualbox on a Windows 8 PC in order to control and program on my BBB.  You can look elsewhere for how to setup Virtualbox and install a version of Linux.  I was originally thinking of using a Raspberry Pi, and Raspbian is a derivative of Debain, hence the Linux "flavor" choice.  Ubuntu seems to be popular for BBB users, so the choice in *nix/*nux is up to you.  I switched to Ubuntu to make my life easier, but found it had connectivity problems with the usb-to-ethernet system, so I went back to Debian until I got ethernet running.

I suggest you follow some of the online tutorials for getting started, since there are plenty out there.  When you first connect your BBB to your computer via the USB cable, it will appear as a mass storage device.  There are Windows and OS X drivers on it.  I noticed that the Windows drivers are unsigned, so they will not load in Windows 8 without some tricks.  I didn't bother with that.  Instead I passed the BBB through to my Linux virtual machine (VM) in Virtualbox.  Then do the initial setup as suggested at beagle board.org/static/beaglebone/latest/README.htm

Another good site:
http://derekmolloy.ie/beaglebone/getting-started-usb-network-adapter-on-the-beaglebone/
BBB Angstrom flasher 2013.09.12.  http://downloads.angstrom-distribution.org/demo/beaglebone/

I fought with the Angstrom distribution for a while (and had a long blog post written) before I got frustrated enough with connmand and wifi network configuration to scrap it.  Install Ubuntu on your BBB instead and save some headaches.  You can probably save some headaches by not getting a RTL8192CU WiFi adapter, but that is a different story.  Many online tutorials use Ubuntu too.
http://elinux.org/Beagleboard:Ubuntu_On_BeagleBone_Black
I got a Ubuntu 13.10 Saucy build from Robert Nelson at http://rcn-ee.net/deb/flasher/
You WILL want to read the following page for flashing a new Linux distribution onto the BBB.
http://elinux.org/Beagleboard:Updating_The_Software
Then resize your microSD and use it as the boot device (the eMMC memory isn't enough for this project).

With Ubuntu installed, plug your BBB into your Linux computer (VM) again.  You will then be able to ssh into the BBB (ssh -l ubuntu 192.168.7.2 with password being temppwd.   Setup your usb-to-ethernet networking.  That being said, I hooked my ethernet cable up (since usb-to-ethernet was acting odd in Ubuntu) and waited for the BBB to show up on my network.  Then I ssh'd into it over eth0.

# sudo apt-get update
# sudo apt-get upgrade
# sudo apt-get install avahi-daemon

That last line will get Zeroconf installed so that we can access the BBB vi arm.local.  Of course, I changed the name of mine to astrobeagle in /etc/hostname and /etc/hosts.  Reboot.

Activate WiFi access
From what I have heard (November 2013), the Adafruit tutorial for getting WiFi working is not applicable to the BBB.  The dongle I purchased from them uses the RTL8192cu Chipset, and after a week's worth of compiling things on my own, here are the best instructions I have found on getting it to work:
http://wiesel.ece.utah.edu/redmine/projects/hacks/wiki/BeagleBone_Black_AP

My kernel is saucy 3.8.13-bone30, so I had to make adjustments as mentioned by Anh Long.  Additionally, for step 9 to compile the driver, I had to adjust the Makefile.  Having tried many approaches previously, I found some good info from Evan Hanau on fixes to the Makefile.  By default, the Makefile is setup to build for i386, so it needs to be switched to arm.

With wifi up and running, want to get hostapd running so that I can make the BBB into an access point.  Ahn's writeup is good.  After configuration and a reboot, I see my beaglebone as an access point with my iPhone!  Pointing Safari to http://192.168.4.1 (I used the suggested 4 subnet) I can see apache running.

Time to hook up a USB hub and get the webcam going...

Activate webcam
I chose the Logitech C300 webcam due to established support in Linux (link).  HD resolutions were not necessary for my purposes (I hope).  The shape and design of the C300 also lends itself to disassembly for eventually mounting on a guidescope.  [Edit: DO NOT get a Microsoft LifeCam Studio.  It has a bug that pull full bandwidth from the USB and will effectively disable your WiFi adapter on the hub.  Look at this list.]  Plug in the webcam and check to see if it is recognized:

# lsusb

Now, we need to get  a few things if you want to follow Derek Molloy's example vid
# apt-get install v4l-utils pkg-config libopencv-dev libv4l-dev uvccapture
OpenCV isn't necessary for my final project, only if you are wanting to do OpenCV stuff.  With that installed, you can run v4l2-ctl to get all sorts of information in the camera.  I found out that my autoexposure was turned on and creating trouble, so...

# v4l2-ctl --set-ctrl=exposure_auto_priority=0

You can use uvccapture to grab some still frames.  Since my webcam doesn't do h264, if you are following Derek's tutorial, I did the following since my output is in MJPEG format:

# ./capture -o > output.raw (then scp'd the output file to my Linux desktop for ffmpeg...)
# ffmpeg -f mjpeg -i output.raw tmp.mp4

Phase 2: Install astronomy software
for the next post...

No comments:

Post a Comment