-
Badge hacking: update
05/12/2017 at 03:00 • 0 commentsAfter a note from [Scott Fish] posting a comment to the hackaday article, I went back and flashed a verified working version of the original badge firmware (properly dumped from a friend's badge) back to my badge.
It seems Scott was having trouble getting the badge to reboot to a bootloader so that it could be overwritten with custom firmware from the Arduino IDE. He was just getting the error:
Connecting to programmer: .avrdude: butterfly_recv(): programmer is not responding
I too ran into the same error via both the Arduino IDE and avrdude command line. This tells me the badge either does not have a bootloader, or something is preventing it from entering the bootloader properly when reset.
This means the only way to write custom firmware to the badge is to first burn the Arduino bootloader to the onboard Atmega32u4. That process requires an external AVR programmer of some sort. I personally used the buspirate. Here are the steps I had to take to get the badge to behave like a regular Arduino Leonardo, programmable via USB.
- Solder a 2x3 male pin header to the badge's ICSP port. This is just above the center pot, with pin 1 being the lower left corner. There is a small _ next to this pin to make it obvious.
- Don't make the mistake I made and try to just hold 6 pins to the pads. This is how I corrupted my firmware to begin with.
- Connect your AVR programmer to the ICSP port
- Open up the Arduino IDE, open the "Tools" menu, and change the following:
- Board: Arduino Leonardo
- Port: [select the COM / tty serial port of your AVR programmer]
- Programmer: [select the type of AVR programmer you have]
- Open up the example "BareMinimum" sketch from the "File > Examples > 01.Basics" sub menu
- Click "Burn Bootloader"
- Once complete, disconnect your AVR programmer and ICSP cable
- Plug the badge in via USB
If everything went well, you should have an Arduino Leonardo show up in your IDE serial port list. Now you should be able to upload my example RGB sketch, or write your own.
Good luck, and I hope this helps clear up any confusion around re-purposing the badge for custom firmware.
-
Badge hacking
05/08/2017 at 01:52 • 0 commentsThe badge can be easily reprogrammed using the Arduino IDE as an "Arduino Leonardo" target. In my case, I accidentally erased the flash of the atmega32u4 while trying to dump the stock firmware, so I used a buspirate as an ISP to burn the arduino bootloader back on to the badge via the broken out ICSP header. After a few rounds of guessing at pin numbers, I mapped all the pot and LED pins out as follows:
Arduino Pin Connected to A2 Left potentiometer A1 Cener potentiometer A0 Right potentiometer 11 Neopixels - The first neopixel (index 0) is the bottom most LED.
- Each pot turned fully counterclockwise provides a value of 1023, and 0 when fully clockwise
I wrote a quick demo sketch where each potentiometer controls the brightness of Red, Green, and Blue respectively. The first 3 LEDs show each individual color brightness and the 4th LED displays all 3 color channels at once, mixing to different colors depending on the brightness of each color channel. The result is showed in the first image in my project gallery. I have shared the code to this sketch on github, also linked from the main project page.