Monday, November 24, 2014

Cree Light Bulbs - A company that stands behind their product


About 6 months ago I replaced all the light bulbs in our house with Cree LED light bulbs.  This is something I've wanted to do for a long time, but I was waiting for the technology to improve, and for the price to come down.  I saw several reviews online of the newer Cree LED light bulbs and was impressed with them from a technological standpoint.  I also like the "color" of the light bulbs, they are very close to incandescent bulbs, not the blue-tint often found in CFL and many LEDs.  They are also one of the most energy efficient bulbs at less than 10W for a 60W equivalent.  And lastly, the price is under $10 a bulb at Home Depot.

After replacing all the bulbs in my house, the bulbs worked great and looked great.  However, a few weeks ago one of the bulbs started to flicker on and off.  Whereas these bulbs have a 10 year warranty, I didn't keep the receipt because they were working great for months so assumed I didn't need them anymore.  So technically that was my fault and I should have to buy a new bulb.

I decided to call Cree sales and support and speak to them.  The nice representative said they would ship out a replacement bulb at no cost to me.  I didn't have to send the defective bulb back, provide proof of purchase, etc.  I was very impressed with this level of support.  They clearly stand behind their products.  If you are looking to replace some or all of the light bulbs in your house with LED bulbs, I highly encourage you to look at Cree (no pun intended).  They have an awesome product with great support!

Sunday, November 23, 2014

Raspberry Pi Media Center

Recently I created a Raspberry Pi DVR to record over-the-air TV.  I enjoyed working with the Pi so much that I wanted to do a second project and create a Raspberry Pi media center, more commonly called a Home theater PC (HTPC).  On my previous project I looked at many of the Linux distros available for the Pi, so this project was much easier.  It was merely a matter of putting together everything I learned from the first project.


Hardware
The hardware for this project was very similar to the first project.  I used another Raspberry Pi model B+, the same 16GB Samsung EVO micro SD card, the same 2 amp power supply, the same Rosewill RNX-N180UBE wireless network adapter, the same copper heat sinks, and the same case off etsy.  I felt the last hardware worked great, so I wanted to duplicate it.  The only new hardware I added was this wireless keyboard and trackpad to be able to control the media center (more on that later).


Software
Since this will be a media center I will be running XBMC, which basically means Raspbmc, OpenElec, or Xbian.  I previously tried all three distros.  I felt that Raspbmc was the oldest, slowest, and least desirable.  I really wanted to use Xbian, but it had problems for me (mainly the network adapter did not have drivers).  So I decided to use OpenElec.  Which is not so bad.  OpenElec is the smallest image of the 3 - I guess you could call it lean and mean.  It is also the most actively developed, which means it will probably run the best with the fewest issues.  As of now the latest stable image of OpenElec is 4.2.1, so that is what I used.

Installation is straight forward and simple.  Use Win32 Disk Imager to copy the image onto your SC card, boot the Pi, and follow the onscreen wizards to configure wireless network access.  Some more settings you might want to change in OpenElec are:
  1. The system name, so you can remotely access the machine via SSH.
  2. Enable Samba, to make it easier to access the machine by name instead of just IP address.
  3. Set one or more time servers so it has the correct time.  I used pool.ntp.org and time.windows.com.
  4. Set your timezone, also required to have the correct time.
In addition to these basic settings, there are some more advanced settings you might want to make:
  1. Under video playback, I set "adjust display refresh rate to match video" to always.  This should make video playback smoother.
  2. Disable any unused services, like Avahi (zeroconf) and Bluetooth.
  3. Disable control of XBMC over HTTP port 80, unless you want to use this feature.
  4. Enable overclocking.  I went for a more aggressive 900MHz CPU, 333 MHz GPU, and 450 MHz RAM.  As for temperatures.  At idle the Pi is 104° F, and playing a video it goes up to 111° F.  I know from previous tests the heatsinks reduce the temperature about 2° F.
  5. I personally set up a cron job to reboot the Pi every morning at 5 AM.  I figure I am asleep at that hour, so why not have it reboot itself to ensure any memory leaks do not get too large.  To create a cron job to do this you need to SSH into the machine.  Then type the command "crontab -e"  Add the line "0 5 * * * /sbin/shutdown -r now" and save the file.


MPEG2 License
The Raspberry Pi foundation sells a license key to enable MPEG2 hardware decoding for a small fee.  Here in the US, broadcast TV uses MPEG2 encoding.  Also, DVDs are encoded using MPEG2.  But the question is, do you need to buy this license?  Can the Pi still decode MPEG2 without the hardware encoder?  Can you overclock the Pi to better decode using software?  Well the answer is, you MUST buy this license.  Without the license, OpenElec will not even attempt to decode the video portion of an MPEG2 video.  The audio will play, but no video.  However, with the hardware license the Pi can play full HD MPEG2 videos with no slow down.  So if you plan to watch any MPEG2 content, you will need to buy the license.  It costs less than $5, so just go for it.


Remote Control
The remote control I purchased to control the media center was a mixed purchase.  One the one hand it works great.  Just plug the RF dongle into the Pi and the keyboard and mouse worked without any additional config.  I also love that the remote is RF wireless and not line-of-sight IR like all other remotes.  The downside is it's not the best as a media center remote.  First off, the touchpad is almost unusable.  Second, it lacks some common buttons that would be helpful - mainly Page Up and Page Down which make navigating XBMC easier, but also dedicated stop, play and pause buttons.

I was researching a replacement remote when I discovered something cool!  HDMI has something called Consumer Electronics Control (CEC).  This is basically a protocol that allows two devices connected via HDMI to talk to each other.  The Raspberry Pi running OpenElec supports CEC.  And it turns out my TV does to, although it was disabled by default.  When I enabled it CEC on my TV suddenly I could control XBMC using my standard TV remote control.  The buttons that work include up, down, left, right, enter, and escape for navigation as well as play, pause, stop, forward, and reverse.  So now with one remote I can control the TV and all aspects of XBMC.  I still have the other remote in the event I need a full keyboard or mouse, but CEC is definitely the way to go!


Results
I am very pleased with the results.  The Raspberry Pi makes a great low-cost low-power media center.  The ironic thing is, I connected this to a TV that is already a "smart" TV.  My experience is "smart" TVs are not that great.  Once you have used something like XBMC and see what a real media center could be like you won't go back to a "smart" TV.  The plug-ins available for XBMC make it a great media center.

Thursday, October 30, 2014

Nerdy Christmas Gift

Continuing the theme from the last post, here is a nerdy Christmas gift my awesome wife got me several years ago.  A set of drinking glasses etched with the writing "#include <milk.h>"  If this means nothing to you, then you can read this and this.


And yes, my favorite beverage is milk!

(Sorry, because of the curvature of the glass I can't get a single picture showing the whole thing)

Coolest Birthday Gift

Earlier this week was my birthday, and my wife got me the coolest gift a nerd could ask for.  A Lego Nintendo Entertainment System (NES).  This is not an official set, but comes from the creative mind of Chris McVeigh.  As someone who grew up in the '80s with Legos and video games, this was the perfect gift that combines those two.









Thursday, October 23, 2014

Raspberry Pi DVR - Addendum

I recently completed my Raspberry Pi DVR and put it into regular use.  But I quickly realized something was wrong.  Some recordings would work, but most recordings would fail 10, 15, 20 minutes in.  Every time it failed I noticed the same thing, if I SSH into the Pi and looked at the running processes, tvheadend was no longer running.  The mere fact that I can SSH in to the Pi means that the Pi itself and Linux were still running.  So what is happening, is tvheadend crashing?

The Problem
I started with the assumption that tvheadend was crashing, after all that seems the most logical explanation.  But where do I go from there?  I researched Linux logging and diagnostics to see if the system recorded more info about this problem.  Eventually I stumbled across /var/log/kern.log which is the log file for the Linux kernel.  Every time there was a failed recording, the following was logged:
Oct 20 20:10:00 garagepi kernel: [79819.240765] Out of memory: Kill process 2314 (tvheadend) score 922 or sacrifice child
Oct 20 20:10:00 garagepi kernel: [79819.240785] Killed process 2314 (tvheadend) total-vm:607540kB, anon-rss:404384kB, file-rss:384kB

Aha!  So the problem here is not that tvheadend is crashing, the problem is Linux ran out of memory so to keep the system up and running, it killed the process using the most RAM which was tvheadend.

Because the Raspberry Pi only has a paltry 512MB of RAM, tvheadend is able to consume that and more resulting in this problem.  But if we dig deeper, what is going on here?  Does tvheadend have poor memory management?  Does tvheadend have memory leaks?  Is the task of recording live TV just too much for the limited resources of Raspberry Pi?  Or is there something else going on here?  I think the answer is mostly in the "something else going on here" category.

Let us start off by looking at what tvheadend is doing.  Basically all it is doing is shuttling data from one pipe to another.  The "input" pipe is the digital TV stream coming in from the TV tuner.  For ATSC TV, this amounts to approximately 5GB of data per hour.  That data is then written (unmodified) to the "output" file.  In my setup, the output file is located on my NAS box, so the data must be transmitted over wifi to get there.  And therein lies the problem.  What if the Raspberry Pi cannot transmit that 5GB/hour of data over wifi fast enough?  Linux, like all modern operating systems, would allocate more buffers to hold that data until such time that it is written over wifi.  This means if wifi is too slow, tvheadend will continue to consume more and more system memory in the form of output buffers until such time as Linux steps in and shuts it down.


The Solution
Now that we know the problem, what can we do about it?  The short answer is, we need to improve the memory "situation" of the Raspberry Pi.  For this I made 3 major changes.

  1. The Raspberry Pi has 512MB of RAM, which is split between both the CPU and GPU.  By default the GPU takes 64MB of RAM.  Since this is a headless unit in my garage, let us change that so the GPU gets the bare minimum.  Editing the config.txt file, set "gpu_mem_512=16"  This gives 16MB to the GPU which is the minimum.  This frees up 48MB of RAM for the CPU.  One downside is the GPU requires more memory than 16 for HDMI output.  I have read that either 24 or 32 is the minimum required for HDMI output.  So if you want HDMI output then set this value accordingly.  Either way, this setting is the single largest way to free up memory.  No other step will come close to the 48MB this frees up.
  2. Second step is to stop any unnecessary background processes.  I am no Linux expert, so it was hard for me to know what to stop and how to stop it.  But doing some research, everyone suggests turning off the getty processes.  To do this edit the file /etc/inittab.  Scroll down and look for the "getty" lines.  Disable the getty lines by placing a '#' in front of that line.  Reboot and they are not disabled.
  3. The final step is to do anything possible to improve wifi speeds.  Faster wifi means fewer buffers.  On Raspbian there are at least 2 ways to check your wifi connection details.  The first is "iwconfig wlan0" and the second is "cat /proc/net/wireless"  Both show two numbers, the link quality and signal level - both measured 0 to 100.  Both numbers are important.  What you want to do is adjust the position of your wifi antenna to increase these numbers.  My starting signal level was low 50s, after adjusting the antenna I was able to reach the high 80s.  Just that little bit made a huge difference!  Timing the copy of a large file across wifi, with signal in the 50s it took 1 minute and 29 seconds.  With signal in the 80s that dropped to 4 seconds!  So without a doubt, wifi antenna placement is critical.  Before you start fine tuning your wifi, run the command "watch -n 1 cat /proc/net/wireless"  This will display the current wifi settings updated once a second.  This makes it easy to see signal levels as you move the antenna.



Conclusions
If you wish to undertake a project like this and turn your Raspberry Pi into a DVR, there are several things that I consider crucial to your success.

First, make the above changes to give the minimum memory to the GPU and shutdown any unnecessary processes.

Second, if at all possible, use the ethernet jack instead of wifi.  Wired is always going to be faster and more reliable.  So only use wifi if you have no other option.

Third, if you do use wifi be sure to turn your wifi for maximum signal strength and speed.  Consider one of those homemade wifi antenna reflectors (plans available on the Internet) to improve wifi signal.

Fourth, with wifi optimized if you still run into problems, consider recording the video locally.  You can record the video directly to the SD card or onto a USB thumb drive or external hard drive plugged into the USB port.  Whereas it is not ideal to record large files directly to flash memory, you may have no choice.  After recording you can always copy the file over wifi during idle time when it is no longer a time sensitive process.

Fifth, consider frequent reboots.  Linux is supposed to be stable over the long run, but this does not mean all daemons (like tvheadend) are.  I think I am going to set up a cron job to reboot the Raspberry Pi every night.  After all, it is not doing anything else at 3 in the morning, so why not reboot and help tvheadend to free up memory?

Tuesday, October 21, 2014

Raspberry Pi DVR - tvheadend

Now that the final configuration of the Raspberry Pi is complete, it is time to install and configure tvheadend.  I felt this process was complex enough to warrant a dedicated post.

Installation:
Installing applications on most Linux distros is very straight forward, you issue a command which downloads and installs the package from the repositories on the Internet.  Unfortunately, the tvheadend package is not a part of the Raspbian repositories, so you can either download the source code and compile it yourself or you can manually connect to another repository.  I went with the latter, specifically using the repository maintained by tvheadend themselves.

First run the command "sudo curl http://apt.tvheadend.org/repo.gpg.key | sudo apt-key add -"  This adds the tvheadend GPG signing key to your system.  Next run "sudo nano /etc/apt/sources.list"  Append "deb http://apt.tvheadend.org/stable wheezy main" to this file.  Lastly, run "apt-get update" and "apt-get install tvheadend"  This will install and start the tvheadend server.  Installation will prompt you for a user account.  You can use the default Raspbian login, or use another account you previously created.

Configuration:
Now that tvheadend is installed we can configure it.  I wish I could say that tvheadend is easy to configure... but it is not.  I spent a lot of time learning the ins and outs of tvheadend before I was finally able to get it to work.

First you need to open a web browser and navigate to "<server>:9981" where <server> is the IP address of your Raspberry Pi or the name (if you enabled Samba).  You can use Epiphany from the Pi itself, or browser on another machine.

You may be prompted for a username and password, if so enter the credentials above used during the installation of tvheadend.  Once tvheadend is displayed, click on Configuration | DVB Inputs | TV Adapters.  From the combo box select your TV tuner.

If you do not see your TV tuner in the combo box then chances are you forgot to download the firmware file into /lib/firmware.  Consult the Linux TV Wiki for more info.

Make sure the device is enabled (checkbox in the middle) and click Save.  Next click on the "Add DVB Network by location" button.  Select the TV signal you wish to add.  For digital over-the-air broadcast TV in the U.S. select "us_ATSC_center_frequencies_8VSB."

After doing this, the right side of the screen where is says "Muxes awaiting initial scan" should read something like 68.  This will slowly countdown to 0.  Although there is little feedback, tvheadend is scanning all possible channels looking for signals.  This will take time - 10, 15 minutes, or more.  When that number reaches 0, hopefully the "services" and "muxes" above will read something other than 0.  That means it found some channels.  If "services" and "muxes" still read 0, then you need to check connections.  Is the antenna connected to the TV tuner?  If the antenna in a good location?

Once you have found services and muxes you are ready to map to channels.  Here is where things get really painful.  You can click the "Map DVB services to channels" button, but in my experience this does nothing.  Instead, we need to manually map these channels.  Here is how.  First, click on Configuration | Channel/EPG | Channels.  Next click "Add channel" and give the channel a name, something like "NBC 6-1."  You should also give it an integer number, but as far as I can tell this number means nothing.  Be sure and click "Save changes" after adding the channels.  Here is a screenshot showing manual entries for all the channels in my area.

Now that you have manually created the channels, you need to manually map them to the services found in the prior scan.  Click on Configuration | DVB Inputs | Services.  All found services should be listed, but the Channel name column should be blank.  For each and every row, double-click on the Channel name column.  This should open up a combo box and allow you to select one of the channels you manually created.  But how do you know which channel to select?  You basically need to do a double-mapping, manually of course (welcome to the world of Linux, do as much of the leg work yourself).  Every digital broadcast channel in the U.S. has something called a physical and virtual channel.  The virtual channel is "6.1" but the physical channel might be 15.  You can use antennaweb.org or tvfool.com (or probably a host of other sites) to get physical and virtual channels for all stations in your area.  The second mapping is physical channel to frequency.  A simple google search will show frequencies in MHz for all physical channels.  Now you are ready to map channels.  For each row there is a Multiplex column.  This shows the frequency for the channel.  Map this frequency to the physical channel, then map that physical channel to the virtual channel, then select that channel in the Channel name field.  After making all these changes, do not forget to click Save changes.  If this step is too complex, just use trial and error.  Set a channel to something, anything, then watch that channel.  Once you know what it really is, go back and change it.

You are getting very close now to completion.  Next click on Configuration | DVB Inputs | TV Adapters.  From the combo box select your TV tuner.  In the settings in the middle, make the following changes, be sure and click Save when you are done.

  • Enable "Skip initial scan."  This will prevent tvheadend from scanning for new channels every time the system reboots.
  • Disable "Idle scanning."  This will prevent tvheadend from continuously scanning in the background for new channels.
  • Enable "Close device handle when idle."  Without this tvheadend keeps the TV tuner active 24/7 which consumes a lot of electricity plus the TV will get really hot.  With this enabled the TV tuner is put into standby after each use.

The final piece of configuration can be found by clicking on Configuration | Recording | Digital Video Recorder.  Make the following changes, and be sure to click Save configuration when done.
  • For the recording path I entered "/mnt/nas/Videos"  This is where I want recorded videos to live, over the network on my NAS box.
  • Change Media container to "Same as source (passthrough)."  This saves the broadcast stream to a video file without any changes (called transcoding).  Since the Raspberry Pi does not have a powerful processor, it is unlikely it could transcode on the fly in real time.
  • I also checked boxes at the bottom control the output filename.


There, that was not so bad, was it?  Ok, I admit, that was a major pain in the butt!  Getting tvheadend is a pain to setup, but once it is done, it works pretty well.  Again, welcome to the world of Linux, expect more effort on your part, and less user-friendly compared to a typical Windows application.

Now that tvheadend is configured, you can set it to record TV programs.  To do that login to the above tvheadend configuration page.  Click on Digital Video Recorder | Upcoming Recordings.  Click Add entry and select channel, date, and time for the recording.  This is just like programming an old VCR.  You tell tvheadend to record channel 6.1 from 8:00 to 9:00 for example.  It uses 24-hour notation, so 5pm is represented as 17:00.


One area I would like to improve here is the use of EPG (electronic program guide).  This is a digital TV guide showing you what is on each channel at a given time.  You can simply click on a show to record it.  Or tell tvheadend to do things like "record the Simpsons" and it will records all episodes of the Simpsons, regardless of channel or time.  I have not configured EPG, for now I am doing everything manually.  EPG would be nice, but frankly after all this, I am just glad it is working.  So maybe in the future I will decide to tackle EPG.

Raspberry Pi DVR - The final configuration

I have finally reached the end of my Raspberry Pi DVR project.  My goal was to turn a Raspberry Pi into a DVR to record over-the-air broadcast TV.  To that end I have spent the last month experimenting with all the major distros available for the Raspberry Pi in an effort to determine the best distro.  Below is a step by step summary of my final configuration.

I ended up using Raspbain Wheezy as the operating system.  I downloaded the latest image (September 2014) direct from the Raspberry Pi Foundation's website.

Download the Win32 Disk Imager on your Windows computer.  Use this tool to write the above Raspbian image onto your SD card.

Stick the SD card into the Raspberry Pi and plug in power.  During first boot the Raspberry Pi configuration screen will come up.  I made the following changes.

  • Select "Internationalization Options" and then "Change locale."  Place a check by "en_US.UTF-8 UTF-8."
  • Select "Internationalization Options" and then "Change time zone."  Linux handles time zones differently than Windows.  Instead of selecting your time zone by name or UTC offset, you instead select a region and a city near you.  So for me I select Americas and Los Angeles.
  • Select "Internationalization Options" and then "Change keyboard layout."  For me I selected "Generic 104 key" and "English US."  This step is important as the default keyboard layout is English UK with things like the pound sterling symbol.
  • Select "Advanced Options" and then "Overscan."  Set this option to disabled.  Older analog TVs have overscan where the image is smaller than what the TV can display.  If I do not disable overscan then on my computer monitor I have half an inch of black all the way around the outside edge.  Disabling overscan corrects this.

Note: I did NOT set the Raspberry Pi to autoload the GUI (X desktop) on startup.  Because this will be a headless unit, having X running is just wasted resources.

Now would be a good time to configure the Raspberry Pi "BIOS."  Shutdown Linux, remove the SD card, and stick it into a Windows machine.  Append the following lines to config.txt:
arm_freq=800
core_freq=300
force_turbo=1
max_usb_current=1
The first 3 lines add a little overclocking which is totally safe, but definitely helps out.  The last line is required for the model B+ to take full advantage of the new USB power circuitry.  By default, the model B+ will deliver up to 600mA of power to the 4 USB ports.  However, with the above setting it can deliver up to 1,200mA (assuming you are using a good quality 2A power supply).  600mA might be enough under normal uses, but with the TV tuner and wifi card on top of keyboard and mouse, you will need the extra amps.

Next I need to configure my wifi.  I manually started the GUI desktop with the command "startx"  I used the shortcut on the desktop to configure my wifi connection.  There are ways to do this from the console, but it was just easier to do it graphically.

Now that the network is setup, we can configure the Raspberry Pi on my network.  By default Linux does not play well with other computers on the network.  Access to and from the Pi works only when using IP address and not computer names.  To fix that we need to install a networking package called Samba.  To install Samba run the command "sudo apt-get install samba samba-common-bin"

The next step is to give your Pi a computer name.

  • Run the command "sudo nano /etc/hosts"  There should be a line with "127.0.0.1   raspberrypi"  Change the "raspberrypi" to whatever name you wish to use.
  • Run the command "sudo nano /etc/hostname"  This should be a single line text file.  Replace the text with the name you entered above.
  • Commit the above changes with the command "sudo /etc/init.d/hostname.sh"  [I am not sure if this step is required.]
  • Reboot your Raspberry Pi.  After the reboot it should have a new computer name and you should be able to access computers via name.


In my setup, I want the Raspberry Pi to record TV programs directly to my NAS box.  To do that I need to mount the NAS box so that the Raspberry Pi can access it.  First, change to the /mnt folder.  Run the command "sudo mkdir nas"  This will create a folder /mnt/nas.  This folder will become the mount point for the NAS drive.  Now run the command "sudo nano /etc/fstab"  Scroll to the bottom and enter the following:

//<server>/<share> /mnt/nas cifs username=<user>,password=<pwd> 0 0

Where <server> is the name or IP of the NAS box and <share> is a shared folder where to save the videos.  Also <user> and <pwd> are the credentials used to access the NAS box.  After rebooting the Pi again, you should be able to browse to the NAS box at /mnt/nas.

To get my Hauppauge 950Q TV tuner working, I need to manually download the firmware file.  I started the X desktop again and used the Epiphany web browser.  I downloaded http://www.kernellabs.com/firmware/xc5000/dvb-fe-xc5000-1.6.114.fw.  I then moved the file to /lib/firmware

After all this work, it is finally time to install and configure tvheadend, which is the software that performs the actual TV recording and streaming.  This step is not trival, so I will cover everything in a dedicated post.

The final step, once all this is configured, is to ensure the Raspberry Pi is up to date.  Run the command "sudo apt-get update" which checks for available updates (but does not install them).  Then run the command "sudo apt-get dist-upgrade" to download and install the updates.  I have found that the second command often times hangs toward the end.  If this happens, unplug the Pi and plug it back in.  Once it comes back up rerun these two commands.  If they succeed then you are done.  However, they might fail and tell you to run another command first.  Run the command it tells you to run and that should clear up any problems.

There you have it.  An end to end configuration guide for turning a Raspberry Pi into a DVR for TV recording.  I hope you found this guide helpful!


Update: This addendum covers changes I made to help with tvheadend crash problems.

Tuesday, September 30, 2014

Raspberry Pi - Overclocking

I have worked with computers professionally for 20 years now, yet in all that time I have never once experimented with overclocking and/or thermal management.  Given that the 1) Raspberry Pi is so easy to overclock, 2) it is relatively cheap to replace should I break it, and 3) the whole idea behind the Raspberry Pi is to be used as an education tool; this seems like the perfect time for me to experiment.

Before purchasing my Raspberry Pi I researched it and the general consensus is the Raspberry Pi does not need heatsinks unless you are trying to overclock to extreme levels.  I wanted to test this for myself, so I purchased a set of heatsinks shown here.  What is nice about these heatsinks is they are made of copper (which conducts heat better than aluminum) and they have tall fins for maximum heat dissipation.  So this should be the most effective passive cooler for the Raspberry Pi.

As far as overclocking, the creator of the Raspberry Pi, Eben Upton, said that overclocking your Raspberry Pi will not damage it, but overvolting it may.  As such, overvolting voids the warranty (and they will know because of a burned out internal fuse).  So I plan to avoid overvolting, which also limits how much overclocking I can do.

Overclocking is accomplished by setting values inside the config.txt.  There are a lot of values you can tweak, but there are 3 main settings.

  1. arm_freq = The frequency of the CPU.  The default value is 700.
  2. core_freq = The frequency of the GPU.  The default value is 250.
  3. sdram_freq = The frequency of the RAM.  The default value is 400.
I started playing with these numbers, and I noticed something odd.  I could crank the speed up higher than most people on the Internet reported and I had no problems with stability nor extra heat generation.  Was the model B+ significantly improved in this area?  Turns out the answer is no.  By default the Raspberry Pi (like all modern processors) has a base line and a "turbo" frequency.  It runs at the above default values and only switches to the overclocked values when the CPU reaches a certain use threshold.  There is an additional setting called "force_turbo" that disables this dynamic switching and forces the Pi to always run at the overclocked values.  I recommend enabling this "force_turbo" setting, at least during initial testing.

When you overclock the Pi there are two concerns.  First is heat generation, you need to make sure the CPU is thermally cooled (more on that later).  The second problem is SD card corruption.  Some overclock settings are not stable and the result in corrupted SD cards.  The reason I recommend enabling "force_turbo" during testing is because then it will force SD card corruptions to happen more frequently if you are using unstable overclocking settings.  But with "force_turbo" disabled the Raspberry Pi will run at slower speeds most of the time even if the overclock settings are unstable.  The long term result would be random crashes that would be hard to diagnose.

Ok, so let us put this all together.  The first question is, does overclocking make a performance difference, and if so how much.  For this I used sysbench which can stress the CPU calculating prime numbers.  At the default 700/250/400 settings, it took 8:29 to calculate the first 10,000 primes.  When overclocked to 900/300/400 this dropped to 6:34 - approximately 25% faster.

As for thermal, during the initial 700/250/400 the starting temperature was 106°F (41°C) and went up to 109°F (43°C).  Overclocked to 900/300/400 the starting temperature was 106°F (41°C) and went up to 111°F (44°C).  As you can see, the temperature increase was very small.  In all of my tests, overclocking added about 2°F (1°C).  Given this small increase in temperature versus the noticeable gains in performance, it makes sense to overclock your Pi.

Lastly I was curious how much of a difference the heatsink made.  I repeated all of my tests this time with the heatsinks attached.  The change was minor but consistent.  Adding the heatsinks reduced the temperature by 2°F (1°C).  In addition to the minor drop in temperature, I noticed temperatures rose less sharply than they did without the heatsinks, and when the load dropped off the CPU cooled off quicker.

I was curious if forced air (like a fan) would make a difference.  The answer is most definitely yes!  In fact, this is far more effective than a heatsink.  Merely blowing on the CPU cooled the processor more than the heatsink ever did.  So if you are looking to seriously overclock your Pi, you need to look into a fan solution, with or without a heatsink.


Conclusions
After all of my tests, here are my conclusions.
  1. Everyone should at least mildly overclock their Raspberry Pi.  Set it to 800/250/400 with force_turbo disabled.  You will not damage your hardware, nor will it overheat, but you will see speed improvements under load.
  2. If you are looking for a little more speed (like me), then set your CPU between 800 and 900, bump the GPU to around 300, and try increasing the RAM to 450.  Be sure and set force_turbo at least during the testing to make sure it is stable.
  3. At these overclock settings, it will run a degree or two warmer, which is exactly how much cooling is provided by the heatsinks.  So think of the heatsinks as piece of mind, they perfectly balance out the slight overclocking.
  4. If you wish to overclock to extreme levels then you will most likely need fans and probably overvolting as well.  So proceed at your own risk.

Monday, September 29, 2014

Raspberry Pi DVR - XBian

Xbian is the last of the XBMC specific distros for the Raspberry Pi I wanted to look at.  XBian, like OpenElec, is updated fairly regularly - which is good.  Beyond that, XBian sounds like a cross between Raspbmc and OpenElec.  A good description of Xbian is OpenElec, but not trimmed down to the bone.  They leave more Linux in place should you need to perform maintenance outside of what they consider to be typical.

XBian - 1.0 release candidate 3
When I first tried Xbian the latest version was 1.0 RC2.  This version was not compatible with the Raspberry Pi model B+.  When you booted Xbian all USB ports were dead, so the mouse and keyboard would not work.  This is where I first learned about the manual firmware update I talked about in a recent post.  But only a few days after running into that problem, RC3 was released which fixed this problem.

Using RC3 I am able to go further, but I hit another wall.  Once XBMC has loaded I noticed my WiFi adapter is not working so I have no network access.  What is worse, I am not able to connect my Pi up to a wired ethernet jack right now.  And without network access, XBian is useless to me.  As I previously started in my review of OpenElec, I am going to go with a headless tvheadend server for now and I will purchase a second Pi to use as a HTPC.  At that point I will revisit Xbian.  Hopefully by then they will either fix the network issue, or I will have access to a wired network port then to be able to test with.

Raspberry Pi DVR - OpenElec

OpenElec is another Linux distro that is centered around XBMC.  OpenElec has several things going for it.  First, they take the "flying gas can" approach, which is to say they strip off everything from Linux that is not vital to either the operating system, XBMC, or operations therein like TV and WiFi.  So OpenElec is a very small image - the entire image file is around 100MB compared to 3+GB for many other distros.  This "light" approach means OpenElec performs better on the Raspberry Pi's limited hardware.  Another plus for OpenElec is the level of active development.  My impression is OpenElec is probably the XBMC-cenetered distro with the most active development, which is good for feature support and bug fixes.  Because of all this, OpenElec has become probably the most popular HTPC distro for the Raspberry Pi.  So going into this I am expecting good things.

OpenElec - 4.0.7
The first thing you notice when working with OpenElec is how quickly you can write the image to your SD card.  Because of the small image size creating a SD card is a lot quicker than other distros.  On first boot it goes straight into XBMC after which an initial configuration wizards comes up.  This wizard allows you to set up things like your network.  Like all other distros, the Rosewill RNX-N180UBE was supported out of the box.

Next I went to try out the TV tuner and tvheadend.  OpenElec includes both the firmware file for my TV tuner, and has pre-installed the tvheadend server.  All I need to do is enable the tvheadend server, which is disabled by default.  Of course, that seemingly simple task proved hard to find.  All the guides on the Internet were old and were no longer the way to enable tvheadend.  After much poking around I found the setting.  From XBMC select System | Settings | Add-ons | Get Add-ons | OpenElec Media Center OS Add-ons | Services | tvheadend.  From this deep buried menu you can enable tvheadend.

The next step is to setup tvheadend.  When started a TV channel scan, the Raspberry Pi hung.  I know the hardware works because I was able to scan for channels under Raspbian, so there must be a software problem causing this.  OpenElec just released 4.2.0 which might address this problem.  I will have to give that a try sometime.

But this was the point where I decided to stop with OpenElec.  My original plan was either a headless DVR in the garage, or a full HTPC in the house.  I have since decided to do both.  This Raspberry Pi will become the headless unit in the garage recording TV, and I am going to buy a second Raspberry Pi to function as a HTPC connected to a TV.  So I do not want to install OpenElec on a headless unit.  When I get a second Raspberry Pi I will reevaluate OpenElec using the latest release of the distro.

Friday, September 26, 2014

Raspberry Pi - BIOS, firmware, and other basic topics

I wanted to take a break from reviewing Raspberry Pi distros and talk about some basics of the Raspberry Pi.  Things I have learned that others might find useful.

First I think it is important to understand I come from a background of Windows.  I know a little bit of Linux, and even less of the specifics of the Raspberry Pi.  So if you are a Linux guru then this will not help you.  But chances are, if you are reading this then you use Windows and will be coming from that background as well.  So below is a list of topics or things I have learned about the Raspberry Pi thus far.

1.  Most, but not all, distros for the Raspberry Pi are "installed" or copied to the SD card in the same way.  You download a single image file (.IMG extension) and then use Win32 Disk Imager to write that image onto the SD card.  This process is straightforward, even for non-technically people.  After this process is complete, it is important to understand what the contents of the SD card look like.  Let's say you have a 16GB SD card.  After writing an image you will have a small (maybe dozens of MB) FAT partition followed by a 3+ GB Linux partition (Windows will call it "unknown").  In total it will use 4GB of the SD card, leaving the remaining 12GB unused.  This is why pretty much all distros for the Raspberry Pi say the minimum SD card size is 4GB.  However, most distros have an option to expand the Linux partition to fill the rest of the SD card.

2.  Every computer I have worked on has a BIOS which is stored in firmware on the motherboard.  The Raspberry Pi does not follow this model.  The BIOS/firmware is stored as a set of files located on the SD card.  As such it is possible for the average user to upgrade the firmware manually.  To do that first download the updated files in the "boot" folder here.  Then copy these files into the FAT partition on your Raspberry Pi SD card.  It is probably a good idea to backup the original files.  Now I believe this process is safe to do, but I am not a Raspberry Pi developer.  I have not found documentation on the web stating you can do this.  But in my experience this does work.  I have had to do this twice on older distros that did not include updated BIOS/firmware to support the model B+.

3.  Because of how and where the Raspberry Pi's BIOS is located, things that you would normally configure inside the BIOS of a computer are configured inside a text file.  The aforementioned FAT partition contains a file called config.txt.  This file contains things like memory allocations, overclocking, USB power, and enabling/disabling hardware.  This page has lots of info about the config.txt file, what settings do what.

4.  Viewing and changing the BIOS/firmware and config.txt files is easiest from a Windows PC.  You can mount and modify this FAT partition from the Pi while the Pi is booted, but this partition is normally mounted as read-only so you have to take extra steps.  It is far easier to shutdown the Raspberry Pi and stick the SD card into a Windows PC.  The FAT partition will show up as a drive letter and you can view and edit the files.  One word of caution, the file config.txt should be a Unix text file which is slightly different from a Windows text file.  So I would not use Notepad to edit this file.  I would recommend a text editor that is Unix-aware, like the excellent and free Notepad++.

5.  During initial set up it is easier to use a monitor, keyboard, and mouse connected to the Raspberry Pi.  But if you remove this Linux is very easy to work with remotely.  For command line administration use SSH, which many distros have enabled by default.  The best Windows SSH client is Putty.  To control the GUI aspect of Linux you can either use xrdp which works with the default Windows Remote Desktop Protocol, or VNC which there are a number of free Windows VNC clients (disclaimer - I never did get VNC working on the Pi).  Lastly, should you want to transfer files to/from the Pi, you might look into SFTP.  I never did use this on the Pi so I cannot tell you how to enable an SFTP server, but I can recommend either WinSCP or Filezilla as great free SFTP clients.

6.  By default Linux does NOT play well with other computers on your local network.  On the Pi I can access other devices (Windows computers, my NAS box, etc.) by IP address but not by name.  The opposite is true also.  From Windows I can access the Pi by IP address, but not by name.  I thought this was a function of DNS, but by default Linux does not interact with DNS in this way.  The solution is a software package called Samba.  Samba is software protocols and services that help Linux to play nicely with Windows and other devices on the network.  Once you install Samba you should be able to access network resources using name as well as IP address.

7.  On my home network I have a Synology NAS box, and I want to be able to access this box to copy files.  To config Linux to mount a network resource every time it boots, you need to edit the file /etc/fstab  Append the following to the end of that file:

//<server>/<share> /mnt/<folder> cifs username=<user>,password=<pwd> 0 0

Where <server> is the name or IP of your NAS box and <share> share name to access.  Note that Linux uses forward slashes whereas Windows uses backslashes for UNC paths.  Next is <folder> which is a local folder on the Pi where to mount the folder for access.  Lastly <user> and <pwd> are the credentials needed to access the NAS.  After you do this you need to manually create the mount folder.  Change to /mnt and create a new folder with the same name as <folder>.  Lastly reboot and you should be able to access your NAS or other network share.

8.  Here are some command commands you might need to run from the command line:

[sudo] nano <file>
Edit a file in a text-only editor.  If you used pine back in the day, nano is the modern version.  You may need to add sudo if you do not have permissions to access the file.

sudo apt-get update
Checks the Internet for newer versions of software and patch upgrades, but does not actually install anything.  This is the first step in updating your computer (think Windows Update).

sudo apt-get upgrade
This step actually downloads and installs the updates found in the previous step.

sudo apt-get dist-upgrade
Think of this as a smarter more powerful version of the above command.  If a newer program supersedes an older one, this will remove the old and install the new.  So the recent release of Epiphany browser, this command will remove Midori and install Epiphany.

sudo apt-get install <package>
This will install new software on your computer.  You need to know the name of the package to install.  All of this apt-get stuff is controlled by the file /etc/apt/sources.list which contains a list of Internet servers where to pull software and updates from.

startx
If your Raspberry Pi boots to command line by default, the command startx will start the graphical environment.

ls -slagFL | more
This displays files and folders similar to the dir command in Windows.

Raspberry Pi DVR - Raspbmc

Raspbmc is the first of the Home Theater PC (HTPC) specialized distros I am going to look at.  It gets its name from XBMC which is the software used to display meida (videos, TV, music, pictures, etc.).  These specialized distros of Linux run XBMC and only XBMC.  When the Raspberry Pi boots it automatically starts XBMC, and XBMC runs until the Pi is shutdown.

To install Raspbmc you have several options.  They have a small image which is the network installer.  When you boot the Raspberry Pi for the first time it downloads and installs Raspbmc.  This version requires network access via ethernet as wifi will not work.  Another option is the full standalone image which is larger to download, but does not require network access via ethernet.  I tried both methods and they both were straightforward and worked.

Once Raspbmc was installed, I was able to setup wifi access as Raspbmc did include drivers for the Rosewill RNX-N180UBE.

It does come with tvheadend server pre-installed, although it is not enabled by default.  To enable it go into the System Config from inside XBMC and scroll down to find tvheadend in the list.  I did notice the firmware file for my TV tuner was not present so I had to copy it manually.

As for remote access, ssh was enabled by default making it easy to connect remotely.

However, I did run into one major problem with Raspbmc.  In XBMC's settings menu is an option to run a web browser called Aurora.  I never actually wanted to use this web browser, but on several occasions I accidentally clicked on the link to start the browser.  The browser started to load and then the Raspberry Pi crashed.  But the major problem was, every time this happened, it corrupted my SD card image and I had to start from scratch.  This is a major problem that a top-level program will result in a corrupted system.  You could say "well just do not run it."  But I was not trying to run it, all 3 times I accidentally clicked on it.

Given this corruption issue, and given that Raspbmc has fallen behind other distros like OpenElec and Xbian, I decided not to pursue this distro any further.  Raspbmc is being superseded by a new project called OSMC.  If and when this project materializes I would love to give it a try.  But for now I am going to pass on Raspbmc.

Thursday, September 25, 2014

Raspberry Pi DVR - PiBang

Although not on my initial list of Linux distros to look at on the Raspberry Pi, I read some posts online where people raved about PiBang.  So I thought I would give it a try.

PiBang - November 2013
When you go to download PiBang, the first thing you notice is a post stating that PiBang is no longer in active development.  They claim this is not because of a loss of interested, but because PiBang had reached a point where there was little more to do on it.  I guess there is only one way to find out.

Booting PiBang for the first time and immediately run into a problem.  The setup screen comes up, but your mouse and keyboard do not work.  Also, any devices plugged into the USB jacks on the Raspberry Pi are not powered on.  After much research on this problem (and experience from other old distros) I found the problem and a solution.  The new model B+ requires newer firmware files to boot correctly.  Without them the USB jacks will not be powered up, hence the non-working keyboard and mouse.  To solve this problem I manually downloaded and copied the latest Raspberry Pi firmware files onto the SD card and rebooted (I will post an entire follow up post with details on this manual firmware update process).

This time my keyboard and mouse worked.  PiBang includes a first-time boot config screen almost identical to Raspbian.  I changed similar settings such as region and locale as well as select the option to expand the SD card.  When the Raspberry Pi rebooted, PiBang crashed and would not recover no matter how many times I rebooted it.  At this point I decided to give up on PiBang.  Because it is so much older than the model B+ I have, it is not worth my time to try and figure out how to get it to work.  In the future if they release an updated version that is compatible with the B+ I would love to give it a try.  But for now PiBang is just too old to be of use.

Raspberry Pi DVR - Pidora

The second Linux distro I looked at for the Raspberry Pi is Pidora, which is the Raspberry Pi version of Red Hat Fidora.

Pidora - Version 20, July 2014 (kernel 3.12.23)
Installing Pidora is even easier than Raspbian.  The first thing you are greeted to is a nice GUI wizard that walks you through the process of setting up the keyboard, user account, time zone, etc.  Not that this was hard in Raspbian, but Pidora makes this so easy anyone could do it.

Once the initial Pidora setup is complete, you immediately notice how it differs from Raspbian.  Whereas Raspbian is an operating system geared towards education and tinkering, Pidora is a full-fledged operating system.  It has user login accounts, defaults to a graphical desktop, and the default set of software is geared more towards work and productivity than education.

The next thing you notice is that Pidora is slower and less responsive than Raspbian.  This is no doubt because it is a more complete operating system and therefore has more tasks and processes going on.  It is still usable as a computer, but be prepared to wait just a little bit more.

Pidora did include built-in support for the Rosewill RNX-N180UBE.  To configure it I selected Settings | Network Connections | Add New Connection for WiFi.  WiFi was not quite as easy to configure as on Raspbian, but Pidora was fairly straightforward.

Pidora also includes the firmware file for my TV tuner, but I did not run any tests on the hardware such as install tvheadend.  After running Pidora I could see that, while a great operating system, it was not a good fit for my needs.  So I did not perform any further tests towards the end goal of setting up a DVR.

Pidora was definitely an interesting distro, worth my time to look at.  If you are looking to use a Raspberry Pi as a replacement for a desktop or laptop computer then Pidora is definitely worth a look.  Of all the distros on the Raspberry Pi, Pidora is probably the closest to a regular desktop version of Linux .

Wednesday, September 17, 2014

uBlock for Chrome - Give it a try

One great thing about Firefox and Chrome is their extensive libraries of add-ons, plugins, extensions (whatever you want to call them).  I do not install many, but the ones I do install I could not imagine "surfing" without them.  One of my long time favorites is AdBlock Plus.  This plugin does a great job of blocking many of the ads we are bombarded with on a regular basis.

I just found an even better alternative to AdBlock Plus.  It is called uBlock (micro-block).  uBlock does the same thing as AdBlock Plus, in fact it uses the same lists and filters as AdBlock Plus.  But what sets uBlock apart is how efficient it is.  The authors wanted to create an ad blocker that is A) as fast as possible, B) as memory efficient as possible, and C) as clean and simple as possible.  And they succeeded!  uBlock is fast, simple, and unobtrusive.

The only downside with uBlock is it is currently a Chrome only plugin, there is no Firefox plugin.  I really hope they come out with a Firefox version.  But in the meantime, all Chrome users should add this plugin to their system and reap the benefits.

Tuesday, September 16, 2014

Raspberry Pi DVR - Raspbian

The Raspberry Pi has lots of different operating systems to choose from.  For my DVR project, instead of picking one and trying to make it work at all costs, I decided to experiment with each operating system one by one.  That way I can see the strengths and weaknesses of each before deciding which operating system is the best for me.  To start things off I will be looking at Raspbian.

Raspbian is the main operating system for the Raspberry Pi.  It is a version of Debian "Wheezy" Linux made specifically for the Raspberry Pi.  It's a general purpose operating system, so you should be able to do most anything from Raspbian that you could do on a regular computer.

Raspbian Debian "Wheezy" - September 2014 (kernel 3.12)
Installing Raspbian is very easy.  Download the image then use a tool like Win32 Disk Imager burn the image onto your SD card.  The first time you boot a configuration screen will pop up.  I made the following changes on this screen (you can rerun this tool later on to make these changes).

  1. Select "Enable Boot to Desktop" and then "Desktop log in as user pi."  Without this change Raspbian will boot to command line, with this change Raspbian will boot to a nice graphical interface.
  2. Select "Internationalization Options" and then "Change locale."  Place a check by "en_US.UTF-8 UTF-8."
  3. Select "Internationalization Options" and then "Change time zone."  Linux handles time zones differently than Windows.  Instead of selecting your time zone by name or UTC offset, you instead select a region and a city near you.  So for me I select Americas and Los Angeles.
  4. Select "Internationalization Options" and then "Change keyboard layout."  For me I selected "Generic 104 key" and "English US."  This step is important as the default keyboard layout is English UK with things like the pound sterling symbol.
  5. Select "Advanced Options" and then "Overscan."  Set this option to disabled.  Older analog TVs have overscan where the image is smaller than what the TV can display.  If I don't disable overscan then on my computer monitor I have half an inch of black all the way around the outside edge.  Disabling overscan corrects this.

Once Raspbian is loaded, I used the "WiFi Config" link on the desktop to configure my wireless network.  I'm pleased to report that Raspbian includes drivers for the Rosewill RNX-N180UBE so the network worked as soon as I entered my wireless password.

One very common task on any operating system is browsing the Internet.  The Raspberry Pi has at least 4 browser options.  I tried each to see which worked the best; Iceweasel, Midori, Chromium, and Epiphany.
  1. Iceweasel is the Raspberry Pi version of Firefox.  To install it you run the command "sudo apt-get install iceweasel"  Whereas Firefox is my favorite browser on Windows, the Raspberry Pi does not do it justice.  It was the slowest of the bunch making surfing a painful experience.  On the plus side, the pages were rendered perfectly and looked as they should.
  2. Midori was the default Raspbian browser up until one month ago.  It was faster than Iceweasel, but still slow.  I also noticed some pages looked as if they did not render correctly.
  3. Chromium is the Raspberry Pi version of Chrome.  Chromium was fast and also rendered the pages correctly.  To install Chromium run the command "sudo apt-get install chromium"
  4. Epiphany was just released about a month ago.  It is the result of about 10 months of work dedicated to making the fastest most optimized browser for the Raspberry Pi's limited hardware.  And it shows!  Epiphany was the fastest of the bunch, rendered all pages correctly, and has a clean simple UI that was easy to use.
I would recommend Epiphany to anyone using a Raspberry Pi.  If you need a second choice, then go with Chromium.  Regardless of which you chose, all 4 browsers scored a perfect 100 on the acid 3 test.  You might run into problems getting Epiphany installed if you are using an older image.  I initially started testing with the June 2014 Raspbian image which does not include Epiphany.  There are instructions on adding it to your system, but each time the upgrade process hung.  I repeated it 3 times on fresh images, each time it hung.  Eventually I got it installed right about the time they released the September 2014 image which contains Epiphany out of the box.  So unless your image contains data you must keep, I recommend wiping your SD card and starting fresh with a new image.

The next hardware question was does Raspbian see the Hauppauge 950Q TV tuner?  The kernel does see it, but you need to manually install a firmware file (more on that in a later post).  Next you need to install the tvheadend server.  First run the command "sudo curl http://apt.tvheadend.org/repo.gpg.key | sudo apt-key add -" then edit the file /etc/apt/sources.list.  Append the following to that file, "deb http://apt.tvheadend.org/stable wheezy main"  Lastly, run "apt-get update" and "apt-get install tvheadend"  This will install and start the tvheadend server.  tvheadend did see the TV tuner and started to pick up local TV channels.  I won't go into more details about tvheadend right now.  I'll save that for another post.  After all, whether I use Raspbian or something else like OpenElec, the configuration of tvheadend will be the same, so best to cover it once in a dedicated post.

The final tests I wanted to run on Raspbian is remote access.  Using the Putty on another computer I was able to connect to SSH on the Raspberry Pi.  SSH was enabled by default in Raspbian.  SSH access was fast and snappy, as you'd expect from a command line only connection.

I also tried Windows Remote Desktop Connection.  On the Pi I ran "sudo apt-get install xrdp"  After which I was able to connect remotely from Windows using the built-in Remote Desktop tool.  The connection was relatively responsive.

The final remote option I tried was VNC.  I installed TightVNC server on the Pi, but no matter what I tried I was unable to connect using another computer.  I don't know if the server wasn't properly started, or maybe the port was wrong.  But I never got it working.  Since I had two other ways to remotely connect, I decided not to pursue this any further.


Well there you have it.  My first distro review for the Raspberry Pi.  For the most part it was easy to use, but I recommend a lot of tinkering to get used to the quirks.  For example, it took me a while to figure out how to set the keyboard to US layout instead of UK layout.

Tuesday, September 9, 2014

Windows will not load after ImageX

One thing I do a lot is image a computer and restore that image using Microsoft's ImageX utility.  Imaging a disk is one of the fastest ways to backup a computer.  But about 1 in 4 times that I restore an image the computer will not boot afterwards.  I never knew why it worked most of the time, but had a high rate of failure.  What's more, it made me very hesitant to use this in critical situations.  What if I backup a computer knowing I will need to restore the image, and that image restoration fails?  You'd never put your money in a bank that has a 1 in 4 chances they will lose your money, right?  Fortunately, I recently found out what the problem is, and more importantly, how to fix it.

First let me describe the symptoms.  After performing a restore from a WIM file using ImageX, you reboot your computer.  But instead of Windows loading you get an error screen saying:

Status: 0xc000000e
Info: The boot selection failed because a required device is inaccessible.

The problem here is the Boot Configuration Data (BCD) info.  Windows stores the boot information in a BCD file and for whatever reason the BCD from the image file is not compatible with the new system after restoring the image.

To correct this problem you need to first boot your computer from a WinPE CD or USB drive.  I won't explain that as there are lots of guides on the Internet.  Once WinPE is loaded, if you type "bcdedit.exe" you will see the problem.  Three of the fields are "unknown."


The following 3 commands will restore these unknown values and fix the problem

bcdedit.exe /set {default} device partition=c:
bcdedit.exe /set {default} osdevice partition=c:
bcdedit.exe /set {bootmgr} device partition=c:

After this, simply reboot and Windows should load normally!

Tuesday, September 2, 2014

Funny sayings

This is a random post with some funny things I ran across recently.  First is a saying:
A PC a day keeps the Apple away.
As a longtime Apple-hater, this is just hilarious to me!  And so true!


The second funny thing is funny SSID names for your home wireless router.  One of my neighbors has a funny SSID, which got me curious so I googled to find more.  Here's a list of the funnier ones I found:

  • Don't sleep with my wifi
  • It hurts when IP
  • Pretty fly for a wifi
  • Bill Wi the Science Fi
  • FBI Surveillance Van
  • Get off my LAN
  • All Your Bandwidth Are Belong To Us
I guess some people use them to send subtle (or not so subtle) messages to their neighbors such as:
  • Stop stealing our Internet
  • Keep your kids off my lawn
  • Stop your dogs from barking
These aren't as funny as the first group unless your situation warrants it.

Thursday, August 21, 2014

Raspberry Pi DVR - Software

In addition to the hardware for this project, I'll need software to make it all work.  For all intents and purposes, the only OS that runs on the Pi is Linux - which is fine by me.  I first learned Linux back in college only a few years after the OS was created.  Yes, my Linux "skills" are no where near my Windows "skills," but I know enough to be effective in the OS.

My ultimate goal is to create a DVR, so to make that happen I need TV recording software.  So far the only software I've found that supports this task is "tvheadend."  If I go with my stretch goal of a full-blown media center, then I'll need a software package to play videos and media content.  Here I have several options, but in truth there is really only one contender - XBMC (soon to be renamed "Kodi").

Linux is different than Windows in that you can get Linux from many different sources, each source being custom tailored for a different use.  Each of these different versions is called a "distro."  For the Raspberry Pi I have 5 different distros that I am considering.  One may work better than another with the hardware I have and the goals I'm trying to accomplish.  So my plan is to try all 5 distros and report back on each.  I'll blog about each distro in a separate page as I test with them.  But here's an overview of the 5 distros I'm going to try.

Raspbian
Raspbian (a.k.a. Wheezy) is pretty much the default OS for the Raspberry Pi.  If you're looking to use the Raspberry Pi as a general computer; web surfing, checking emails, word processing, programming, etc. then you'll most likely use Raspbian.  It has a friendly graphical user interface along with support for a lot of hardware and software packages.  My guess is all new Pi owners should at least start here, to get a feel for how the hardware and software works before moving onto more specialized options.

Raspbmc (soon to be renamed OSMC)
As stated above, XBMC is the preeminent media center application for the Pi.  Whereas you can install and run XBMC on Raspbian, with so many resources used by the OS it sounds like it will run sluggishly and/or have issues.  Enter Raspbmc - one of several distros dedicated to running XBMC on the Pi.  Raspbmc is built on top of Linux, but it is built specifically to run XBMC.  Anything in the OS that is not needed by XBMC has been removed.  What's more, the creators have taken the time to add drivers and support for hardware specifically used by media centers.  Hardware like TV tuners, remote controls, etc.  The trade off is these media center distros are not general purpose computers.  You cannot check email, surf the web, etc.  In fact, when you power up the Pi it boots directly into XBMC.

OpenElec
OpenElec is another dedicated media center distro for the Pi.  It sounds like OpenElec is Raspbmc taken even further.  Even more of the unused parts of the OS have been removed making OpenElec tiny and fast.  It sounds like OpenElec is even faster than Raspbmc, but at the cost of customization.  If OpenElec has support for your hardware then you're golden, but if not it sounds like your only option is to download the sources and recompile OpenElec yourself - not for the faint of heart.

Xbian
Xbian is the last of the dedicated media center distros I'm going to look at.  From what I've read, Xbian sounds like a cross between Raspbmc and OpenElec.  It's got the speed of OpenElec with the customization and flexibility of Raspbmc.

RetroPie
The last distro is completely different from the others in that it is not for media but is designed to play retro video games.  It's basically a collection of computer and video game emulators as well as free and open-source video games from the 70s, 80s, and 90s.  Assuming I connect the Pi to my TV (and not headless in the garage) this would be a fun distro to have on hand for playing "old-school" video games.


That's a summary of the 5 distros I plan to look at.  Not having tried the distros, only going by what I've read on the Internet, it sounds like OpenElec and Xbian are the most promising for my goal.  I think it all boils down to if these two distros have drivers for my hardware, and if not then I'll have to research how to add that support.

As I said, I plan to run all 5 distros and report back on my findings and impressions of each.

Monday, August 18, 2014

Raspberry Pi DVR - Hardware

To continue my chain of posts, after some research in the hardware necessary to turn a Raspberry Pi into a DVR I purchased the hardware.  Below is what I ordered:

Raspberry Pi model B+

Obviously the most important piece is the Raspberry Pi itself.  For this I went with the newly released model B+.  The model B+ has the exact same CPU, graphics core, RAM, and networking as previous models.  Where the model B+ really shines is the extra USB ports and improved power.  The improved power circuitry means I should be able to avoid using an external hub (pretty much required on all previous models) and also consumes less electricity so it costs less to run.

SD card

For the micro SD card I went with a 16GB Samsung EVO micro SD card.  I chose those card because it's rated as one of the fastest micro SD cards available, so that should help to speed up the Pi.

Power supply

In order to take advantage of the model B+'s improved power circuitry to power USB devices without a hub, you need a sufficiently powerful micro USB power adapter - specifically you want one that can deliver at least 2 amps of power.  I went with this adapter, it got great reviews and was relatively cheap.

TV tuner

Probably the hardest part about this project is the TV tuner.  You need a "stick" USB tuner to be able to receive TV signals.  But TV tuners and Linux don't seem to play well together.  There aren't many TV tuners on the market to begin with, and even fewer that work with Linux.  What's more, where you are in the world will dictate what type of tuner you need.  Most of the world uses DVB-T, but North America uses ATSC.  So shop for a tuner accordingly.  In the end, I went with the Haupauge 950Q.  New this item costs $70, but I purchased a used one on eBay for less than half that.  Before selecting your tuner you might want to read this list of TV tuners known to work in Linux, and this list of hardware known to work with the Raspberry Pi.

WiFi adapter

Although the Pi has built-in ethernet, I want to locate the Pi far from my router.  So I'll need a USB wireless adapter.  As with TV tuners, it's important to find one that works with Linux and/or the Pi.  Here's a list of hardware known to work with the Rapberry Pi.  I went with the Rosewill RNX-N180UBE.  I chose this model for several reasons.  First, the large antenna should provide a good signal from the garage.  Second, it was listed as working out of the box with the Raspberry Pi (less setup headache).  And finally, it's listed as an N300 adapter for greater speed.  However, I'm disappointed on this last one.  After receiving the adapter the manual clearly states the download stream is N300 but the upload speed is N150.  I thought I was mislead by Newegg/Rosewill, but after reading the product specs online closer it does say this.  So the fault is my own.  This is still the adapter I want. I just wish it were N300 both directions.

Heatsinks

From what I can tell, the Pi does not need heatsinks.  And it sounds like heatsinks will only lower the temperature by a couple of degrees.  That said, I did purchase a set of copper heatsinks.  In all my years of working on computers I've never experimented with overclocking nor heatsinking options.  So I'm going to experiment on the Pi with those.  And it's that the whole idea behind the Pi - to experiment, learn, and have fun?

Case
Technically the Pi doesn't need a case.  But it's a good idea, if for no other reason than to prevent shorts against metal.  I haven't purchased my case yet, but I like the look of this case.

HDMI cable
I do have several 6' HDMI cables, but I wanted something shorter.  So I purchase this 3 pack of 3' HDMI cables from amazon.

Keyboard, mouse, and monitor
Fortunately I have plenty of spare keyboards, mice, and monitors to choose from.  You will at least need a keyboard, mouse, and monitor for initial boot.  After that you can remotely connect to the Pi eliminating the need for these.  So you probably don't want to buy this hardware for a project, just borrow them from another use for a short while.

Raspberry Pi DVR

Many people have heard of the Raspberry Pi - it's a small low-power computer with a low price tag of $35 (or $25 for the lower model).  The whole idea behind this concept is it's a platform to learn, tweak, and experiment from.  Since they first went on sale 2 years ago I've wanted one, but I've needed a project or idea, something to do with it.  Recently I figure out what that idea is - I want to build a cheap low-power DVR for over the air (OTA) broadcast TV.  With this broad goal in mind I started my research.  Whereas projects with the Raspberry Pi are well documented on the Internet, my experience is any time you're dealing with Linux, unless your setup exactly matches a known working setup then you might run into issues which you need to work through.  Anyway, I wanted to do a series of posts on my blog about my progress towards this goal.  Hopefully if someone else is considering this project with a Raspberry Pi they will find these posts helpful.

First I wanted to elaborate more on my ultimate goal.  Since cutting the cord and dropping cable TV about 7 years ago, my only source of TV is OTA broadcast.  With an antenna I receive 9 channels, and whereas I don't watch much TV, there are a few programs that I enjoy.  The problem is timing, the shows are on at a time when I can't watch.  So I need a simple DVR to record the shows so I can watch them at my convenience.  This is typically called "time-shifting."

The most well-known time-shifting device is the TiVo.  The problem with a device like this is two-fold.  1) they are expensive, especially when you add in monthly fees; and 2) these devices usually require cable and/or satellite TV.  That said, there are a few commercial exceptions.  Channel Master makes a product called the DVR+ which is a DVR designed for OTA broadcast TV.  This device costs even more than a TiVo, but doesn't have monthly fees.  Another interesting product is the HDHomeRun.  This tiny box (with a street price of $100) can record TV shows and stream them to a network drive.  I already have a NAS (network attached storage) device in my house, so this is an enticing product.

In the end, I decided to go with the Raspberry Pi.  In effect I want to create my own version of these devices.  Even through the Raspberry Pi is only $35, this route is by no means cheaper.  When all is said and done, I estimate the hardware to cost about $150 including shipping and tax.  So it's definitely more cost-effective to go with the HDHomeRun.  But that is a single use device, whereas the Pi is a fully functional computer which means you can do more, and it will have more configuration options.  Plus using the Pi is just cool and more fun!  I'm more looking forward to the process of getting this to work than I am in using the end product.  I know that sounds weird, but as an engineer I've always enjoyed the work more than the end result.

Anyway, back to the goal of creating a time-shifting DVR.  My original plan was to mount the Pi with an antenna into an out of the way place like the garage.  The Pi would be headless (no keyboard, mouse, or monitor) so I would control it from another computer.  All the Pi would do is record TV shows of my choosing and save the output to my NAS box.  This was my original goal, but now I'm kicking around some additional ideas.  We have 3 TVs in our house, 2 of which are "smart TVs" but the main TV in the living room isn't.  So I thought if I put the Pi by that TV and connect it to the TV via HDMI, then that Pi could be multipurpose.  In addition to recording TV programs for all the TVs, it would also be a media server for that TV - allowing me to watch both my recorded TV shows as well as the wealth of free streaming content available on the Internet.  As an added bonus, I could use the Pi as an emulator and game station for playing retro video games on the big TV.

So my initial goal is as a headless DVR.  But once that is up and running I'll look at turning the Pi into a full-blown media center.