How To Build a Flashlight With Perfect Modes (picture heavy)

I’m reading my way through this thread with the thought to getting the equipment needed to flash my own driver modes. I have come up with a question.

Is there a way to tell beforehand whether or not a driver is programmable or not? Are most reprogrammable or not?

Thanks very much.

Don

The drivers this thread is aimed at are the one's using the ATTiny 13a. A lot of development is also being done now on the 25/45/85 versions.

Basically, if your light has a "Nanjg xxx" driver, such as most of the Convoy's have, it has the ATTiny, & is capable of being re-programmed using the methods described in this thread.

If you look close, you should see the model of the chip printed on it;

Most other lights will use a different chip, they may even use the same footprint as the 13a, but are not programmable using this method due to using a different language.

- edit -

You may want to check out Hoop's guide, which contains everything you need to know to get up & running with flashing your own drivers.

Hi everyone,

it's a very long time since I saw this thread for the first time and this is my very first post.

This question caught my attention so I decided to give an explanation about modifying existing drivers in case someone is interested. I made an one-page document explaining the process, here you are the link to the explanation. I hope it could help understanding how tedious would be to make even just a small modification to the existing drivers compared to writing the firmware from scratch.

Hi Chupo_cro, and welcome! Brings back ol memories of 8" floppy disks and paper tape. We've gone way past those attempts now. We have a pretty rich library of drivers that can do just about anything you want. Source is posted publicly. See this thread for starters: https://budgetlightforum.com/t/-/32545, in case you are not aware. Many of us buy bare PCB drivers cheap at OSHPark and reflow them ourselves, then program them using a $4 USB dongle, free software, and a cable and clip.

This thread, of course, is what started it all. Lots of innovation here, plus showing that we can actually do it.

It makes me happy that the last sentence is: “In case of most flashlight drivers it is much simpler to write the new firmware from scratch.”

That’s exactly the reason I haven’t messed with Atmel assembly code. :slight_smile:

Hello, I have been following a page that is guiding me through the equipment needed to flash drivers, I am an absolute beginner.
The page I have been getting much information from like the link to this page actually and is called AVR Drivers on Flashlight Wiki and my question is only about the price of a USBasp.
I have found one at Hobby King, for $3.99 and have seen others for a bit more but not much less than this, I think this is about middle of the road,
I am hopeful that someone could please perhaps take a quick glance and tell me if maybe this is to cheap and perhaps what is a reasonable price range ?
This is the link to the, USBasp AVR Programming Device for ATMEL Processors
Thank you very much…

Why wouldn't you get this one - well proven, known, used by many: https://www.fasttech.com/products/0/10000022/1002900-atmega-attiny-51-avr-isp-usbasp-usb-programmer

It's referenced all over the place. The USBAVR V2.0 labeling is important. Dunno what the Hobby King is exactly. As mentioned just a couple posts above, please refer to Hoop's thread: https://budgetlightforum.com/t/-/30672. Lots of ref info in the OP there.

I bought the one Tom mentioned a month ago and it’s been working fine for me.

Thank you Tom and SigShooter, that is exactly what I will do today, absolutely…
I might have saved myself a few hours by just asking here outright but didn’t want to bother anyone.
Thank you again and have a wonderful day… oh, also, Tom thank you for the lead and link to Hoops thread, very helpful as always, along with SigShooter’s endorsement, fantastic, that’s solved…!
One thing I knew was Hobby King is a China company but has Stateside warehouses and that one I pointed out was in Oregon warehouse, so it would have gotten here quicker, but quicker is not always better…
Thanks all,

- yea, think someone bought something similar a while back, wound up being wired differently - think it was actually an old design compared to the V2.0 - think they ended up buying the 2.0 anyway.

That would most certainly have been my luck and would have been such a disappointment and right out of the gate,
So I am glad I used my head for more than a hat rack and decided to ask first.
I still have an old list you had given me in a post a long time back, but it was only the names of required equipment and that was it, but I’ve been sitting on that info Tom and finally decided to move ahead after watching the work you’ve been doing and wanting some of the UI’s available but no means to flash them to my lights, So thank you very much Tom

If you have a PC with parallel port you can build a programmer in less than 15 minutes. Just connect a few wires and 4 resistors as shown here and then you can use Ponyprog which has much friendlier user interface than avrdude + some GUI, especially when working with fuses. I've been using such a 'programmer' for years without a single issue.

That is really great… Thank You Chupo…!!
I should be able to use a Parallel DB25 M/2F Y-Splitter so I can keep using my printer, I think this is a DB25 parallel, well it’s stock with system so generic, thinking out loud sorry, and with your recommendations that should work perfectly and doesn’t appear complicated at all, thanks again greatly appreciated. Wow, that is some really great information you linked, thanks once again…

I am glad you find it useful. After the first launch of Ponyprog under Setup > Interface Setup select Parallel, AVR ISP I/O and probably LPT1 and everything else unchecked. Then run Setup > Calibration and that's it. Be careful with the fuse bits not to lock the µC by disabling the internal oscillator (checked = programmed = zero). If you by accident disable the internal oscillator then you will have to connect the external crystal or use high voltage programmer to reprogram the fuses to reenable the internal oscillator so you could use ISP programming again.

I have cut and pasted this to my note book, and I’d bet this would have been something I surely would have messed up since I believe I am accident prone :stuck_out_tongue: ,
So thank you again, you’ve been so helpful…!

That sounds cool

Can you use an old Jetdirect with parallel ports?

Unfortunately I don't think that might work because PonyProg uses direct I/O access and it doesn't work well even with PCI parallel adapter card. In that case it is not possible to select AVR ISP I/O option and AVR ISP API option has to be used resulting in very slow programming speed (minutes instead of seconds). On the other hand, a 'real' parallel port works really well. I have both USBasp programmer and JTAG ICE debugger and I can use USBasp with both the PC and Raspberry Pi and I can program AVRs even directly (without programmer) using Raspberry Pi's I/O lines but I mostly use parallel port + PonyProg. I use USB programmers only when parallel port is occupied by CNC machine.

Thanks for the explanation. :slight_smile:

Ran into a new problem running a reflash of STAR, although I suspect my problem has nothing to do with STAR.

Have not updated any drivers or or changed the pinouts on the USBASP. They’re all soldered and in great shape. No shorting between pins either.

Any ideas?

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

Solved the above issue with a reboot but have run into a new problem.

At the end of programming I’m now getting the following message:
avrdude: verifying …
avrdude: verification error, first mismatch at byte 0x0000
0x00 != 0x09
avrdude: verification error; content mismatch
avrdude done. Thank you.

After this, the driver does not output any power.

Really stumped here. Trying to program the same piece of code I successfully programmed a few times in January.