[Sprite_TM]’s Keyboard Plays Snake

Hackaday Prize judge, hacker extraordinaire, and generally awesome dude [Sprite_TM] spends a lot of time at his computer, and that means a lot of time typing on his keyboard. He recently picked up a board with the latest fad in the world of keyboards, a board with individually addressable LEDs. He took this board to work and a colleague jokingly said, ‘You’ve had this keyboard for 24 hours now, and it has a bunch of LEDs and some arrow keys. I’m disappointed you haven’t got Snake running on it yet.” Thus began the quest to put the one game found on all Nokia phones on a keyboard.

The keyboard in question is a Coolermaster Quickfire Rapid-I, a board that’s marketed as having an ARM Cortex CPU. Pulling apart the board, [Sprite] found a bunch of MX Browns, some LEDs, and a 72MHz ARM Cortex-M3 with 127k of Flash and 32k of RAM. That’s an incredible amount of processing power for a keyboard, and after finding the SWD port, [Sprite] attempted to dump the Flash. The security bit was set. There was another way, however.

Coolermaster is actively working on the firmware, killing bugs, adding lighting modes, and putting all these updates on their website. The firmware updater is distributed as an executable with US and EU versions; the EU version has another key. Figuring the only difference between these versions would be the firmware itself, [Sprite] got his hands on both versions, did a binary diff, and found only one 16k block of data at the end of the file was different. There’s the firmware. It was XOR encrypted, but that’s obvious if you know what to look for.

flashdata The firmware wasn’t complete, though; there were jumps to places outside the code [Sprite] had and a large block looked corrupted. There’s another thing you can do with an executable file: run it. With USBPcap running in the background while executing the firmware updater, [Sprite] could read exactly what was happening when the keyboard was updating. With a small executable that gets around the weirdness of the updater, [Sprite] had a backup copy of the keyboard’s firmware. Even if he bricked the keyboard, he could always bring it back to a stock state. It was time to program Snake.

The first part of writing new firmware was finding a place that had some Flash and RAM to store the new code. This wasn’t hard; there was 64k of Flash free and 28K of unused RAM. The calls to the Snake routine were modified from the variables the original firmware had. If, for example, the original keyboard had a call to change the PWM, [Sprite] could change that to the Snake routine.

Snake is fun, but with a huge, powerful ARM in a device that people will just plug into their keyboard, there’s a lot more you can do with a hacked keyboard. Keyloggers and a BadUSB are extremely possible, especially with firmware that can be updated from a computer. To counter that, [Sprite] added the requirement for a physical condition in order to enter Flash mode. Now, the firmware will only update for about 10 seconds after pressing the fn+f key combination.

There’s more to playing Snake on a keyboard; Sprite has also written a new lighting mode, a fluid simulation thingy that will surely annoy anyone who can’t touch type. You can see the videos of that below.

22 thoughts on “[Sprite_TM]’s Keyboard Plays Snake

    1. No. That was lost. Unfortunately, I was the only one doing video/content from the Munich party. I was overextended, and honestly doing the web content from the Munich party is one of the biggest embarrassments of my life. Really, really amateur stuff going on.

      I know for a fact we lost views and therefore ad revenue because of our inability to properly plan this, so the people who are in charge of this have been made aware.

      I do have the last half of Sprite’s talk, so if anyone out there has the first half, I’ll be more than happy to put something together.

      1. Sorry for more nagging about the layout.

        But: There is no direct link to older entries on the front page anymore. You need two clicks to reach entries of only a two days ago, and there is a very limited number of stories on the front page. This could also contribute to lost views.

        1. The whole damn thing is screwy. I’m glad they gave it a shot and it looks nice (sort of), but I miss the old site. I mean, who actually thinks putting the photo above the headline is a good idea? Lemme guess, your new “UX” guy?

          1. I have to agree, the old site was better IMO. It could be that I don’t adapt to change as well as some people but I miss having everything right there, in chronological order where if I miss a day I can just continue through until I get caught up.

        1. am i being trolled here? k, i’ll try again.

          oh hi JD! welcome to hackaday! this website features projects found on the web that generally fit into the category of “hacking” (or sometimes just building) things. one commonly accepted definition for “hacking” is “using things in a way in which they weren’t intended to be used.” many people enjoy engaging in such activities not merely for the end result, but for the experience of taking something apart and figuring out how it works. a deep understanding of a thing is usually required before one is able to take control over it and make it do something new. gaining such mastery can elicit a sense of accomplishment, pride, even awe at the cleverness of the thing being hacked. perhaps you have felt similar feelings in life — what do you enjoy learning about? what do you strive to deeply understand? if you wanted to make your keyboard play snake, would you know how? if not, where would you start looking for information? how much do you imagine you’d learn about electronics, signals, and mathematics in the process?

          i hope reflecting on such questions will help you realize a bit of empathy for the person who engaged in this project. and next time you see someone spend time on something that you don’t understand, i suggest you ask about it with a less judgmental tone. it just might elicit a positive conversation from which all parties can learn something.

          thanks for your participation here, and again, welcome to hackaday! i hope you enjoy spending your time here!

          (how’s that?)

  1. Great hack. Exactly what you have to do with this keyboard.
    I don’t like the “gamer-stuff” but this one actually looks pretty good and with the arm cpu there are many possibilities to do other stuff.

  2. Really nice hack, too bad there’s no first part in the videos. I have exactly the same keyboard. BTW the light in one of the keys is already shot after only a couple of months of not really too active usage. Granted, I tend to keep it with all lights on.

    1. Keeping the lights on shouldn’t matter, they’re not light bulbs, LEDs don’t burn out. I’d guess it’s a mechanical problem. Dunno how the LEDs and keys are all connected together, but on something with that many connections I’d guess a connection has gone. Might be able to fix it if you opened it up. Then again you might end up with 150 pieces of expensive keyboard, depends how good you are at fixing stuff. It’s probably just a solder joint needs redoing.

Leave a Reply to mziwiskyCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.