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

This is a short “quickstart” guide on how to flash drivers that use the ATtiny13a MCU such as Qlite, AK-47, 105a/c/d, etc. Flashing drivers that have an ATtiny25/45/85 is similar but the “fuses” and firmware will be specific to the MCU being used.

References and relevant links:
http://flashlightwiki.com/AVR_Drivers
USBASP V2.0 user guide
ATtiny13a datasheet
Flashlight Firmware Repository by ToyKeeper
Attiny25/45/85 FW Development Thread
BLF A6 FET+7135 Light Troubleshooting and Mod thread
STAR Firmware by JonnyC - Source Code and Explanation
howto: Use Atmel (Microchip) AVR Studio 5 to make a .hex file
howto: flash ATtiny with AVRDude and command prompt

Required hardware:
USBasp V2.0 programmer (ebay)
Pomona 5250 SOIC clip (Digi-Key, Mouser) (Cheaper alternative. See post #167)
40-pin Splittable Ribbon Cable (20cm) (Ebay, FastTech)
USB extension cable (optional but helpful) (EBAY)

Required software:
Microchip Studio
AVR Tools (download page)
USBasp driver for Windows

THE PROCESS:

Step 1) Wire the Pomona 5250 SOIC clip and USBASP V2.0 properly:
Here’s a “coloring by numbers example.” Put the wires straight across like this:

The USBasp V2.0 should correspondingly be wired like so:

What these wires are, functionally, is detailed on the flashlight wiki and in the USBasp V2.0 users guide.

1) MOSI
2) VCC
3) GND
4) TCK
5) RESET
6) RXD
7) SCK
8) GND
9) MISO
10) GROUND

The pins of the Microchip ATtiny13A chip itself on the driver are as follows:
1) RESET
2) INP
3) INP
4) GROUND
5) MOSI
6) MISO
7) SCK
8) VCC

(Image credit: flashlightwiki.com)

Step 2) Install USBasp V2.0 driver:
Available here. If you have trouble with installation, refer to the USBasp V2.0 user guide.
Extract the zip contents to a folder on the desktop or elsewhere. Plug the USBasp device into your computer. It may or may not install properly on its own. In Windows, bring up the device manager. If you see the USBasp device with a triangle notation. Right click on it, click update driver software, and then select “browse for the driver manually.” Select the folder where you put the .zip contents. It should then install properly.

Step 3) Install the necessary software:
Install AVR Tools.
Install Microchip Studio.

Step 4) Acquire firmware:
ToyKeeper has created the flashlight firmware repository where pretty much all relevant firmware is located and kept current. Refer to the INDEX to see descriptions of most of the available firmwares, though not all of the firmwares in the repository are listed in the index; there are a few hidden gems in there. Firmwares are grouped into folders by author, then by firmware title. Refer to the META files for information. Note that not all firmware in the repository is for the ATtiny13a.

Most of the custom firmwares come as a .c file, which can be opened with wordpad or Microchip Studio and read as text so that we may edit the code. Ultimately we need a .hex file to load onto our driver, which is not human readable.

Step 5) Flash the driver:
After the desired edits have been made to the code, use Microchip Studio to convert the .c file into .hex. Comfychair has written an excellent guide which details the process HERE.

So now that we have a .hex file we are ready to load it on the driver. Create a folder on the C drive and call it avrusb. This is the working directory we will read from and write to during the driver flashing process. This is where the .hex file we obtained should be put and where we will store and backup driver related files as well.

Have your USBasp plugged in and the Pomona SOIC clip connected to the driver. Connect the SOIC clip so that pin 10 (GND) is connected to pin 4 (GND) of the ATtiny13A according to the illustrations above. Just to note, it shouldn’t matter if you have the jumper on the USBasp at 3.3V or 5V, but I recommend 5V. The ATtiny13A’s Operating Voltage range is 1.8 – 5.5V.

Open the start menu and navigate to MHV AVR Tools folder. Click MHV AVR Shell. This gives us the cmd window in which we will execute commands to write to the ATtiny13A. (Optional: WarHawk-AVG has written a nice guide on a process in which a .bat file is created and commands are executed by means of it.)

The command: avrdude -p t13 -c usbasp -n is a test command and will let you know if the chip is wired correctly.
If you get the “initialization failed” message, you aren’t getting a good connection.

Now it is time to flash the mcu with fresh firmware. Change the “current directory” by executing cd C:\avrusb so that AVRdude can find the file.

Finally, flash the driver with the new firmware: (change the star.hex part to whatever you named your .hex file)

avrdude -p t13 -c usbasp -u -Uflash:w:star.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m

Be mindful of the value of the fuses; they may change from firmware to firmware. In the above example, the “low fuse” is 0x75 and the “high fuse” is 0xff. Generally all firmwares will state the proper fuse values in the .c file. An AVR fuse value calculator is available here.

Commands are case sensitive. The functions of the commands (-e, -p, -u, -U, etc.) are explained in detail in the Option Descriptions section of the AVRdude users manual.

Know that it is also possible to download the settings and firmware from the driver and dump them into the ‘current directory’ with the command:

avrdude -p t13 -c usbasp -u -Uflash:r:flash-dump.hex:i -Ueeprom:r:eeprom-dump.hex:i -Ulfuse:r:lfuse-dump.hex:i -Uhfuse:r:hfuse-dump.hex:i

This reportedly does not work to salvage the factory code, only code you had previously written to the driver that you wish to extract and save. This section of the wiki has more about this command.

2 Thanks
how to start programining atmel?
SP36 head disassembly / reflash -- non-destructive? (ReFlashed! Didn't Break! - much-)
Single 7135 with resistor?
iPhone ready - Nanjg stripping and A17DD-SO8 building videos
17mm & 20/26/27mm single-sided DD/FET driver release: A17DD-SO8 / A20DD-SO8 / etc
Nanjg memory
New Guy - Older than Motorola 6800 - My first code
Swapping out Atmel attiny13a
soldering 3rd star from left on nanjg 105c doesn't get rid of blinky modes
Flashlight Firmware Repository
Pomona clip users
Code now public! BLF A6 FET+7135 Light. Short 18350 tubes and Unanodized Lights Available
Code now public! BLF A6 FET+7135 Light. Short 18350 tubes and Unanodized Lights Available
WTS : USB-UPDI Programmers for Attiny1616/AVR32DD20 drivers (Sofirn/Wurkkos/Fireflylite/Emisar)
BLF17DD Info Thread - Reference
22mm 16x 7135 driver for F13 flashlights - [released]
Code now public! BLF A6 FET+7135 Light. Short 18350 tubes and Unanodized Lights Available
How To Build a Flashlight With Perfect Modes (picture heavy)
Brightest AAA size light available
【convoy】
Disaster, dead light: Seeking Advice on updating FWAA firmware: Atmel T85 different package
FWAA Anduril 2 .hex
(BLF) Sofirn Q8 V1.5: The XPL HI monster, DIY parts + Extended 8x18650 tubes GB Interest List
Emisar D4V2 Flash Kit Instructions (Official How To)
*BLF LT1 Lantern Project) (updated Nov,17,2020)
Sofirn Q8 group buy (gb closed, but try PM to Sofirn for discount)
help with avrdude and D4 flashing kit
S2+ programming trouble (because I'm an idiot)
I'm willing to pay $200 (not commercial)
BLF LT1 Runtime test *updated 12/11 with step level 2*
What programmer do you use?
FW3A Troubleshooting / FAQ
Anduril hex file for Q8
FW3A mod thread. Post yours!
FW3A Troubleshooting / FAQ
Nanjg AK-47 driver low voltage blink
What did you mod today?
SOLD! Sofirn Q8, flashed with Anduril for fancy features like candle mode and others. Maybe custom Anduril MCUs as well?
Need a 500 ma/ 600ma single cell driver
Need a 500 ma/ 600ma single cell driver
Need step-by-step guide for idiots on how to flash Emisar D4 with Anduril
Q8, PMS SEND TO THOSE WITH ISSUES BLF soda can light
Taking the custom mod plunge.
Flashlight Firmware Repository
Flashlight Firmware Repository
BLF A6 FET+7135 Light Troubleshooting and Mod thread
TK's Emisar D4 review
Modding... What do I need to know??
Who is still flashing his/her own drivers?
TK's Emisar D4 review
newbie 1st try
[PART 2] Official BLF GT Group Buy thread. Closed, but Public sales open!
Please could somebody help me modify the drivers firmware?
E-switch UI Development / FSM
Annoying strobe.
Q8, PMS SEND TO THOSE WITH ISSUES BLF soda can light
Babka firmware development
Babka firmware development
New to modding - H03 ramping UI driver choice
What did you mod today?
And another newbie with dozens of questions join the forum.
Problem with Convoys Bistro mini/Biscotti driver
Q8 modding
Q8 modding
Upgrading Old Convoy S2+ to biscotti? and some other newbie questions
Flashing ATtiny firmware?
Is this possible for current clicky drivers?
howto: flash ATtiny with AVRDude and command prompt
New Convoy C8 – Clearly better
Is there a noob's guide to flashing firmware?
PD68 Review: Convoy BD03 - Tube light w/ built-in charging (Coupon inside)
Flashlight Firmware Repository
gChart's 500 post giveaway - winner announced
help with fet+7135 driver
Light building tips
Recommendation for 1x18650 driver for Nichia 219C
▶ Flashlights with BLF User Interfaces - Master List ◀
Convoy S2+ vs. Nitecore SRT5
New Convoy C8 – Clearly better
Convoy S2+ vs. Nitecore SRT5
Firmware Suggestions for 17mm MTN-MAX lp Driver
Klarus Mi7 Driver mod with NarsilM
Flashlight User Interface Cheatsheets
Need Help Flashing Atiny25 MTN FET + 3175
NovicesFirmwareGuide: learn to use existing code for your custom builds (WIP) <!--break-->
DQG tiny 4 18650 triple mod
Advice Needed: Should I build or buy a pre-made light? Help with specific flashlight need (strobe mode on as default)
My modified program for Convoy S3 flashlight
Mod: Convoy L4 de-domed, driver swapped, & a cnc machined rifle mount
How To Build a Flashlight With Perfect Modes (picture heavy)
EagleEye X2R Mod and Discussion thread
Flashlight Firmware Repository
BLF ReyLight Titanium Flashlight 3*Nichia
6V Driver with LVP
Attiny25/45/85 FW Development Thread
Dr Jones RGBW F6 Driver Problem Solving
Light Recommendations for Underground Use, 6hrs Runtime
105c driver testing?
Help to Program Driver A17DD-L FET+1
usbasp wiring
How To Build a Flashlight With Perfect Modes (picture heavy)
New Guy - Older than Motorola 6800 - My first code
Attiny25/45/85 FW Development Thread

For your information:

Some newer flashing guides that may help you:

Emisar D4V2 Flash Kit Instructions (Official How To)

FW3A Firmware Flashing Guide

1 Thank

Thanks for puting this together!

+ 1 Hoop. Thanks.

That looks very well written, thanks to this more folks will be encouraged to flash their own MCU's.

(not me, I'm scared of computer programs)

Thanks a lot Hoop, I have all the hardware and software ready, all I need is courage :smiley: . Can I flash a Nanjg105/101 or does it have to be a Qlite?

(subscribed)

Any driver with the attiny13a MCU will work.

@OP: Thank you for posting this!

You’re all welcome! Big thanks to all those BLF’ers whose posts made it possible for me to figure this out! :party: And for the efforts of the likes of DrJones, JonnyC, Tido, and others for creating and sharing their code!

Do it djozz!

Good job Hoop, I like this compilation guide. Those are all great resources you tapped into there and I think you’ve put them together well. We’ve been needing for someone to do this.

In order to repair the forum software’s butchering of your command line text, you can try using the HTML PRE tag. - HTML pre tag After bracketing your text with the PRE tag you’ll have this:

avrdude -p t13 -c usbasp -u -Uflash:w:star.hex:a -Ulfuse:w:0x75:m -Uhfuse:w:0xFF:m

Very nice Hoop, I think you may have just pushed me enough over the edge into buying the equipment.

Now if I can only learn to solder 8 more 7135s proficiently to the QLITE REV.A 7135*8 3.04A, I’ll have the 5A Eagle Eye X6’s I wanted for around $5 more each instead of $15! :slight_smile:

Maybe an addition of everyone’s modes and examples would be a good addition?

It’s probably worthwhile to add instructions on the Pomona SOIC clip [5250]. I think the general consensus is that it’s superior in every way and worthwhile over the eBay contraption. It should cost <$20 shipped in the US, but it does not come with cable. I currently have mine hooked up with a harness made from one of these 40-wire female-female strips. Ordering the Pomona clip from Mouser or Digikey is a perfect time to stock up on small components like resistors, capacitors, diodes, FETs, extra ATtiny13A’s, etc.

Nice work Hoop! Concise and well written.

I have been procrastinating - this write up may push me over the edge :slight_smile:

John.

No excuses now :wink:

I wrote a post in another thread with perhaps some useful info: what programmer to buy

At least the info on what AVR Dude responds with if it can find the programmer or not, and then if it can find the chip or not, is of interest. I was having problems and it took me a while to figure it out.

Nice! Good Howto:

Good job!

Not as hard as it seems is it :wink:

Thanks for providing the SOIC8 eBay link. I discarded the idea previously when I found 3M SOIC8 cost about $48 from element14 in my country. I will give it a try when I get hold of the components.

Thanks! Great job and this is very nice compilation indeed. :slight_smile:

Love it!

I like having all useful info in as few posts as possible!

When I flashed a few of mine (never done it again after) I had to ask people through PM, and most information was hidden deep in threads..

luckily you have made a good overview.

you could even change the title to "Guide: How to flash a "you name it" with custom firmware."

edit: it would be very nice if there would be a thread where everyone can post their codes in, so people can copy and paste them....without having to reinvent the wheel.