Happy Thanksgiving 2014


turkey is good

Happy Thanksgiving!

I want to say Happy Thanksgiving to all my friends, family, readers and visitors.  I really enjoy having this blog and sharing what I have done and what I am planning to do.  I appreciate all the encouragement, feedback, and dialog that this forum has generated.

I hate apologizing for not blogging more regularly.  However, I feel like I should since I have had so many kind words about my articles on the BeagleBone Black (BBB) and my increasing interest in woodworking.  So, to all of you, thank you.

Over the past year, I have been as busy as ever and it is only just starting to calm down but as soon as I say that, I am sure that it will wind right back up again.  In October 2013, I was asked to assume the team lead and system engineering responsibilities for one of my company’s web sites.  We use Adobe CQ/AEM for our CMS solution, running on Red Hat Enterprise Linux.  When I was first asked to start building components for the CMS a few years ago, my experience centered around Microsoft technologies and this made for a “K-2”-like learning curve.  One of my decisions was to fully immerse myself and this is why I “burned the ship” by installing Linux on my workstation.  This forced me to figure out how to work out the mechanics in this new environment and it has been a fun, frustrating, exciting and very rewarding experience.

Without that, I would never have dove as deep with the BBB and plan to continue projects with it.

This year, my wife and I stubbled, quite literally, into a what may become a business endeavor.  While chatting with some neighbors on our community’s Facebook group, someone asked if anyone had or could make a Corn Hole set.  My wife said that I could build a set and then informed me.  By the way, I had never built a set before.  That was March and since then, I have built over 50 sets for friends, family, and neighbors.  It has been great for me because I had just finished building a work bench and was slowly working on some other projects but I really didn’t have any direction.  Building Corn Hole sets has really forced me to focus on the basics and the details of woodworking.  They are easy to build but take technique to build flat and straight, especially when building from box store lumber.  I have acquired good tools, experience, and confidence to begin building more complex projects.  I hope to share many of them with you.

I am what some would call a “changing imager.”  This is a type of person that can plan and start many projects but may take a while to finish.  I also have many different types of interests including audio engineering, guitar building, electronics, programming, general computers, and building and making things.  I try not to blog multi-part articles anymore because I may not finish them for a while or at all and I drives me crazy to get half-way through someone’s walk-through on something to find out that it was never finished.  Since I discovered Breaking Bad only on it’s final season, I waited until it was over before starting it on Netflix.  So, I just don’t want to do that to you.

If you have ideas for projects, please let me know.  I will try to share with you what I am doing on a more regular basis so you don’t feel like I have abandoned this blog.  To start off, I started listening to podcasts on the way to and from work.  Mostly woodworking but some guitar and generalized subjects.  Right now, my favorite is Fine Woodworking’s Shop Talk Live (iTunes & i-heart-radio).  It runs about an hour (the length of my commute) and the guys are funny, knowledgable, and down-to-earth.  It’s NOT a Festool commercial, so if you’re a woodworker, check it out.

I will probably put up some more articles on what I am up to so check back.  If you don’t hear from me, drop me a line.  I get distracted trying to keep my boys from burning down the house and keeping up with my Corn Hole orders but I will try to respond it a timely fashion.

Thanks for listening.  I look forward to getting back here.

PS.  Here is a couple if pictures of what I’ve been up to.  Building Corn Hole boards and finally getting my Dust Deputy cyclone working.

This slideshow requires JavaScript.

Advertisements

Linux : Mounting A Remote Network Folder Locally


SSHFS and FUSE To Mount Remote Network Resources

UPDATE (2014.04.09): I may have been premature with the startup script mentioned below.  This doesn’t seem to work.  I am assuming the failure is because my profile isn’t loaded at the time the script is run or my account isn’t allowed to to run scripts using @reboot in a cron config.  Whatever the case, I have found a configuration that works.  I put the startup script call in my ~/.bashrc file and it works as intended.  Here’s the line I added after my environmental declarations (near the bottom):

~/startup.sh

Everything else worked pretty well.  I am getting the following message when I open a terminal and I will need to do more research as to how to resolve this:

fuse: mountpoint is not empty
fuse: if you are sure this is safe, use the 'nonempty' mount option

</UPDATE> At work, I have a network homedrive for my Linux systems that I only have access network-drive-connectedto once logged into one of my systems.  Once I am in one system, it’s easy for me to move scripts and files around but I have always struggled with the overt disconnection between my local workstation andy my network.  My requirements were straightforward: Easy to configure locally, no network/remote configuration required, maintains solid security, and scriptable. Today, I made a push to get some level of resolution to this issue and I was finally successful using sshfs and FUSE.  While not strictly work related, this will be a huge improvement for my BeagleBone Black projects as well.  It was much easier than I thought it would be.  Let’s say I want to mount the remote home drive from my BeagleBone (hostname: ‘trisket’, user: ‘dave’). NOTE: These instructions assume Ubuntu, but I’m sure the process is the same for other distros

1. Install (if it’s not already installed) ‘sshfs’ on my client

sudo apt-get install sshfs

2. Verify that my user account is in the fuse group.

groups dave

which returns:

dave adm dialout cdrom sudo dip plugdev fuse lpadmin sambashare

If not, add user:

sudo adduser dave fuse

3.  Verify ownership of /dev/fuse and make sure it’s root:fuse.  This is important!

ls -la /dev/fuse

yielded:

crw-rw---- 1 root root 10, 229 Apr  3 09:12 /dev/fuse

I fixed this with:

sudo chown root:fuse /dev/fuse

4.  Create a mount point:  (I wanted this in my home folder)

mkdir ~/bbb

5: Mount the remote resource:  sshfs remoteuser@remotehost:/remote/resource /local/resource

sshfs dave@trisket:/home/dave ~/bbb

Success!  Now I have the remote BBB home folder mounted on my local workstation. This worked amazingly well and it was very easy to to add others.  In retrospect, I think I will centralize the mount points that I bind to much like the mount folder.  I am keeping these separate from /media or /mnt for my own sanity. Finally, a quick word on persistence.  After I mounted the drive, I logged out and back in and the mount was still there.  However, after a reboot, it disappeared.  So, as I have mentioned in previous posts for my BeagleBone Black initial configuration, I created a startup script that runs on reboot.  There’s lots of ways to do this but this is my method which helps me keep everything organized and within scope. First I added the mount line to my ~/startup.sh script:

#! /bin/bash

~/getIP.py
~/updateGateway.sh
sshfs dave@trisket:/home/dave ~/bbb

Because I have this already to run on reboot/startup, I don’t have to do anything else.  However, if you are setting this up for the first time, you can have the cron service run this file for you.  I have other posts that go into more detail but you can simply add one entry in your crontab to get this done:

crontab -e

then add the following line:

@reboot /home/dave/startup.sh

Just make sure you change the path to where your startup.sh script is saved.  Also, don’t forget to make your startup script executable:

chmod +x startup.sh

Overall, this was a very easy feature add to my local client configuration and the value is huge, especially at work.  I hope this helps someone and if you have any questions, feel free to post comments.

Projects Update: It’s been crazy


CrazyWell, it’s been a rather crazy and chaotic few weeks.

First, I want to say thank you to everyone that has visited my blog.  I don’t make money from this.  I do it to share the knowledge that I accumulate.  For the 2012 calendar year, I had a total of 333 hits… for the entire year!  I must say that wasn’t really trying for an audience.  Rather, I started blogging just to document some things that I wanted maintain in a way that I could share with others.  However, in 2013, I actually gathered somewhat of a following and logged over 6000 hits, the lion share of those came after August.  It is humbling and an honor to have not only so many visitors but regulars that come back and reference my posts.  Thank you.

Now, I want to quickly let you know what I am working on and some of the projects I will be documenting in the near future.

  • Beaglebone Black Santa-CAM (after-magic report) – I had some issues with this but things worked out in the end
  • Beaglebone Black Santa-CAM upgrade – adding motion detection on it so it will fire when there’s something happening
  • Hand-made Wood Bench Plane – I will be finishing that up soon
  • Bunk Bed Underbed Storage (IKEA Kura bunk bed hack)
  • SteamOS beta Virtual Machine Install (on Oracle Virtual Box – this is going to be a hoot!)

So, check back often because the updates will be coming fast and furious!

-Dave

Simple Santa-Cam Hack with BeagleBone Black


Merry Christmas and Happy Holidays to all! I hope this post finds you in a cheerful and festive way.

chippy

Chippy, the Christmas Elf on the Shelf

This past month, my son and I have been thinking about a way to get a picture of the elusive Santa Claus!  We got the Idea from a Make! Weekend Project post. We’ve had to be extra careful because Santa has his embedded helper (spy), Chippy,  watching our every move.  Since Chippy has gone back to the North Pole to help Santa with his last minute preparations, Xander and I found our opportunity get this next project done.  It is a simple frame capture using some inexpensive items we already had, so this didn’t cost us anything.  However, if you were starting from scratch, I estimate this project would cost between $90.00 – $120.00.

Operation Polar Bear

First, here’s a list of the items we used to pull this off:

  • BeagleBone Black
  • Logitech HD C525 Webcam
  • 4-port USB Hub (as small as you can get it – I had to take the cover off mine)
  • 8GB thumb drive (for storing images)
  • Radio Shack Project Box
  • 5V Power Supply
  • Drill and various drill bits

First, I put everything together and proto-typed the build.  Once I verified everything was working as I had intended, I reached for the Project box.

Polarcam – Camera lid

I drilled one hole in the center of the lid for the camera and two holes on left-hand side of the box for power and networking (left or right makes no difference but you will want to position the BBB length-wise to make room for the USB hookup).  I turns out that my double-sided tape was used by Chippy (do you think he knows something?) so I had to improvise and use a combination of medical and painters tape to secure everything to my box.

Temp Mounting Solution

Temp Mounting Solution

Since we have very little time and this is a temporary installation, I was not very tidy with the side hole.  NOTE:  Be tidy with the side holes and give yourself plenty of space.  You will thank me later.

I then mounted the BBB, the USB hub, and the thumb drive into the box.  After one last check, I sealed it up and did a test. (See my post on mounting a USB drive HERE)

USB Hub with Camera and Thumb Drive attached

USB Hub with Camera and Thumb Drive attached

Once everything was working, it was time to fine tune the system.  Here’s what I did to get the system running:

I am running Ubuntu 12.10 on my BeagleBone Black.  I have mounted a 16GB thumb drive to it using my USB passive hub to “/media“.  I created the folder structure under media to hold my images “/media/capture/polar-bear”.

Next I installed fswebcam.  I based my fswebcam build off a blog post HERE:

apt-get install fswebcam

To make this process work (time-lapse style), I created a configuration file and saved it in my home folder, called “polarcam.conf“, which I will explain:

device /dev/video0
input 0
loop 2
skip 10
#background
resolution 640x480
set brightness=60%
set contrast=13%
top-banner
font /usr/share/fonts/truetype/msttcorefonts/arial.ttf
title "Santa-CAM"
timestamp "%m-%d-%Y %H:%M:%S (%Z)"
jpeg 95
save /media/capture/polar-bear/polarcam-%Y%m%d-%H:%M:%S.jpg
palette MJPEG

Device: this is your webcam.  In most instances, it will be /dev/video0 unless you have other video sources plugged in.

Loop: this is the delay between frames, in seconds.  Since I figured Santa was a busy guy and would be trying to get in and out rather quickly, I set this for 2 seconds.

Skip: this is the number of frames to skip at startup.  Most camera have a short warm-up period where colors and brightness are not exact.  I set mine for 10 seconds but you can adjust for your particular device.

Background: runs the app in quiet mode if you are using it interactively.  I leave this commented out until I am ready to put it into “production”

Resolution:  This is the video resolution.  A smaller image size saves space and bigger has better image quality.  Based on your needs, and storage, you will be able to modify and adjust accordingly.

Top-banner:  This puts a banner at the top where you can put the name of the camera and a time stamp.  I haven’t played around with this but I believe you can put this at the bottom too.

Title:  Whatever you want to call this camera.  It will be superimposed in the banner on every frame.

Timestamp:  Puts the date and time on each image as it was taken.  This can be modified.

Save:  This is the path to where I want to save my images.

I really didn’t mess with the other parameters but you can get the details on all the available parameters and add them to your config by using the “fswebcam –help” command.

To test this, I simply entered the following:

sudo fswebcam -c <path-to-config-file>/fswebcam.conf

If the background parameter is commented, then the output should look something like this:

dfrey@ubuntu-armhf:~/fswebcam$ sudo fswebcam -c polarcam.conf 

>>> Next image due: 2013-12-24 09:59:52 (EST)
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
--- Capturing frame...
Skipping 10 frames...
Capturing 1 frames...
Corrupt JPEG data: 1 extraneous bytes before marker 0xd3
Captured 11 frames in 0.34 seconds. (32 fps)
--- Processing captured image...
Putting banner at the top.
Setting font to /usr/share/fonts/truetype/msttcorefonts/arial.ttf.
Setting title "Santa-CAM".
Setting timestamp "%m-%d-%Y %H:%M:%S (%Z)".
Setting output format to JPEG, quality 95
Writing JPEG image to '/media/capture/polar-bear/polarcam-20131224-09:59:52.jpg'.
>>> Next image due: 2013-12-24 09:59:54 (EST)
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
--- Capturing frame...
Skipping 10 frames...
Capturing 1 frames...
Corrupt JPEG data: 1 extraneous bytes before marker 0xd1
Captured 11 frames in 0.34 seconds. (32 fps)
--- Processing captured image...
Putting banner at the top.
Setting font to /usr/share/fonts/truetype/msttcorefonts/arial.ttf.
Setting title "Santa-CAM".
Setting timestamp "%m-%d-%Y %H:%M:%S (%Z)".
Setting output format to JPEG, quality 95
Writing JPEG image to '/media/capture/polar-bear/polarcam-20131224-09:59:54.jpg'.
>>> Next image due: 2013-12-24 09:59:56 (EST)

… and so on until you stop it (CTRL-C).  I noticed that there were a couple error messages regarding corrupt images but when I looked back at them, they looked ok, so I disregarded them.

If the “background” parameter is uncommented, you will see nothing and the app will run until the cows come home (translation: until you run out of storage space or turn off the BBB).  However, you can shut it off using this command:

sudo pkill fswebcam

Automation

Now that I have the app and hardware to get the job done, I have to make a decision as to how I want to start and stop the application.  I tried putting the start command in my .bashrc file and it worked but it just runs forever and that’s just not enough control for me.  After talking with Xander, we decided that we needed to limit the amount of time the camera ran so we could get as many images as possible.  We decided that between 11:30pm and 1:00AM would be fine b/c Santa has historically made his rounds in our town by 1:00AM (based on NOAA, NASA and NORAD data).  I elected to start and stop the process with a cron job (pronounced: CRAN JAB).

Here’s my script for root:

sudo crontab -e -l root

@reboot /opt/startup.sh

00 */12 * * * ntpdate -b -s -u pool.ntp.org
30 23 * * * fswebcam -c /home/dfrey/fswebcam/polarcam.conf
00 01 * * * pkill fswebcam

The last two lines are where the magic happen.  At 11:30PM, the fswebcam process will start, using my polarcam config file.  This will run continuously until 1:00AM, where the process is killed.

Last night, I tested this a couple times.  I did have some trouble with it not actually running but I think that this was because I didn’t give the BBB enough time to boot up after moving it to the target location.  However, my final test was successful and I was able to capture 30 minutes of images @ 1 per 2 second intervals.  Something else to note is that this camera has an IR filter on it, so it cannot use IR LEDs to illuminate dark rooms.  I will have to insure that the room has adequate lighting for our “Polar Bear.”  I will be upgrading this project to include and IR-ready camera and a PIR motion sensor.

Well, today is the big day.  After 46 years of trying to catch that Jolly Ol’ Elf in the act, I think I finally have a solution.  Check back in a couple days to see Santa in Action!

Thanks for stopping by.  Merry Christmas and a Happy New Year to all!

Ubuntu 13.10 – Saucy Salamander Upgrade


saucyLast week, Ubuntu started pestering me about upgrading from 13.04 to 13.10.  While I should have know better, I elected to go ahead and perform the upgrade.  Not that it’s out of the question for me to run on the bloody, razor’s edge, I just made a couple errors in judgement that cost me a few hours of shop time.

My first mistake was not having a backup.  I use Ubuntu One and Dropbox to store off my important data so if the OS tanks, oh well.  It would be a pain in the ass, but I could get through it.  What I didn’t expect was that this would actually happen since the upgrade from 12.04 to 13.04 was flawless.  So, no system-wide, disaster recovery, monkeys ARE flying out of your butt backups.

The second error was basing this upgrade success on the last upgrade.  While it’s only been a few months, a secret squirrel is capable of jacking up a build within one cycle.  I’m a software engineer.  I know these things.  Hell, I’ve DONE these things.  Bah… what could go wrong, aye?

So, I started out getting the notice to upgrade which I eagerly confirmed.  I got the normal, mentions about breaking your stuff, back up your stuff, the moon is made of cheese disclaimers.  Blah…. waving them off with a deft click of the mouse, I continued into Saucy Nerdvana…

Just as a matter of conversion, when an upgrade notice tells you NOT to turn off your machine, they mean it.  No foolin, here.  It’s going to cause problems.  The moon will become a ball of Nachos!

About half way through the multi-hour upgrade, my machine started twitching.  Error in Judgement #3.  I should have found another machine to work on while the upgrade finished.  But I was being a little lazy and about to be paid for sloth.  The OS suddenly twitched, pitched, then switched.  Finally it locked up then shut off.  Technically, I did not turn off the power but I probably pissed it off somehow.

I attempted to boot it back up and got to my Grub menu but not much further.  The boot process ended with a black screen and a fully functional mouse.  This would have been cool in 1972 but it just sucked for 2013.  I tried some vain attempts at repair but nothing worked.  It was dead, Jim.

My hope was that I could install a fresh copy of 13.10 on top and everything would be fine.  So I downloaded the latest version and burned it to a DVD.  I then booted off it and started the install process.  I was warned that all my programs would be going to heaven by everything under my home directory would be fine.  So, when prompted, I put in my username and password, then sent the install off to do it’s thing.

After a while, it finished and I rebooted.  I added my username and password into the login form and…. nothing… Whaaaa?

It turns out that Ubuntu assigned a new ID to my user account.  So, even though the username and password were the same, I was not allowed access.  Luckily, I was able to switch into the terminal (CTRL + ALT + F6).  I was able to log in here and then via sudo, chown my home directory to my new user account.

Then I spent about 4 hours reinstalling the apps that I really, really needed.  Had I not put in my actual username and password, I suspect that my creds would still have worked without issue (since I was able to log in with my secret squirrel account).

So, in the end, I got to keep all my important stuff and do a little Fall cleaning of crap that has been accumulating.  But it should have been easier that that.  No fault of Ubuntu’s.  I simply got lazy and didn’t follow my own rules.

So, now I have had my 5-year computer epic fail moment, which usually gets me back on the straight and narrow.  I’ll probably be waiting for v14.10 before I upgrade again, staying on version behind, like usual and running backups like I should.

But then again, where would the fun be in that…

Beaglebone Black and Ubuntu – Copying the OS Image to the SD Card from Linux


beagleAbout a month ago (maybe longer), I started my Beaglebone Black saga and in one of my first posts, I recall mentioning that I was unable to copy the OS image to the SD Card in Linux.  My process was to format the card, then boot into Windows and use ImageWriter for Windows to copy the image to the card.  Then move back over to Linux to carry on.  Yesterday, while I was waiting for FFMPEG to compile (foreshadowing), I was be-bopping around on adafruit.com’s web site and read a paragraph about the Mac process for copying the image to the sdcard.  I had previously skipped that since I wasn’t using a Mac.

So, after some careful experimentation, I was able to get the copy to work on Ubuntu.  Here’s how I did it:

First, check to see what the device designation is:

sudo fdisk -l

for me it was /dev/mmcblk0

Next, for convenience, I changed directories to my Downloads folder where I unpacked the gzip’d version of my OS image.

Finally, I entered in the following command:

Before doing this, be aware that this command, if not carefully used, could quickly and easily destroy your host system.  Just pretend that you are on the ledge of a very, very tall building without a railing.  Scary?  You bit it is!

sudo dd if=ubuntu-raring-13.04-armhf-3.8.13-bone20.img of=/dev/mmcblk0

The article included an additional parameter, “bs=1m” but Ubuntu did not like it so I took it out.  I can only assume it is a Mac-related thing.

Anyway, after entering this command, I waited about 20-30 minutes.  When the prompt came back, I pulled out the card, slipped it into my BBB and viola… A new, sexy install of Ubuntu was on my card, waiting for glorious projects.

Here’s the original article (the code is near the bottom):

http://learn.adafruit.com/beaglebone-black-installing-operating-systems/mac-os-x

PS.  Yes, Be-bopping is an industry term.  Don’t believe me?  Look it up…

Beaglebone Black : Get More Space From Your SD Card


sandisk-micro-8While researching for my post, “Backing up your Beaglebone Black“, I came across an article that demonstrated how to expand the linux partition from the standard image size.  I use an 8GB card and after flashing my sd card with the Ubuntu image, I had roughly 4GB of unused space.  Since space is at a premium, I have added external USB drives to help with that but leaving 4GB on the table is just silly.  So I decided to fix that today.

Even though I’m doing this on an Ubuntu instance, this should work for Angstrom instances as well.  However, be forewarned that this is potentially dangerous for your file system.  Make backups, double-check your work, and test this out on an install you can afford to lose before doing it on one you can’t.  Warning over.  Let’s get back to throwing caution to the wind.

First, let’s take a look at what we’re working with.  As root, run:

fdisk -l

This will spit out a list of all the partitions on your BBB.  The one we are concerned with today is mmcblk0.

Now, using the fdisk utility, we can resize the card while in the BBB.  We’re going to delete the existing partition, then create a new one, expanding its size and then wrap it all up with a bow on top.

Let’s start with:

fdisk /dev/mmcblk0

You will get a prompt:

Command (m for help):

If you’re curious, enter ‘m‘.  You should be safe here, just don’t enter ‘w‘ which is write! If you’re unsure at any time, you can enter ‘q‘ to bail without committing.

Here’s the sequence to resize the card:

root@ubuntu-armhf:~# fdisk /dev/mmcblk0

Command (m for help): d
Partition number (1-4): 2

Command (m for help): n
Partition type:
 p primary (1 primary, 0 extended, 3 free)
 e extended
Select (default p): p
Partition number (1-4, default 2): 2
First sector (4096-15523839, default 4096): <enter>
Using default value 4096
Last sector, +sectors or +size{K,M,G} (4096-15523839, 
default 15523839): <enter>
Using default value 15523839
Command (m for help): w

The partition table has been altered!
Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 
Device or resource busy. The kernel still uses the old table. 
The new table will be used at the next reboot or after you run 
partprobe(8) or kpartx(8)
Syncing disks.

root@ubuntu-armhf:~#

Now, since the partition is currently in use, we won’t see any change until we reboot. Let’s do that now:

shutdown -r now

When the BBB comes back, you will have a 4GB partition in an 8GB partition.  We can fix that with a utility called resize2fs.  Here’s how to use it.  As root run this command:

resize2fs /dev/mmcblkp2

When this command completes, reboot again and then run ‘df -h‘.  Here’s what mine looks like:

dfrey@ubuntu-armhf:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mmcblk0p2 7.3G 1.4G 5.6G 20% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
devtmpfs 248M 4.0K 248M 1% /dev
none 50M 244K 50M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 248M 0 248M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mmcblk0p1 1004K 472K 532K 48% /boot/uboot

Personally, I think this is a better solution than the USB drive but the USB drive works for backups and supporting content like MP3s, videos etc to host on my WordPress site. Space is still at a premium but at least now I have a little more breathing room.

http://www.gigamegablog.com/2012/09/26/beaglebone-101-linux-tricks-for-backing-up-and-resizing-your-microsd-card/