Repairing bootloader for 3V Trinket using Bus Pirate under L

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
j3gum
 
Posts: 3
Joined: Thu Oct 03, 2013 7:04 pm

Repairing bootloader for 3V Trinket using Bus Pirate under L

Post by j3gum »

Hello,

I managed to mangle my bootloader on a 3V Trinket. My bad, I don't know how, but it WAS me. When looking for a fix I found:
https://learn.adafruit.com/introducing- ... bootloader

There were two problems with that fix. 1) I'm not sure if this is even safe with a 3V Trinket. I don't think so since Uno is 5V and Trinket 3V isn't stated to be 5V tolerant. Oh yes, 2) I don't have a Uno. However, I do have access to a Bus Pirate, http://www.adafruit.com/products/237 , Everyone should!

These are the steps I used to get a firmware image, power the Trinket, then finally repair the bootloader with the Bus Pirate.

This is how I did it. Just because it worked for me doesn't mean I'm tell you it'll work in your circumstance. For all I know, you'll have a pile of goo and burned hands. Don't blame me if that's exactly what you get.

0. Start.

1. Getting the Trinket bootloader binary/hex (this is the hard part)
a. make a place to work:
mkdir ~/trinketloader
cd ~/trinketloader/
b. get the adafruit archive that contains our bootloader:
wget http://learn.adafruit.com/system/assets ... loader.zip
c. unzip trinketloader.zip; cd trinketloader/
d. Use magic to create the hex file:
grep '^":' images.cpp | cut -d'"' -f2 | cut -d'\' -f1 > trinket.hex
The first line should start with:
:20000000
The last line should be:
:00000001FF
If this isn't the case then this step didn't work, DON'T CONTINUE. (or create this file manually from images.cpp, it's pretty obvious)

2. Connect the Bus Pirate to the Trinket (5 connections)

These are in the order of the wires on the Bus Pirate. I'd recommend following this order when connecting to avoid confusing the colors. The color and order reinforce the correct Bus Pirate clips.

Code: Select all

Bus     Bus     Trinket ATtiny85  ATtiny85
Pirate  Pirate  Label   Label     Pin
Color   Label                     Name
------------------------------------------
BROWN   GND     GND     GND       GND
RED     3v3
ORANGE  5v0
YELLOW  ADC
GREEN   Vpu
BLUE    AUX 
VIOLET  CLK     2       SCK       PB2
GREY    MOSI    0       MOSI      PB0
WHITE   CS      RST     RST       RST
BLACK   MISO    1       MISO      PB1
3. Connect the computer USB to the Bus Pirate (mine choose /dev/ttyUSB0, if yours is different, you'll need to change the avrdude lines below)

4. Connect the computer USB to the Trinket (only for power)

5. Wait for a 15 seconds just to be sure we're past any bootloader code remaining in the Trinket.

6. Verify avrdude can see your Trinket via the Bus Pirate:
avrdude -c buspirate -P /dev/ttyUSB0 -p attiny85 -v

7. Program the Trinket via the Bus Pirate:
avrdude -c buspirate -P /dev/ttyUSB0 -p attiny85 -U flash:w:trinket.hex

Success will be indicated by avrdude reporting:
avrdude done. Thank you.

8. Fin.

Best luck!

====
Useful references:
Microcontroller cheat sheet:
http://tinkerlog.com/2009/06/18/microco ... eat-sheet/

Adafruit - Repairing bootloader:
https://learn.adafruit.com/introducing- ... bootloader

Bus Pirate AVR Programming:
http://dangerousprototypes.com/docs/Bus ... rogramming

--
Jeffrey Hundstad

User avatar
adafruit_support_rick
 
Posts: 35092
Joined: Tue Mar 15, 2011 11:42 am

Re: Repairing bootloader for 3V Trinket using Bus Pirate und

Post by adafruit_support_rick »

Thanks for posting this!

User avatar
j3gum
 
Posts: 3
Joined: Thu Oct 03, 2013 7:04 pm

Re: Repairing bootloader for 3V Trinket using Bus Pirate und

Post by j3gum »

Update: I found the Adafruit github repo for the Trinket, it's here, https://github.com/adafruit/Adafruit-Tr ... Bootloader . This really simplifies the worst step from the previous post. Here's the changes:

Replace step 1 (Getting the Trinket bootloader binary/hex):
wget https://github.com/adafruit/Adafruit-Tr ... mma_v1.hex

Replace step 7 (Program the Trinket via the Bus Pirate):
avrdude -c buspirate -P /dev/ttyUSB0 -p attiny85 -U flash:w:trinketgemma_v1.hex

Success will be indicated by avrdude reporting:
avrdude done. Thank you.

--
Jeffrey Hundstad

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”