Category: hackery (page 1 of 2)

Controlling an Original Xbox with an Arduino

A few years ago, I used to use an original Xbox as an XBMC box, it recently occurred to me that there was a perfectly good 500GB hard drive sitting in there doing nothing, so I bought a hard drive caddy and decided to salvage it.

It’s not just a case of pulling the old drive out and putting it into the hard drive enclosure, which I found out the hard way. You first have to unlock the Xbox drive, as for some reason, Microsoft decided that they would lock Xbox hard drives using ATA passwords.

This usually means just booting the Xbox, selecting unlock hard drive from the settings menu of your Xbox dashboard and you’re done. However, I didn’t have a controller, or DVD remote to control the menus (both lost somewhere), though my Xbox does still have the DVD IR receiver plugged into the front. I had the IR receiver, but no remote to control it with. No problem.

I took my Arduino Uno, and built a simple circuit with an IR LED and a resistor. Then I installed the excellent IR library for Arduino written by Ken Shirriff, I’ve used this library in a few projects and it’s fantastic.

Now, how to interface with the Xbox? As people with universal remotes will know, you need the IR codes specific to the device you want to control, the LIRC project maintains a database of IR remote codes, so I found their entry for the Xbox here.

The sendRaw function of the IR library takes an unsigned int array of the length of times for the LED to flash on and off, how can we work out what values to put in this array based on the LIRC file?

Ken published an excellent breakdown of the how LIRC files work here, which helped me construct the arrays needed to work some simple commands.

Basically the HEX number in the LIRC file corresponds to a binary string, and at the top of the file it tells what pattern of IR flashes a ‘1’ corresponds to, and what pattern a ‘0’ corresponds to. Start with the ‘header’ values, add the values for the ones and zeros, and finish with the ptrail value. Note that the values in the file seem oddly specific. This is because they’re measured from real remotes, and real IR recievers aren’t ideal. I just rounded the values for easiness sake.

Pretty soon I had a simple Arduino sketch that takes values from the serial monitor and in turn sends the proper code to the LED. It’s not pretty, but it does the trick.

In the very, very off-chance that someone else needs to do something like this, or wants to create a remote control for their Xbox, I’ve added the code below, it only implements Up, Down, Left, Right, Select, Play and Back, but if you need extra buttons, they should be easy to work out based on what’s there already and the LIRC file.

Eventually, after updating my Xboxes ‘dashboard’ software (UnleashX) to the ‘latest’ version (released about 5 years ago) I was able to unlock the hard drive, put it in my new enclosure and reformat it, and done. Brand new old hard drive.

xboxremote.ino

 

Using the Zune HD in Linux

Contrary to a lot of advice on the Internet, the Zune HD can be used in Linux. Support has been integrated into libmtp for the mtpz protocol thanks to some awesome work by Sajid Anwar.

libmtp however, does not and will not contain the encryption keys required, so it will seem like the Zune isn’t recognised. Running mtp-detect on the command line gives


shane@ratbert:~$ mtp-detect
Unable to open ~/.mtpz-data for reading, MTPZ disabled.libmtp version: 1.1.6

Listing raw device(s)
Device 0 (VID=045e and PID=063e) is a Microsoft Zune HD.
Found 1 device(s):
Microsoft: Zune HD (045e:063e) @ bus 1, dev 6

It’s simple to get this to work however.

Just create a file in your home directory called .mtpz-data and add to it the following string of numbers. This is the encryption key needed to interface with the Zune.

Encryption Key

Now, run mtp-detect and you should see the encrypted handshake take place, gmtp, Clementine, Rhythmbox and any media player that supports mtp should now be able to copy music to and from the Zune HD.

Waking up to new Ubuntu

Today Ubuntu 10.10 was released, at 10:10am. Last night I prepared my laptop for a complete reinstall, I took a backup of everything important from both Ubuntu and Windows, and prepared GParted and Windows 7 CD’s.

This took a while, so it was late when I went to bed. That left me with a conundrum, I wanted to install Ubuntu as soon as it came out, but I also wanted to sleep… Hmm..

Read more →

My New Desktop

Since its exam time, of course I’m spending my time doing anything but studying. So, I’ve completely redone my Ubuntu desktop.

Read more →

Handy Songbird Tips – AllTray, MMKeys and ubuntu-notify

I love Songbird, it’s a great music playing program and I’ve been using it since it hit it’s 0.6 release. Anyway, today I discovered 2 cool little things that have made my Songbird experience much better.

Read more →

World Community Grid in Linux – Peer certificate authentication problem

UPDATE – Tyler in the comments notes that this is also a problem in 32 bit versions, so I’ve modified the title accordingly

Last night I performed a fresh install of Ubuntu 9.10. One of the first things I did was to install the BOINC manager so I could continue contributing to the World Community Grid

I fired up the BOINC manager and for some reason, the blasted thing wouldn’t connect and download new jobs. I switched to ‘Advanced View’ and had a look under the ‘Messages’ tab. There was the following error message –

"Scheduler request failed: peer certificate cannot be authenticated with known CA certificates"

What the hell does that mean, well, I found some information on this really helpful site.

The issue appeared to be that the file ca-bundle.crt was not included on the installation of the BOINC software.

So, the instuctions were to download the file, and add it to the BOINC data directory. Where the heck is the BOINC data directory? Well, after a little poking, I found it. This is only an issue if you installed the package from the repositories, otherwise, the data directory is easy to find, as it’s in your home folder.

To fix the problem,

1. Download this file

2. Copy the file to the BOINC data directory,

sudo mv /path/to/the/file/ca-bundle.crt /var/lib/boinc-client

3. Now, to get the client to recognise the new file, you need to stop the daemon, restart it, then restart the manager. If this all sounds like a pain in the arse, just reboot your PC and it will do all this for you. If you don’t want to reboot, run

sudo /etc/init.d/boinc-client restart

Then start the BOINC manager again, you should be up and running.

Build a single kernel module in FreeBSD

This is a simple piece of information that may save some of you some time.

There are a few reasons that you would like to build a single kernel module in FreeBSD, and thankfully it is easy to do.

Firstly, find the module you need.

cd /usr/src/sys/modules/YOURMODULE

Often there will just be one file, a Makefile in these directories. That’s not a problem, just run

make

Now you will be left with a load of files, the one you need is the *.ko one.

To load this onto a running system, use the

kldload

command.

Done and done! To check your work, run

kldstat

mount command different in FreeBSD & Linux

At work I use both Linux and FreeBSD extensively. Recently while going through some old bash scripts trying to make sense of them, I had two terminals open, one for looking through the script and the other for looking up man pages, to decipher command line switches.

This was going fine, until I can across a certain command that just didn’t make sense, the mount command.

The operation was happening at boot up, where a partition was being mounted as the root filesystem.

mount -f -o rw /dev/md0 /

This mounts dev/md0 on /. Sinple enough, the -o option specifies that the partition is to be mounted readable and writable. What about the -f part though.

I switched across to my other terminal, and typed in man mount to have a look for this command switch. According to the man page, go on, check for yourself, this command ‘fakes’ the mount, i.e, does everything except the system call.

manpage linux

manpage linux

This had me puzzled for a while, until I realised that I was looking at the man page for the LINUX implementation of mount,not the FreeBSD implementation, so I ssh’d to a FreeBSD box and had a look and sure enough, I found,

screenshot-shaneshane-work-desktop

Sure enough, the command is different, but what a difference!

In Linux, -f ‘fakes’ a mount, whereas in FreeBSD, it ‘forces’ a mount. Those are two completely different things, you could hypothetically want to check a volatile FS using -f to fake a mount, and then acting based on the return from that, but if you run the command on FreeBSD, it will force the mount, a dangerous thing to do!

So note to self – Linux and FreeBSD are NOT THE SAME…watch out for the subtle differences between even the most fundamental of commands in the two operating systems

Watch out for checksums

I was fiddling around with snort there yesterday, creating new rules and stuff like that. I almost tore my hair out for a while though, thanks to one small problem.

I was looking for HTTP packets, so was searching for “GET” requests, and whatever I tried, the packet, (that I knew was there!) would not show up. After some pouring through man pages, I tried the -k none command line switch, and it began to work.

It seems that the packets’ checksum had failed and because of this, snort was ignoring it. Probably the right thing to do, but its handy to know how to turn it off, and know that it does cause problems.

So instead of

snort -c snort.conf -r traffic.cap -l log

Try

snort -c snort.conf -r traffic.cap -l log -k none

conky

I just set up conky on my Hardy machine, its as simple as can be, a quick “sudo apt-get install conky” did it for me.

The cool thing about it is that you specify exactly how it works, by creating and editing a file in your home directory called .conkyrc , this file is a little hard to understand so you’re better to (like I did) use a pre configured file, I’ll post mine here, along with a screenshot. It makes your desktop look seriously l33t!

.conkyrc

screenshot