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. Achieve success with the ATtiny13a and work up from there.
References and relevant links:
USBASP V2.0 user guide
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 AVR Studio 5 to make a .hex file
howto: flash ATtiny with AVRDude and command prompt
USBasp V2.0 programmer (ebay, fasttech)
Pomona 5250 SOIC clip (Digi-Key) (Cheaper alternative. See post #167)
40-pin Splittable Ribbon Cable (20cm) (FastTech)
USB extension cable (optional but helpful) (EBAY)
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:
The pins of the ATMEL ATtiny13A chip itself on the driver are as follows:
(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. Plug the USBasp device into your computer. It should fail to install properly on its own. In Windows, bring up the device manager. You’ll 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 root folder on your desktop where you put the .zip contents. It should then install without any issue.
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 Atmel 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 Atmel 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.
The command: avrdude -p t13 -c usbasp -u -e will erase the contents of the chip so that it can be re-written to.
Now that the chip is empty it is ready to be flashed 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:mBe mindful of the value of the fuses; they may change from firmware to firmware. In the above example, the “low fuse” is 0×75 and the “high fuse” is 0xff. Generally all firmwares will state the proper fuse values in the .c file.
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:iThis 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.