Sunday, April 22, 2012

My Guruplug + USBLCD

A lot of years ago, I set up a hacked XBox Crystal as a download server, file server and repository. I installed a Gentoo GNU+Linux distro, and I decided not to install X-Windows, because of the low RAM the XBox has (64 MB). The XBox worked great, but due to its low memory, was a bit slow (a lot of HDD thrashing happened) when performing some tasks, like downloading files using aMule daemon, for example. So two years ago, I decided to retire my old XBox to replace it with a Guruplug Server +.

The Guruplug Server + is a nice and small ARM machine. It has a 1,2 GHz CPU, 512 MB RAM, two Gigabit Ethernet ports, WiFi, Bluetooth, an eSata port, two high speed USB host ports, a microSD card reader, etc. The problem with this machine is that it has a flagrant design flaw: The internal heatsink is unable to keep the CPU and memory cool, and this makes the system highly unstable. In my first tests, the system was continuously rebooting even with medium-low CPU loads. This problem was reported to Globalscale (why didn't they discover it anyway?), and in the second batch of Guruplugs, the heatsink was replaced with a tiny and very very noisy fan. The heat problem was solved, but for most users, the noise created a new problem.

To solve the heat problems, I decided to mod my Guruplug. I removed the heatsink, the internal 5V power source (later I used it for The Fonera Plugstrip) and used the hollow it left to add a big heatsink with a silent fan.

The removed tiny heatsink

The removed power source

The heatsink with the fan occupies the space left by the power source

Another capture of the heatsing with the fan
I applied polysynthetic silver thermal compound on the CPU, the RAM chips and the Gigabit Ethernet PHY, and placed the heatsink over them. Then I wired a panel mounted Jack to the 5V input and to the fan power cables. I had to do two holes on the case: a small one for the panel mounted 5V DC Jack, and a big one for the fan. This is the finished mod.

As you can see, the fan has a big air flow input. Ideally, I should have made some more holes to the case, for the air flow output, but it looks like it's not needed, the system works perfect as is, and is very stable (no hangs/reboots in almost two years of work!). To power the entire system, I use a 5V/25W power brick. I could have used a smaller one (maybe 10W are enough), because the entire system drains less than 5W, but as I also have to add a hard disk (about 2,5W more) and maybe some more USB bus powered devices... better safe than sorry.

On the software side, I have built a custom Ångström GNU+Linux distribution. To build the system I have used OpenEmbedded, a set of tools, scripts and configuration files, aimed to build GNU+Linux distributions for embedded systems. OpenEmbedded uses a tool called BitBake for building. BitBake is similar to the Portage tool used in Gentoo distribution, but it is aimed to cross compile for embedded systems.

The Ångström OS image I have built is console based (no X-Windows) and has tools for file serving (samba, ftp, sftp), file sharing (aMule daemon, rtorrent), file downloading (plowshare), and media serving (mediatomb). I have also created some scripts that report specific events to a Twitter account (using OAuth authentication), automagically mount external USB disk drives read only (for unpluging without having to manually unmount them), and share its multimedia contents via mediatomb.

The system works perfect, but I was still missing something: a way to promptly know the system status at a glance, without having to use a computer/smartphone/tablet with a SSH or web client. For that task, I dedided to create USBLCD.

LCD + LEDs + Pushbuttons + USB
USBLCD is just what its somewhat unimaginative name says: A USB board with a LCD. Going into details, it has a 2x12 characters LCD, 6 LEDs, 5 pushbuttons and of course the LCD interface. The heart of the board is a PIC18F4550. There is a small expansion connector to the right of the board, in case I dedide to plug something in (like for example a temperature and humidity sensor). I have defined a simple protocol that allows the host to display whatever it wants in the display and to turn ON and OFF the LEDs. The protocol also defines a way for the USBLCD board to notify the host when a pushbutton is pressed and released.

Guruplug + USBLCD + eSata HDD
A small program running in the host, can display three different screens and switch among them when the user pushes the buttons. The first screen shows the upload and download bit rates, and the disk usage in bytes and %. To the bottom right there is a "spinner" made by cycling the "|/-\" characters. The second screen shows the last file downloaded by plowshare, aMule daemon or rtorrent. The third screen shows mediatomb status and allows to launch and kill it. Just by having a quick look to USBLCD, it's possible to know the system status without the need to launch a SSH client and log in the system. Mission accomplished. If you are interested in making your own USBLCD, or are simply curious, you can get the schematics, gerber files and sources for both the microcontroller and the host here.

BONUS: for the LCD, I have used one without backlight, but the board is also prepared for displays with LED backlight. There is a small mosfet transistor driven by a PWM inside the microcontroller, that can drive LEDs up to 300 mA. I have connected another USBLCD board to a white LED strip and have coded a PWM driver. The firmware allows you to change LED intensity from 0 to 100% in steps of 1%, and it also has a timer that automatically shuts down the light when the count hits 0. Both the remaining time and the LED intensity are shown in the screen. Source files for this function, here.

No comments:

Post a Comment