My attempt to reflash my flashlights - work in progress

Ok first of all, I actually had some experience with PIC microcontrollers, though limited. And then I went to school where we learned some VERY basic C for the PIC.

After I left school I learned about Arduino.

Well, the flashlights I like lately, the EMISAR D1S, D4, D4S all run on Atmel microcontrollers! Those are like, ALMOST arduinos!

I understand that the whole idea of Arduino is simply a bootloader that allows Atmel microcontrollers to be programmed without a proper programmer. You can do it with two wires. This is not useful for flashlights because the Arduino bootloader has to wait a moment after being powered-on in order to wait for a new program. You wouldn’t want your flashlight to delay a moment before turning on every time just because it might need to be ready to be programmed.

So programming the microcontroller inside one of these flashlights requires a dedicated programmer that can control 4 different pins instead of just 2. I think with PIC this required higher voltages, but thankfully this is not the case here.

I bought my flashlights and then instantly wanted to make subtle changes to the firmware of the older ones to match the newer ones (hint: D4S firmware is much more advanced than that on D4). So I bought a USBASP from a link I found somewhere on the web.

I got the USBASP and it is not recognized as a USB device. Note that this is different from not having drivers. I tried that, of course. After some research I came to the conclusion that my USBASP arrived without being programmed with any firmware whatsoever. Just buy a new one, right? It did only cost $1.50. Well, I remembered that an Arduino can be used as an ISP programmer. I could install the firmware on my USBASP! And then I realized that if I already had that, I maybe didn’t need the USBASP in the first place. I could use the Arduino ISP programmer to program the Emisar light directly.

I did make some attempts to program the USBASP with firmware but it does not seem to respond. There’s a jumper to close to allow reprogramming, and I believe I found it and closed it. I do not have a schematic for this exact variation of the board but the jumper is in the same place as others. I have not yet determined if it gets power (need to break out the multimeter and some good lighting + magnification) but in any case I cannot program it so far. But this is only a side exercise if the Arduino is capable of programming the flashlight microcontroller firmware directly.

My next step is to try to compile a custom version of Anduril (Sorry, I’m not going to put that accent on it! Don’t hate me.) from the Windows command line for the D4S and flash it and enjoy it. I would do the D4 first but I am still waiting for a clip to arrive and the D4S is easier to connect to with the stuff I have.

I just wanted to share this experience as a naive experimenter with flashlights. I hope someone else reads this and has something to add or even just finds it useful in some way. In any case I hope this message finds you well today and I will be adding more messages as I figure this out, if that is permitted.

So far only great failure.

I’m trying to use an arduino as an ISP programmer. I have it connected to the D4S but all I get is “avrdude: stk500_getsync(): not in sync: resp=0x00”

… more investigation required. I don’t even know if the arduino ISP is up to the task.

I can’t get it to work either, using an Arduino Nano as ISP programmer. I’m stuck on “Yikes! Invalid device signature”. I suspect bad contact because I don’t have pogo-pins, but I can only know for sure once my reflashing kit from intl-outdoor.com arrives.

Edit: The reflashing kit worked right away.