Close

Secret Component & Feature: SD Card & BYOB

A project log for AND!XOR DC25 Badge

We're going bigger, better, more Bender.

hyr0nHyr0n 04/27/2017 at 04:292 Comments

So our first technical detail update in a while, but here it is: Micro SD-Card and Bring Your Own Bling (BYOB).

We're starting off a bit EZ on the feature release and a lot of it stems from this one component. So for todays update, lets focus on why SD card and the whimsical magic that is BYOB.

Chalk it up as lessons learned from DC24 to start with. Last year we leveraged NAND which is really easy to work with from a programming perspective, but a complete PITA when it comes to updating resources (configuration, images, etc) because you have to recompile the firmware and flashing in a really annoying way (Just ask Yaakov). Plus we had so many neckbeards ask us at DC24 how they could put their own images on the badge right then, and we had no "easy" answer without custom rolling a dev environment. So to be good software engineers as well as hacker friendly (not typically a good thing, but this is for DC hacking goodness) we made much of our software purely functional, reads specific resources, and parses it via an interpreter function. If you read our CHIP8 update, you would have noticed that each game comes with a config file, thats so when it loads, metadata is appropriately parsed and the menus get filled out.

Security Side Bar: This is for making a "hackable" badge. Keep in mind with real life projects, parsers are the absolute devil for code injection.

BLING works in a similar way. We have a specific folder in which we store the bling files and we added a "custom" bling mode where you can select any raw file on the Micro SD Card, pair it with a pre-made blinky light pattern, and there you go! So if you are just unsatisfied with the 100 preloaded bling modes we will provide, BYOB! Now you cant just drop an animated GIF (pronounced "jiff" or GTFO) because we use RAW format. Without getting super technical (you can f-ing google it there are well written programming articles on this topic), RAW is easier to work with than GIF in terms of overhead, which is great for embedded programming. If we just loaded plain GIFs we would have to put the entire image in memory to play it (which we are extremely limited on). Rather, using RAW format (RAW 16-bit 565 Big Endian uncompressed), we can stream the bits over SPI and straight to the screen. End result: more efficient, better FPS, less overhead, m0@r l337. @Zapp gets IPA tokens for this win. If you have criticisms, make your own embedded system con badge that has a full color screen and can display animations with only 64k of memory where each frame requires 33k of RAM...yeah we're THAT kind of efficient.

So that means to BYOB, you need to convert your files ahead of time. Here's how...

1) Find an animated GIF

2) Crop the GIF to a 1:1 Ratio

Our screen is a square and will convert the final animation to 128x128. Just make sure your crop is relatively "square" or the image will look skewed. There are many websites that will do this, we just use one at GIFGIFs

3) Convert the file to RAW

FFMpeg is your friend. Use it. Because we are going to give you the command line instructions to get this job done. There are GUI programs which do this as well, but...we are hackers. We use Linux. Deal with it. The INPUT.gif is the name of your file, the OUTPUT.RAW is what ffmpeg will save the conversion as. Make sure the filname is 8.3 length (e.g. no more than 8 charachters . RAW)

ffmpeg -i INPUT.gif -r 22 -f rawvideo -s 128x128 -pix_fmt rgb565be OUTPUT.RAW
Below is an example output. You'll see a lot of info from FFMPEG, dont worry thats normal.

4) Mount the SD Card in to your computer and copy the newly created RAW file in to /SDCard/BLING/

.

5) Safely unmount the SD Card, put back in the badge, turn on the badge and go to...

Bling Menu -> Custom Bling

You will find the RAW file you just added alphabetically. Choose it and dance the night away! (forgive the video quality)

That's about it. We have some other features we'll release as the 'con gets closer. Enjoy!

Discussions

int3grate wrote 04/27/2017 at 23:48 point

This is extremely awesome! Can the core firmware be modified via the SD card, or is it being using more for storing auxiliary stuff like games, configs, bling, etc?

  Are you sure? yes | no

Hyr0n wrote 04/28/2017 at 01:45 point

Just for storing auxiliary stuff. The core firmware is updated via 10 Pin SWD.

  Are you sure? yes | no