Guide: how to flash ATtiny13a based drivers (NANJG, QLITE, etc.) with custom firmware

620 posts / 0 new
Last post
goshdogit
goshdogit's picture
Offline
Last seen: 27 min 32 sec ago
Joined: 12/03/2015 - 21:28
Posts: 927

The flash-85.sh file is located in ToyKeeper’s flashlight firmware depository inside the /bin folder. Its avrdude command reads:

Quote:
avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:FILENAME.hex

Change FILENAME.hex to your .hex file’s name.

Note the ‘t85’ option. This sets the chip model to ATtiny85. Your example shows ‘t13’, which is erroneously specifying an ATtiny13.

I mentioned in your other thread that before sending your new firmware, you can test your connection between the ATtiny85 and your programmer with this command:

Quote:
avrdude -p t85 -c usbasp -n

If the connection test is unsuccessful, you may need to fiddle with your clip. I have a cheap one that sometimes needs a couple of tries. Smile

It looks like you’re getting close to a successful reflash. Keep at it, and keep us posted! Thumbs Up

sbslider
sbslider's picture
Online
Last seen: 5 min 36 sec ago
Joined: 01/22/2017 - 13:41
Posts: 1143
Location: United States

goshdogit wrote:
The flash-85.sh file is located in ToyKeeper’s flashlight firmware depository inside the /bin folder. Its avrdude command reads:
Quote:
avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:FILENAME.hex

Change FILENAME.hex to your .hex file’s name.

Note the ‘t85’ option. This sets the chip model to ATtiny85. Your example shows ‘t13’, which is erroneously specifying an ATtiny13.

I mentioned in your other thread that before sending your new firmware, you can test your connection between the ATtiny85 and your programmer with this command:

Quote:
avrdude -p t85 -c usbasp -n

If the connection test is unsuccessful, you may need to fiddle with your clip. I have a cheap one that sometimes needs a couple of tries. Smile

It looks like you’re getting close to a successful reflash. Keep at it, and keep us posted! Thumbs Up


Hey goshdogit, thanks for all your help. I guess I really should have kept all this in one place, it would have helped me keep track of it. Blushing

I was able to connect using the ‘t13’ command, but got some minor errors. using the t85 came out a bit cleaner it seemed. I still get a warning about ‘cannot set sck period. please check usbasp for firmware update’, but the device signature comes out ok and I get the safemode Fuses ok message, much better. Thumbs Up

I have been practicing with a demo board with a t85 chip on it before disassembling my D4. I connected the clip backwards to the demo board yesterday Facepalm but it seems like it survived that.

After a couple of false starts on gettting ‘filename.hex’ correct, it looks like I successfully flashed the demo board. Beer

Next step is my D4 . . .

success!!

PocketSammich wrote: I don’t need this, but I want it. Please sign me up.

goshdogit
goshdogit's picture
Offline
Last seen: 27 min 32 sec ago
Joined: 12/03/2015 - 21:28
Posts: 927

sbslider wrote:
After a couple of false starts on gettting ‘filename.hex’ correct, it looks like I successfully flashed the demo board.
Nice! Party

I put a small dot of silver marker on my clip to mark pin 1’s location, and another on the ATtiny85 chip. It makes it easier to attach the clip correctly.

I get that ‘cannot set sck period’ error, too. I’m not sure what it means, but it doesn’t seem to cause any problems. I’ve flashed over a dozen lights several times without issue. Perhaps someone with more experience can chime in about it.

moderator007
moderator007's picture
Offline
Last seen: 1 hour 6 min ago
Joined: 12/23/2012 - 04:47
Posts: 2929
Location: North Carolina

It’s my understanding that these USBASP boards set SCK automatically and the error is really just a advisory.
Perfectly normal. Just ignore it.

FilipeBanana
FilipeBanana's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 05/11/2018 - 16:13
Posts: 8
Location: Eastern US

After reading this thread, I managed to disassemble my D4 and flash Anduril successfully, but got in a hurry when attempting to flash my Q8 and used the wrong fuse vales Facepalm

The only led that still works is the green button led, and the ATtiny 85 isn’t responding. Any ideas on the best and/or cheapest way to fix this?
From what I’ve read it seems like my only options are either building a high-voltage avr programmer (which I do not think I have the knowledge to do) or get a hold of a completely new Q8 driver…

JasonWW
JasonWW's picture
Offline
Last seen: 2 hours 17 min ago
Joined: 10/22/2016 - 11:41
Posts: 10925
Location: Houston Texas

New drivers are 10 bucks.

BLF Q8 Driver Chip Q8 Circuit Board http://s.aliexpress.com/ZbyUBBBZ

FilipeBanana
FilipeBanana's picture
Offline
Last seen: 2 months 2 weeks ago
Joined: 05/11/2018 - 16:13
Posts: 8
Location: Eastern US

Thanks! One’s on the way, $10 is quite a bit cheaper than I thought a q8 driver would be Thumbs Up

bansuri
Offline
Last seen: 5 hours 8 min ago
Joined: 01/30/2017 - 23:43
Posts: 393
Location: Land of Lincoln

OMG! I CONNECTED!!!!
Cheaped out and bought the pre-wired clip from wherever, have never been able to connect.
Did all of the driver signing stuff with Win10, been at this for a while.
Finally desoldered the wires and did it myself and I just got the most beautiful response to avrdude -p t13 -c usbasp -n

There’s still a lot to be done, but I’m happy to be past that.
Thanks to all who’ve contributed!
Robert

MRsDNF
MRsDNF's picture
Offline
Last seen: 2 days 12 hours ago
Joined: 12/22/2011 - 21:18
Posts: 12921
Location: A light beam away from the missus in the land of Aus.
Smile Beer

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

bansuri wrote:
OMG! I CONNECTED!!!!
Cheaped out and bought the pre-wired clip from wherever, have never been able to connect.
Did all of the driver signing stuff with Win10, been at this for a while.
Finally desoldered the wires and did it myself and I just got the most beautiful response to avrdude -p t13 -c usbasp -n

There’s still a lot to be done, but I’m happy to be past that.
Thanks to all who’ve contributed!
Robert

can you post a picture of your usb setup?

thanks!

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

bansuri
Offline
Last seen: 5 hours 8 min ago
Joined: 01/30/2017 - 23:43
Posts: 393
Location: Land of Lincoln

Man Without Shadow wrote:
bansuri wrote:
OMG! I CONNECTED!!!!
Cheaped out and bought the pre-wired clip from wherever, have never been able to connect.
Did all of the driver signing stuff with Win10, been at this for a while.
Finally desoldered the wires and did it myself and I just got the most beautiful response to avrdude -p t13 -c usbasp -n

There’s still a lot to be done, but I’m happy to be past that.
Thanks to all who’ve contributed!
Robert

can you post a picture of your usb setup?

thanks!

It won’t help much as it’s all covered in heat-shrink, but I’ll explain how I did it.
The one I ordered off ebay is black and has 8 grey wires coming out of it. I peeled back the heat shrink and de-soldered the wires.
I tinned the relevant pins and soldered the colored ribbon cable, matching the colors so there would be no confusion.
Attached the black clips to the USB adapter and it works.

I feel like a script kiddie, I just installed the pre-built Anduril on my D4 and am giddy with excitement!

If my description doesn’t help I’ll post a picture. And I finally broke down and used a USB extension cable as suggested. Little tip, big help. MUCH easier making sure the pins are exactly where they need to be.

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

ya, a picture of colors and wiring would be helpful. as well as the usb device and clip

and links to the parts…

thanks!

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

bansuri
Offline
Last seen: 5 hours 8 min ago
Joined: 01/30/2017 - 23:43
Posts: 393
Location: Land of Lincoln

Man Without Shadow wrote:
ya, a picture of colors and wiring would be helpful. as well as the usb device and clip

and links to the parts…

thanks!

I just clicked on the links provided in the OP. Skip the clips with the cables attached and use the ribbon cable in the fasttech link instead.
It won’t let me copy/paste so just check the Required Hardware section in post #1, that’s what I did.
Of course this method requires some wait time, but there’s plenty to read before starting.
I took the easy way and used preconfigured hex files from toykeeper so I didn’t screw anything up.
I would post a link to that but my damned KVM is messing up and I can’t type on my other computer and I’m shutting my regular computers down now because it’s driving me crazy trying to type.
oh wait, here it is: http://toykeeper.net/torches/fsm/

Well this is ugly but here it is:

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

Thanks!

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

ToyKeeper
ToyKeeper's picture
Online
Last seen: 8 min 42 sec ago
Joined: 01/12/2013 - 14:40
Posts: 9640
Location: (469219) 2016 HO3
Hoop wrote:
The command: avrdude -p t13 -c usbasp -u -e will erase the contents of the chip so that it can be re-written to.

Hoop, could you remove this part? It’s not necessary to erase the chip before flashing, and a couple people reported that erasing it made the chip stop responding entirely. I’d rather not advise people to do something which might brick their hardware.

It’s probably also worth noting somewhere that the t13 part will change depending on the hardware, and tiny85 is pretty popular lately. Tiny13 settings won’t work on tiny85 hardware, and they use totally different fuse values.

lohtse
lohtse's picture
Offline
Last seen: 4 days 23 hours ago
Joined: 05/19/2017 - 04:18
Posts: 300
Location: UK

where is the Atmel Studio???? I can find it at the link in the first post!!!

Caving, Climbing, Mountaineering, Kayaking, Diving etc any time anywhere!!! If you in the UK let me know and lets Play!
Current lighting
Olight X7R,M2R,S1 Baton,S10R Baton 3m,S2R 2, I1R EOS,SofirnC8T,Lenser P7'2,Lenser P14,BLF A6,Fenix HL50,HM50R,HL55,CL05,HL05,CL09,CL25,Nitecore HC30,HC65,NU12,NU30,Astolux K1,Petzl E-light,Tikka Xp3,XP3LED,DUO,Atomlight,Xtar Warboys H3,PL47(on the way) Manker E03H and many Chinese ones

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

lohtse
lohtse's picture
Offline
Last seen: 4 days 23 hours ago
Joined: 05/19/2017 - 04:18
Posts: 300
Location: UK

wow thats a large download!!!!!!!!

ok so web installer allows me to install 3 parts… which one is needed???

Caving, Climbing, Mountaineering, Kayaking, Diving etc any time anywhere!!! If you in the UK let me know and lets Play!
Current lighting
Olight X7R,M2R,S1 Baton,S10R Baton 3m,S2R 2, I1R EOS,SofirnC8T,Lenser P7'2,Lenser P14,BLF A6,Fenix HL50,HM50R,HL55,CL05,HL05,CL09,CL25,Nitecore HC30,HC65,NU12,NU30,Astolux K1,Petzl E-light,Tikka Xp3,XP3LED,DUO,Atomlight,Xtar Warboys H3,PL47(on the way) Manker E03H and many Chinese ones

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

I installed the entire thing, but have only played around with it and not compiled any code. I cannot say what parts are necessary for flashlight purposes, though people only seem to ever talk about the “studio” part of it…

Have fun!

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

I’ve read hundreds of posts and finally successfully flashed. Here is a condensed version of the hardware and software you would need if running a Windows computer (I use Windows 10)…enjoy!

I had some trouble figuring out exactly what to buy, but I figured it out after reading all the posts for months. Just get those three things I linked below for hardware.

I bought this:

https://www.amazon.com/gp/product/B00AX4WQ00/ref=oh_aui_detailpage_o02_s...

and these:

https://www.amazon.com/gp/product/B077×7MKHN/ref=oh_aui_detailpage_o02_...

and this from ebay:

https://www.ebay.com/itm/Black-Programmer-Testing-Clip-SOP8-Pin-SOIC8-DI...

you have to bend the clip pins a bit, but works fine and it’s not 20$!

Picture from Dutcheee:

ya…cheaper from china…but not by much, and I prefer Amazon reliable quick ship. Not worth saving 3 or 4$ ordering from china and waiting a month.

Windows programs: (the first two are direct download links…when you click on them, a download will start…no malware or viruses…I use these myself)

uspasp driver: (direct download)

https://protostack.com.au/download/USBasp-win-driver-x86-x64-v3.0.7.zip

avrdude chip flashing program: (direct download)

https://cytranet.dl.sourceforge.net/project/winavr/WinAVR/20100110/WinAV...

TK’s hex files library:

http://toykeeper.net/torches/fsm/

Please read the previous posts in this thread to learn how to wire the usbasp to the clip and how to use avrdude to flash the chips…I merely wanted to provide quick links to the three hardwares I used and the two softwares I needed.

Thanks to everyone for all the information in this thread and others!

Special holla to ToyKeeper for all of her coding magic and Hoop for all the more detailed info and links!

Hope the above info helps you start flashing UI’s…

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

ryukin2000
ryukin2000's picture
Offline
Last seen: 1 day 23 hours ago
Joined: 04/17/2017 - 15:40
Posts: 132
Location: Calgary, Alberta

Okay just skimmed through all of the posts. Most of it didnt stick. I have a Q8 that wants TK’s candle+lightning mode bad enough that i’m going to try. Ordered parts!

ZozzV6
ZozzV6's picture
Offline
Last seen: 24 min 26 sec ago
Joined: 03/24/2016 - 12:19
Posts: 2246
Location: Near to my soldering iron.

I tried a lot of things and don’t know what is wrong. I get this error message when I testing connection with this command:
avrdude -p t13 -c usbasp -n

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0×1e9108
avrdude: Expected signature for ATtiny13 is 1E 90 07 Double check chip, or use -F to override this check.

avrdude done. Thank you.

Man Without Shadow
Man Without Shadow's picture
Online
Last seen: 4 min 49 sec ago
Joined: 02/20/2017 - 18:17
Posts: 392
Location: Wisconsin

My first thought is you have the chip name wrong. What light are you trying to flash?

Q8 and emisars have attiny85

avrdude -p attiny85 -c usbasp -n

When I'm spending mony foolishly, I like to do it wi$ely...

I have all the flashlights I need, but not as many as I want...

 

goshdogit
goshdogit's picture
Offline
Last seen: 27 min 32 sec ago
Joined: 12/03/2015 - 21:28
Posts: 927

ZozzV6 wrote:
I tried a lot of things and don’t know what is wrong. I get this error message when I testing connection with this command:
avrdude -p t13 -c usbasp -n

avrdude: warning: cannot set sck period. please check for usbasp firmware update.
avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0×1e9108
avrdude: Expected signature for ATtiny13 is 1E 90 07 Double check chip, or use -F to override this check.

avrdude done. Thank you.

After some googling, I think the “0×1e9108” signature indicates an ATtiny25. This page has a list of device signatures.

That means the programmer is detecting an ATtiny25, but you’re specifying an ATtiny13.

Does your driver indeed have an ATtiny25? If so, you’ll want to say:

Quote:
avrdude -p t25 -c usbasp -n
ToyKeeper
ToyKeeper's picture
Online
Last seen: 8 min 42 sec ago
Joined: 01/12/2013 - 14:40
Posts: 9640
Location: (469219) 2016 HO3

If it’s tiny25, make sure to use fuse values which match tiny25 instead of tiny13. They are not the same, and bad fuse values can basically brick the MCU.

You’ll also need firmware compiled for tiny25, because the .hex files aren’t compatible from one to the other. Tiny25 code can be flashed on 45 and 85, because they’re the same family… but tiny13 and tiny25 are different families.

ZozzV6
ZozzV6's picture
Offline
Last seen: 24 min 26 sec ago
Joined: 03/24/2016 - 12:19
Posts: 2246
Location: Near to my soldering iron.

Thank you. It is a stock convoy C8 driver and I think I haven’t touched it so it should be tiny13. I will look at it tomorrow morning because now I’m at work. Maybe I mixed up my drivers and that answers everything.

ryukin2000
ryukin2000's picture
Offline
Last seen: 1 day 23 hours ago
Joined: 04/17/2017 - 15:40
Posts: 132
Location: Calgary, Alberta

FilipeBanana wrote:
After reading this thread, I managed to disassemble my D4 and flash Anduril successfully, but got in a hurry when attempting to flash my Q8 and used the wrong fuse vales Facepalm

The only led that still works is the green button led, and the ATtiny 85 isn’t responding. Any ideas on the best and/or cheapest way to fix this?
From what I’ve read it seems like my only options are either building a high-voltage avr programmer (which I do not think I have the knowledge to do) or get a hold of a completely new Q8 driver…

I just did the same thing! guess i need to order another driver. for my next attempt is this the correct command?

avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:BLFQ8.hex

staticx57
Offline
Last seen: 9 hours 40 min ago
Joined: 04/11/2016 - 00:43
Posts: 636
Location: New Jersey, United States

ryukin2000 wrote:
FilipeBanana wrote:
After reading this thread, I managed to disassemble my D4 and flash Anduril successfully, but got in a hurry when attempting to flash my Q8 and used the wrong fuse vales Facepalm

The only led that still works is the green button led, and the ATtiny 85 isn’t responding. Any ideas on the best and/or cheapest way to fix this?
From what I’ve read it seems like my only options are either building a high-voltage avr programmer (which I do not think I have the knowledge to do) or get a hold of a completely new Q8 driver…

I just did the same thing! guess i need to order another driver. for my next attempt is this the correct command?

avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:BLFQ8.hex

The cheapest option is to just order a single new attiny85 and change it out on the existing driver.

Here are the flash commands I use for 25 and 85

ATTINY 25: avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:Bistro-HD-Triple.hex

ATTINY 85: avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:ProjectLunasolv3.hex

ryukin2000
ryukin2000's picture
Offline
Last seen: 1 day 23 hours ago
Joined: 04/17/2017 - 15:40
Posts: 132
Location: Calgary, Alberta

staticx57 wrote:

The cheapest option is to just order a single new attiny85 and change it out on the existing driver.

Here are the flash commands I use for 25 and 85

ATTINY 25: avrdude -c usbasp -p t25 -u -U lfuse:w:0xd2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:Bistro-HD-Triple.hex

ATTINY 85: avrdude -c usbasp -p t85 -u -U lfuse:w:0xe2:m -U hfuse:w:0xdf:m -U efuse:w:0xff:m -Uflash:w:ProjectLunasolv3.hex

Thanks for another option. Id hate to replace the rest of the driver. Plus im only ok at soldering

ToyKeeper
ToyKeeper's picture
Online
Last seen: 8 min 42 sec ago
Joined: 01/12/2013 - 14:40
Posts: 9640
Location: (469219) 2016 HO3

FWIW, the repository’s bin/ directory has scripts to flash tiny13, tiny25, and tiny85. I recommend using those scripts instead of running avrdude directly, because the scripts are much less likely to brick anything.

Pages