Hardware

Raspberry Pi & PHP & Swift

I may have mentioned in previous posts that I’m working on a PHP port of my MonoPi and jsRPi frameworks for the Raspberry.  The project is WELL underway and a great deal of progress has been made. The core and some of the extensions are already done and I’m now beginning work on the “Components” and “Devices” portions of the framework.  Also, I just read a really interesting article about getting Apple’s Swift compiler running on the Raspberry Pi 2 (will also work on the Pi 3).  I’ve been wanting to try out Swift for a while now but none of my Macs are new enough to run new enough versions of XCode to get the Swift toolchain.  However, Apple recently open-sourced Swift, and luckily plenty of people have already gotten to work porting it to other platforms such as Linux and now there is a working port for the ARM7 architecture under Linux.

This pleases me.

One of the things the article mentions is a need for libraries that allow access to Raspberry Pi hardware such as GPIOs….

Well… As you can imagine, this is a bit like the perfect storm for me.  I get to learn and code in Swift *and* port my framework to Swift at the same time. Boom. So now how am I going to go about this?  Well since I can’t really use my Mac for the dev work, I *can* use my PC running Linux and thankfully this fella built an Atom addon for Swift dev and debug that I can use for exactly that. I am so excited I can barely stand it.  Now I gotta hurry up and get this damn PHP port done so I can start on it.

 

UPDATE: Turns out you can do unit testing in Swift under Linux too.  Apparently, Apple also open-sourced XCTest.

Wednesday, April 6th, 2016 Hardware, PHP, Programming, Raspberry Pi, Swift No Comments

CyrusBuiltHTPC v2.0 Released!

I’m happy to announce that the new version CyrusBuiltHTPC has just been released.  Version 2 is an extensive overhaul that fixes the ATX PMU firmware, upgrades from XBMC to Kodi and if you are still running Raspbian “Wheezy”, the setup scripts will upgrade you to Raspbian “Jessie” (Kodi v15.x works best on Jessie).  This build of Kodi fixes the “Black Screen” issue that would occur when exiting Kodi.

Wednesday, December 2nd, 2015 Arduino, C/C++, Hardware, Programming, Raspberry Pi No Comments

CyrusBuiltHTPC Update

I’ve finally released a new build of CyrusBuiltHTPC for Raspian Linux.  This new build will install the latest XBMC (12.2 “Frodo”) and configure your Raspberry Pi as a full-fledged HTPC with the following features:

1) AirPlay support
2) TVHeadEnd support
3) libCEC support, so you can control it using your TV’s remote.
4) Support for relocating rootfs to an EXT4-formatted USB HDD.
5) A ~60% reduction in overall CPU usage.
6) Support for the DS1307 Real-Time Clock.
7) XBMC can now be updated just like any other package in the system via “apt-get update” or using the “systemupdate” tool installed with CyrusBuiltHTPC.
8) Reduced memory usage footprint to ~40MB on average.

NOTE:  This has only been tested with the Raspberry Pi Revision 2 Model B.  IT HAS NOT BEEN TESTED ON PREVIOUS RASPBERRY PIs AND LIKELY WILL NOT FUNCTION CORRECTLY.

This build makes use of the pre-compiled DEB packages built and maintained by Michael Gorven (cocooncrash).

Usage instructions:

Once you’ve pulled down the source package, navigate to the CyrusBuiltHTPC/CyrusBuiltHTPC folder in the terminal and then type “chmod +rx remote_install.sh”.  If you have not already done so, enable the SSH daemon on your Pi.  Then run “./remote_install.sh” in the terminal and follow the prompts.  This will push the CyrusBuiltHTPC package to the home folder of the Pi user (or whichever user you specified).

On the Pi, navigate to ~/CyrusBuiltHTPC in the terminal and type “chmod +rx setup.sh” and then run it “./setup.sh”.  This will make all the necessary scripts executable and install some system tools.  You can now run commands like “systemreboot” to reboot the Pi immediately or “systemshutdown” to gracefully power off, or “systemupdate” to upgrade and update the system.  You can also backup and restore the system configuration files modified by CyrusBuiltHTPC setup.  To proceed with installing XBMC do “cd ~/CyrusBuiltHTPC/xbmc_install” and then “./get_and_install_xbmc.sh” from the terminal.  This will add Michael Gorven’s APT repo for XBMC and then pull down XBMC and any necessary dependencies and install it all.

Once finished, you will be prompted to run the platform configuration utility.  This will install RTC support, some additional tools, configure XBMC to auto-start on boot, grant the authority to XBMC to shutdown and reboot the system, and give you the option to relocate rootfs.  This will also overclock the system to 800MHz and set the memory slice to 128MB/384MB.  As prompted, you will need to reboot the system for the configuration changes to take effect.  If you chose not to run the platform configuration utility, make sure you are not booted into desktop mode (pure console, not running X11/Xorg), and run “xbmc-rpi” to launch XBMC.  The xbmc-rpi script will store the current terminal settings before launching XBMC and then restore the terminal when XBMC quits so you are left with a black screen afterward.

I plan to make this available as a custom distribution of Raspbian in the form a disk image that you can just plop onto an SD card and go with.  But this will be a little ways down the road.  Hop on over to my GitHub page to get the latest CyrusBuiltHTPC stuff.

Enjoy!

Tuesday, June 18th, 2013 Arduino, Hardware, Programming, Raspberry Pi No Comments

HTPC Pt 3

USB-to-SATA adapter and 250GB Hitachi HDD.  Relocated rootfs to the HDD to eliminate writes and reduce reads from the SD card. The SD card is only used for bootstrap, and then hands off to the HDD.

USB-to-SATA adapter and 250GB Hitachi HDD. Relocated rootfs to the HDD to eliminate writes and reduce reads from the SD card. The SD card is only used for bootstrap, and then hands off to the HDD.

 

Raspbian up and running on the HTPC.  Once I work out on the compilation issues with XBMC 12.1, I'll post pics of that too.

Raspbian up and running on the HTPC. Once I work out on the compilation issues with XBMC 12.1, I’ll post pics of that too.

 

And there you have it.  A fully-functional HTPC (connected via HDMI to a 1080P HDTV) that also works as a full-blown Linux desktop.  CEC is also working, so if the TV is off with the HTPC turns on, the TV will turn on and switch to that input.  Likewise, XBMC can be controlled using the TV remote because the TV essentially becomes a peripheral of the HTPC via libCEC.  Thanks to my PMU, it behaves much like a PC would in the sense of power on/off, reset, auto-off on shutdown, etc.  The only thing it does not do yet is power on via remote control (…. yet).

Sunday, May 5th, 2013 Arduino, Hardware, Raspberry Pi No Comments

HTPC Pt 2

The Raspberry Pi (Model B., revision 2). The brown & black wires go to the RPi reset, and the colored cable goes to the RTC. The purple wire is for shutdown detection.

The Raspberry Pi (Model B., revision 2). The brown & black wires go to the RPi reset, and the colored cable goes to the RTC. The purple wire is for shutdown detection.

 

Better shot of the Pi with the 2-pin header added to the board for reset.

Better shot of the Pi with the 2-pin header added to the board for reset.

The DS1307-based Real-Time Clock (RTC) from Adafruit (http://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/overview)

The DS1307-based Real-Time Clock (RTC) from Adafruit (http://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/overview)

 

The DC-to-DC ATX power supply. The connector was removed and the wires fed into a terminal block for easier wiring. The PMU is powered off the +5V standby lead from PSU (purple lead) and the green wire is the ATX trigger.

The DC-to-DC ATX power supply. The connector was removed and the wires fed into a terminal block for easier wiring. The PMU is powered off the +5V standby lead from PSU (purple lead) and the green wire is the ATX trigger.

Wireless keyboard/mouse combo.  TV remote shown for size comparison.

Wireless keyboard/mouse combo. TV remote shown for size comparison.

 

 

Sunday, May 5th, 2013 Arduino, Hardware, Raspberry Pi No Comments

HTPC

I finally got around to taking some photos of my HTPC.

Here it is fully assembled in its Mini-ITX chassis

Here it is fully assembled in its Mini-ITX chassis

 

And here is the front bezel of the chassis (Power button w/LED, HDD LED, reset button - the big red one)

And here is the front bezel of the chassis (Power button w/LED, HDD LED, reset button – the big red one)

With the top off. Top tray holds the HDD.

With the top off. Top tray holds the HDD.

 

And here's all the guts. The middle board is the PMU I designed. It is controlled by the blue Arduino Micro on board.

And here’s all the guts. The middle board is the PMU I designed. It is controlled by the blue Arduino Micro on board.

 

Close-up of the PMU. The green terminal block on the right is power input. The block up top is the switched power (to RPi and HDD).

Close-up of the PMU. The green terminal block on the right is power input. The block up top is the switched power (to RPi and HDD).

 

Sunday, May 5th, 2013 Arduino, Hardware, Raspberry Pi No Comments

Arduinos!!

Ok, so I’ve been playing with a couple of Arduinos for a while now.  I love these things…. soooo many possibilities.  I used to use the Parallax BASIC Stamp 2P24 for similar purposes, but quite frankly, they are just too expensive to compete with the Arduino (or Raspberry PI for that matter).  Plus, I don’t really care for the PBasic programming language either. The Arduino essentially uses C/C++ and the libraries are extensive.

Anyway, I bought 2 of these guys.  I started with an Arduino Uno and did some experiments and prototyping with it.  After playing around I had a cool idea….. remember when I said I got a Raspberry PI a while back?  Well, I had decided to build an HTPC using the PI, a Mini-ITX chassis w/power supply, an RTC (real-time clock), and some other goodies.  I found that Raspberry Pi + Raspbian + XBMC (Xbox Media Center) = One badass HTPC.  I mostly stream video from my TVersity server, but I also added a 250GB 2.5″ SATA HDD using a USB-to-SATA adapter.  The power supply that came with Mini-ITX chassis is more than ample considering the Pi only uses 5V @ 0.5A DC.  The bulk of the power consumption is spent on the HDD.  I also got a SWEET mini wireless keyboard/mouse combo so I can work the whole thing while sittin across the room in bed.  I can even surf the web!

Caveats:
1) There is a lot of work to getting XBMC compiled and installed on Raspbian.  There are pre-built images that have a stripped-down OS based on Raspbian with XBMC already integrated as a self-contained HTPC OS.  They were great, but did not support I2C or the DS1307 (both needed for the RTC module), nor did it have adequate support for my USB-to-SATA controller.  I found it best to just build XMBC on top of Raspbian and then customize the whole thing as needed.

2) Power.  The Mini-ITX chassis uses an ATX-style power supply.  It also has power and reset buttons, as well as power indicator LED in the front bezel just as you’d expect from any other PC.  The problem is this:  The Pi does not behave like an ATX-class PC.  You can soft-off through the OS, but it does not power off the board.  You have to disconnect and then reconnect the power in order to get it to boot up again.  However, there are 2 solder pads on the Pi used for reset.  So then I got the idea:  I could build a PMU (power management unit) using an Arduino!!

As it turns out, the ATX specification has a 5V standby pin (purple wire) that is always on as long as it has power.  This is what keeps certain functions of your motherboard alive so it can monitor power button presses, which then tells the power supply to turn on by driving the trigger pin (green wire) low, or in other words, ties it to ground.  So my thought was to use the Arduino to sense power and reset buttons and then drive relays to to control them.

But that is where I ran into problems.  I started off trying to use an ATtiny85 and just program it using my Arduino Uno as an ISP, but that didn’t work out because I couldn’t get the damn thing programmed.  I eventually gave up and bought an Arduino Micro from AdaFruit.  Not as cheap as the ATtiny85, but far more versatile and a breeze to program.  Plus it supported a greater instruction set, which I ended up needing anyway.

Then I ran into another problem:  Power draw.  The Arduino Micro, plus LED and a couple of relays is just too much power draw from the 5V standby pin.  I did not have sufficient power to run the whole circuit.  So, plan B: tie the trigger pin low leaving the ATX supply on full-time (or while it to a switch for hard-disconnect).  Then I can use the full 12V and 5V rails from the ATX supply.  The only thing is, I had to add a third relay.  The relay assignments are as follows:

Relay 1 = Reset switch.
Relay 2 = 5V power switch for Raspberry Pi and HDD.
Relay 3 = 12V power switch for HDD.

So the basic operation is simple:

Power button press (momentary):
Power currently on? no-> turn on LED and Relays 2 and 3. Otherwise, turn them all off.

Reset button press (momentary):
Power currently on? yes->turn off LED and turn on Relay 1. Do not switch states back until button release. During this time, ignore power button presses; Otherwise, do nothing.

This was actually quite effective.  The prototyping phase is done.  I just need to start soldering this stuff to the PCB!!  I’ll be posting schematics, source code, etc to github as soon as I get everything put together and tested.

Tuesday, February 12th, 2013 Arduino, C/C++, Hardware, Programming, Raspberry Pi No Comments