#Badgelife, AND!XOR, DEF CON, Eagle, EFM8, EFM8SB, EFM8SB10F2G-A-QFN20, Joe Grand, MacroFab, MEP, SAO, Tag-Connect, TC2030
Engineering

MacroFab Engineering Podcast DEF CON 26 Badge Design

DEF CON is one of the largest conferences for computer security, hackers, hardware, and software in the world. Ever since DEF CON 14 where Joe Grand designed the first official electronic DEF CON badge (find out more about that story on MEP EP#73), there has been an increase in “unofficial” electronic DEF CON badges. This has been come to be known as the #badgelife movement. In recent years, the unofficial DEF CON badges has grown to the point where even the badges are getting badges which spawned the creation of the Defcon 26 Shitty Add-Ons Standard, also known as SAO’s. Stephen (co-host of the MacroFab Engineering Podcast) and I interviewed the AND!XOR team in MEP EP#109 and the AND!XOR team convinced Stephen and I to create our own DEF CON badge. Due to time constraints and general procrastination, I dialed the scope of the badge project down to build a MEP based SAO.

The majority of SAO’s are just PCBs with some silkscreen art and a pair LEDs. I wanted to design and manufacture something a little bit beyond that so I decided to implement an EFM8 MCU to control several LEDs and blink them in a pleasing way. The PCB also needed to be small and replicate the shape of the MacroFab Engineering Podcast Logo.

MacroFab Engineering Podcast Logo to be replicated into PCB form.

MacroFab Engineering Podcast Logo to be replicated into PCB form.

 

Schematic and Hardware Design

Due to my short time frame to design, program, and test this project I went with a MCU that I have used before, the EFM8SB10F2G-A-QFN20 which I used on the MacroWatch V2. The EFM8SB only needs a pullup on the reset line and two power filtering capacitors to function. I will be using the internal 20MHz oscillator which frees up two of the I/O pins for more LED blinking goodness.

Each LED was setup to pull about 8mA off of the 3.3V supply from the EFM8SB I/O directly. Some of the EFM8SB I/O drive multiple LEDs which used a proportionally smaller resistor to drop less current. This might not be the ideal setup in terms of driving the LEDs but will be acceptable for the purpose of this project. Ideally a proper LED driver would be nice to implement but the PCB ended up not having enough space to implement one.

For programming I knew I wanted to implement a Tag Connect connector to decrease the Bill of Materials cost and Assembly Labor by removing the programming connector. Lastly the SAO connector was implemented by using two 1×2 through hole headers so I did not have to create a 2×2 header design.

 

Schematic for the MEP SAO REV1 for DEF CON 26.

Schematic for the MEP SAO REV1 for DEF CON 26.

 

To speed up the prototyping process and insure I received the prototypes before the closing deadline of DEF CON, I made sure the design would fall under the requirements of MacroFab’s 10-Day Prototyping Service.

Layout Design

The first step was to create the outline of the logo with the dimension layer in Eagle. Eagle has a few different ways to import graphics; DXF, SVG, and bitmaps. I tried importing the MEP logo with the SVG importer but got less then spectacular results as the SVG importer does not seem to handle polygon fills or something similar. Next I tried using Inkscape to export the SVG of the MEP logo into a DXF. I have had success with importing and exporting DXFs into Eagle in the past and was hoping this would work. However, I ran into similar issues with converting the SVG to a DXF.

MEP Logo converted to a black and white image for importing into Eagle.

MEP Logo converted to a black and white image for importing into Eagle.

 

The way I ended up making the outline was to import the bitmap of the MEP logo into a document layer in Eagle and then I traced it with the dimension layer. The reason I did the tracing instead of importing the bitmap directly into the dimension layer is due to how Eagle draws bitmaps. Bitmaps are a raster based image and Eagle also draws it in a raster format. This creates a dimension line that is made up of lots of horizontal lines instead of a continuous line which can cause problems for PCB manufactures.

Stephens Tank logo is a good example the rastered nature of importing a bitmap into Eagle.

Stephens Tank logo is a good example the rastered nature of importing a bitmap into Eagle.

 

After the outline/dimension layer was complete I put all the electronics on the back besides the LEDs. I did not want any parts on the front to reduce clutter. Around this time I decided to reduce the number of vias as well to reduce the number of visible holes through the board. I ended up putting the vias that connect the MCU to the LEDs under the LEDs to reduce their visibility. Lastly, I added some decorative silkscreen and removed some soldermask in some key areas. Removing the soldermask exposes the copper which the PCB house will then plate with the gold ENIG finish which increases the badges bling factor.

MEP SAO PCB Layout. Front side on left. Rear side on right.

MEP SAO PCB Layout. Front side on left. Rear side on right.

Software

Software was pretty straightforward since the only thing this SAO does is drive LEDs in blinking patterns. The software is driven by the timer0 interrupt which is configured to fire every 1 millisecond. In the timer0 interrupt a global variable called “mS_counter” gets incremented and then the global variable “LED_OUTPUT” updates all the LED I/O states. Lastely the timer0 interrupt flag gets cleared.

SI_INTERRUPT (TIMER0_ISR, TIMER0_IRQn)
{
mS_counter++;

LED_D1 = LED_OUTPUT & 0x0001;
LED_D2 = LED_OUTPUT & 0x0002;
LED_D3 = LED_OUTPUT & 0x0004;
LED_D4 = LED_OUTPUT & 0x0008;
LED_D5 = LED_OUTPUT & 0x0010;
LED_D6 = LED_OUTPUT & 0x0020;
LED_D7 = LED_OUTPUT & 0x0040;
LED_D8 = LED_OUTPUT & 0x0080;
LED_D9 = LED_OUTPUT & 0x0100;
LED_D10 = LED_OUTPUT & 0x0200;
LED_D13 = LED_OUTPUT & 0x0400;
LED_D11_D12_D17 = LED_OUTPUT & 0x0800;
LED_D14_D15_D16 = LED_OUTPUT & 0x1000;
LED_D18_D19_D20_D21 = LED_OUTPUT & 0x2000;
LED_D22_D23 = LED_OUTPUT & 0x4000;

TCON_TF0 = 0;
}

In the main loop, the software just goes through different patterns that are preprogrammed. The delay_ms function just looks that the “mS_counter” variable to see how many cycles it needs to throw away. Setting the “LED_OUTPUT” will drive the I/O on the next timer0 interrupt.

void delay_ms(int milliseconds)
{
milliseconds = milliseconds + mS_counter;
while((milliseconds != mS_counter) || (milliseconds > mS_counter));
return;
}

Getting it Built

I uploaded the Eagle .BRD file to the MacroFab PCB interface and checked out the render. Looked great! Since I used the MPN and POPULATE flags for my part attributes in Eagle the Bill of Materials tool was automatically filled out correctly. Then I ordered the first prototype.

MEP SAO render in the MacroFab PCB Interface.

MEP SAO render in the MacroFab PCB Interface.

 

After 10 days the prototype arrived on my desk and it turned out much better then I would have thought!

Fully assembled MEP SAO PCB!

Fully assembled MEP SAO PCB!

 

To program the MEP SAO, I used the same setup I wrote about in my article about Getting Blinky going for EFM8. I pressed the Tag Connect into the contacts on the MEP SAO board and used the TC2030-CLIP to hold the cable in place.

Tag Connect cable secured using the TC2030-CLIP.

Tag Connect cable secured using the TC2030-CLIP. Front side of the MEP SAO.

 

Tag Connect cable secured using the TC2030-CLIP.

Tag Connect cable secured using the TC2030-CLIP. Back side of the MEP SAO

After some testing with the software I was able to get the LEDs to blink! Success!

I then programmed in some simple blinking patterns.

Recap

The files to make your own MEP SAO can be found in the MacroFab github repository! Completely open source. Feel free to make a pull request if you want to add more blinking patterns to the code. I have seen a couple of our MacroFab Engineering Podcast listeners make some of these already and use them on their badges! If you see these in the wild let me know on twitter or on our Slack Channel!

Next year I would like to expand the SAO to use the I2C bus that is available and move to RGB LEDs to increase the bling factor. Making the SAO interactive will be the primary goal for DEF CON 27 and of course add a bagel pin.