Need step-by-step guide for idiots on how to flash Emisar D4 with Anduril

25 posts / 0 new
Last post
Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California
Need step-by-step guide for idiots on how to flash Emisar D4 with Anduril

I tried this guide from the Emisar D4S review thread today:

Fate0n3 wrote:
zeroflow wrote:
Gavka wrote:
I’m an absolute newbie. For starters, I would like to learn how to flash new firmware in my D4S. Where did you buy such adapter for the D4S?

Ok. Starting with the basics, assuming everything has to be bought.

1. Buying the hardware

First you need the programmer itself, an USB ASP Programmer.
The original can be found here https://www.fischl.de/usbasp/ while you can find it cheaper on Aliexpress or on Amazon
For the D4 or other boards without the nice connectors, you will need an SOIC8 programming clip to connect to the chip

Also, to get nearly any kind of connection, I suggest a set of Dupoint connectors
You will use this cable to make connections between the Pins of the programmer and either the clip or the D4S programming pads.

2. Connections
Now lets look at the available connections, with an example for the D4S.
You have the programmer

And you have the D4S

Now you take the female-male dupont cables and connect it the following way:

USBasp -> D4S
GND (any) to V- (top left)
MOSI to MO
RST to RS
SCK to SC
MISO to MI
VCC to V+ (bottom right)

The result may look like this

(for the BLF Q8 ,D4 or so, you do the same thing but with the connector of the clip. But that’s out of scope for now)

3. Flashing itself

Get the hex-file from here: http://toykeeper.net/torches/fsm/ – take the latest date of anduril for your light
Tutorial for avrdude is here: http://www.ladyada.net/learn/avr/avrdude.html

Short version of the tutorial:

  • Download hex from toykeeper.net
  • Download avrdude
  • Run this command: avrdude.exe -p attiny85 -c usbasp -Uflash:w:anduril.YYYY-MM-DD.EMISAR_D4S.hex:a

I want to say thank you for putting this all together…. Along with Toymaker providing updated configs, it really helps people like me getting into the hobby of flashing flashlights.

This was my first attempt ever at flashing a driver on a flashlight so I don’t really know what I’m doing. Tried to flash my Emisar D4 with Anduril.

Got the hardware per the guide above (got it on Amazon). Got the appropriate hex file from Toykeeper’s site above. Downloaded and installed AVRdude.

Result: TOTAL FAILURE.

  • I could only get AVRdude to work for a little while before it stopped working completely. And when it worked I couldn’t get it to detect the hardware or flash the ATiny.
  • When I tried to run the app initially it seemed to work fine. typing AVRdude at the command prompt displayed the list of stuff AVRdude can do. But when I tried to flash an ATiny85 I got a message about USBasp not being detected or something like that.
  • After a few attempts at this, the result changed. Instead when I tried to run the command line for AVRdude a pop-up window appeared saying “this App can’t run on your PC”. Along with a similar message at the command line prompt.
  • I’m running Windows 10.
  • I NEED A VERY DETAILED STEP-BY-STEP GUIDE FOR COMPLETE IDIOTS LIKE ME ON HOW TO GET THE SOFTWARE INSTALLED AND WORKING IN WINDOWS 10 AND FOR FLASHING THE ATINY. Tired

And what’s worse… now that I read up on some of the 1-star reviews of AVRdude, people are complaining that the app messed with their system and broke many programs. GAAAAH! I hope this didn’t happen to me. I have no idea if that happened. I sure hope not. AVRdude seemed to work at first from the command line then abruptly stopped working.

Are there any safer alternative programs to AVRdude for flashing the ATiny?

Edited by: Firelight2 on 01/24/2019 - 01:04
Cereal_killer
Cereal_killer's picture
Offline
Last seen: 11 months 1 week ago
Joined: 07/22/2013 - 13:10
Posts: 4005
Location: Ohio

Sounds like you didn’t get the usbasp drivers installed with how avrdude couldn’t see it.

Get zidag, follow its instructions to get the usbasp driver properly installed.

https://zadig.akeo.ie

 RIP  SPC Joey Riley, KIA 11/24/14. Now I am become death, the destroyer of worlds.

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

Ok got some ideas about the computer issue. Installing the USBasp driver first might help. Or if that doesn’t work doing a system restore hopefully to a point before Windows decided to ban AVRdude.

But I realized I have another problem: I have the USBasp and the SOIC clip. But my clip came pre-wired, and I understand the wiring needs to be changed for each chip.

I found a map on this site showing the wiring positions for the ATiny13. But have no idea what the wiring positions should be for ATiny25. The map on the D4S page doesn’t help since my goal is to flash a D4 and the D4 doesn’t have the ports on the bottom of the driver for flashing.

I need a map showing exactly which pin on the coupling coming out of the USBasp is supposed to correspond to which point on the SOIC connector. And how the SOIC connector should be oriented when attached to the ATiny85.

I’m a total noob at this stuff and would prefer not to destroy my D4’s ATiny85. Tired

chadvone
chadvone's picture
Offline
Last seen: 6 months 1 week ago
Joined: 08/28/2015 - 23:48
Posts: 1843
Location: Iowa

Did you get the ribbon cable

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

chadvone wrote:
Did you get the ribbon cable

I ordered a dupont cable with the separate sockets for each wire so I can change up the wire positions. It’s coming from Amazon so should arrive in 2 days.

What I have now is the USBasp 2.0 (from Amazon) and an SOIC clip that came pre-wired with its own ribbon cable and socket that mates with the one on the USBasp. The SOIC clip can plug-in as-is into the USBasp, but without being able to change the wiring, I’m sure the wiring would be wrong. Once my dupont connector arrives I can insert is in the middle and use it to change wiring positions (I hope).

However, in the meantime I have absolutely no idea what positions the wires are supposed to be in. Even if by some miracle the ribbon connector that came with my SOIC clip were wired correctly I wouldn’t even know what orientation is the correct one to attach the clip to the ATiny85.

chadvone
chadvone's picture
Offline
Last seen: 6 months 1 week ago
Joined: 08/28/2015 - 23:48
Posts: 1843
Location: Iowa

You will have to set them up like in Hoops photo

the colors don’t matter as long as they are the same on both ends. My colors don’t match Hoops but they work.

I used that photo for the Attiny85 so I think they are all the same.

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

chadvone wrote:
You will have to set them up like in Hoops photo

the colors don’t matter as long as they are the same on both ends. My colors don’t match Hoops but they work.

I used that photo for the Attiny85 so I think they are all the same.


Do you have a link to Hoops photo?
chadvone
chadvone's picture
Offline
Last seen: 6 months 1 week ago
Joined: 08/28/2015 - 23:48
Posts: 1843
Location: Iowa

http://budgetlightforum.com/node/36216

This is what I used to hook mine up. Post 2.

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

chadvone wrote:
http://budgetlightforum.com/node/36216

This is what I used to hook mine up. Post 2.

There are no pictures in Post 2. Do you mean this picture from Post 1? I understand that was for the ATiny13a. So the same wiring works for the ATiny85?

Cereal_killer
Cereal_killer's picture
Offline
Last seen: 11 months 1 week ago
Joined: 07/22/2013 - 13:10
Posts: 4005
Location: Ohio

Yes. 13A, 25/45, 85, they’re all the same pinout.

I marked my clip with a dot of paint, that way I know that side goes on the side of the MCU with pin 1-4 and don’t have to figure it out by tracing wires every time I want to use it.

 RIP  SPC Joey Riley, KIA 11/24/14. Now I am become death, the destroyer of worlds.

chadvone
chadvone's picture
Offline
Last seen: 6 months 1 week ago
Joined: 08/28/2015 - 23:48
Posts: 1843
Location: Iowa

Yeah, sorry beer. Thats the photo I used.

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

chadvone wrote:
Yeah, sorry beer. Thats the photo I used.
Thanks.
chadvone
chadvone's picture
Offline
Last seen: 6 months 1 week ago
Joined: 08/28/2015 - 23:48
Posts: 1843
Location: Iowa

Good Idea on marking them. I have hooked my upside down several times. If its wrong the light on the programmer goes off.

Wire 5 goes on the dot.

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

Drat.

Installing the USBasp driver doesn’t allow AVRdude run. And unfortunately, I waited too long to system restore and no longer have a restore point from before Windows blocked AVRdude.

Currently, when I type “AVRdude” from the command prompt I immediately get “does not have permission” and a pop up window saying the app will not run on my computer (even though I have the latest version of AVRdude installed). I even get the same result even after uninstalling AVRdude if I go to the command prompt and type “AVRdude”.

I haven’t found any way to bypass this apparent “feature” of Windows and allow AVRdude to actually run.

However, I did download AVRdudess and at least it launched when I tried running the app.

Unfortunately, I have no idea how to use AVRdudess. I can’t just cut and paste from Zeroflow’s guide into a command line since its a graphical windows interface with tons of options to fill in.: “avrdude.exe -p attiny85 -c usbasp -Uflash:w:anduril.YYYY-MM-DD.EMISAR_D4S.hex:a”

amars7
Offline
Last seen: 2 months 1 week ago
Joined: 05/13/2018 - 23:51
Posts: 58
Location: Western U.S.

Hey guys, I think I can help here. This guide should work for anyone using Windows10.

Step 1: get your appropriate driver from: http://toykeeper.net/torches/fsm/ , rename it something easy like D4S.hex (or what ever your light is)

Step 2: get WinAVR from: https://sourceforge.net/projects/winavr/ , install it to the root of your C: drive. Take your hex file from the previous step and copy it into the WinAVR folder that has now been installed on your C: drive.

Step 3: get Zadig from: https://zadig.akeo.ie/ , don’t worry, it’s a safe program, and quite handy.

Step 4: plug your USBasp in

Step 5: run the zadig.exe file, in the window that opens, click the “Options” menu and click “List all devices”. In the dropdown menu, USBasp should appear, if it doesn’t, select it. (if it isn’t there, check all your connections).

Step 6: what ever the driver listed is, select “libusbK” from the menu to the right of the green arrow, and click the “Replace Driver” button. Congratulations, you have now circumvented 98% of Microsoft’s bullshit.

Step 7: use the connection guide from earlier in the thread or here: http://flashlightwiki.com/AVR_Drivers , make your connections to your solder pads or clip, which ever you are using.

Step 8: open a command prompt (click start menu, type “cmd”, enter) and type “cd \” enter. (do not type the quotation marks). Now type “cd WinAVR” and press Tab, the rest of the name of the folder will fill in, then press enter. Your command prompt should now show “C:\WinAVR-20100110>”

Step 9: hook everything up and test your connection by typing the following: avrdude -p t85 -c usbasp -n , if your connections are successful, you will get a message that says “device initialized and ready to accept instructions” along with a progress bar and some other stuff. Ignore the warning about not being able to set sck period.

Step 10: assuming you are successful up to this point, you are almost done! Now enter in your command prompt: avrdude -p t85 -c usbasp -u -Uflash:w:FILENAME.HEX:a , and obviously replace “FILENAME.HEX” with the name of your file that you saved. The flash should begin immediately and take no more than 10-12 seconds. You will see two progress bars, one writing and one verifying. Once it’s finished…

Step 11: bask in the glory of your new firmware. Or fume at your lack of success, in which case post back here and I will try to help you!

Edit: I do not know how to format on forums Sad

AnhTran
Offline
Last seen: 5 months 4 weeks ago
Joined: 05/13/2017 - 23:56
Posts: 179
Location: Australia

Excellent guide, very short i clear, i have successfully flashed my D4. Thank you!
Also, there are so many hex file in the link in step 1, do you know where can i get some description for each file?

amars7
Offline
Last seen: 2 months 1 week ago
Joined: 05/13/2018 - 23:51
Posts: 58
Location: Western U.S.

They are mostly sorted by date I believe. I just scroll to the bottom and get the most recent one for my light. The one with lower muggle ceiling has just that: a lower max for muggle mode making it safer to give to kids and such.

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 1 day 1 hour ago
Joined: 01/12/2013 - 14:40
Posts: 10623
Location: (469219) 2016 HO3
amars7 wrote:
They are mostly sorted by date I believe. I just scroll to the bottom and get the most recent one for my light. The one with lower muggle ceiling has just that: a lower max for muggle mode making it safer to give to kids and such.

Yes, when sorted alphabetically, they also end up sorted by date. But it’s generally a good idea to click the “Last Modified” column to actually sort by date, just in case there’s something which doesn’t follow the naming convention.

http://toykeeper.net/torches/fsm/?C=M;O=D

jknut
Offline
Last seen: 3 weeks 3 days ago
Joined: 01/23/2019 - 08:47
Posts: 16

This guide was really helpful for flashing my D4S.

Is there something similar for flashing the FW3A? I’d like to put in the latest “fancy (2-level) lockout momentary moon.”

amars7
Offline
Last seen: 2 months 1 week ago
Joined: 05/13/2018 - 23:51
Posts: 58
Location: Western U.S.

The process is identical, save for using a clip on the chip instead of the PCB pads. And of course, the proper firmware

Firelight2
Firelight2's picture
Offline
Last seen: 6 hours 13 min ago
Joined: 04/08/2011 - 15:17
Posts: 4176
Location: California

FW3A also uses an ATiny85… the same MCU in the D4 v1.

The guide in this thread for the D4 should work perfectly for flashing the FW3A. Only difference is getting to the MCU is a bit easier since the driver is held in via retaining ring rather than glue.

CoRDS
Offline
Last seen: 1 month 18 hours ago
Joined: 06/03/2019 - 03:58
Posts: 21
Location: AU

i used the instructions at the top of the page to update mine today to Anduril so much nicer being able to do the lockout on 4 clicks instead of 6

byarnell05
Offline
Last seen: 6 hours 26 sec ago
Joined: 09/13/2011 - 02:32
Posts: 112
Location: Washington

Anyone else have trouble getting their D4S to flash using the dupont cable method? I flashed mine a while back to Anduril and had trouble getting it to flash but eventually got it to work. Then with Anduril2 being a thing I wanted to update it to that but can’t get it to work on avrdude via a mac or using the new android app method. I got the test command to show 100% success 1 time so I quickly ran the full flash command and it failed and the light is now not functioning at all and I cant get the cables to make proper connection long enough to do anything. Is it possible to “wollow” out the pinholes and render them unusable?

TMaxxJJ
Offline
Last seen: 57 min 35 sec ago
Joined: 02/01/2018 - 03:18
Posts: 215
Location: England

byarnell05 wrote:
Anyone else have trouble getting their D4S to flash using the dupont cable method? I flashed mine a while back to Anduril and had trouble getting it to flash but eventually got it to work. Then with Anduril2 being a thing I wanted to update it to that but can’t get it to work on avrdude via a mac or using the new android app method. I got the test command to show 100% success 1 time so I quickly ran the full flash command and it failed and the light is now not functioning at all and I cant get the cables to make proper connection long enough to do anything. Is it possible to “wollow” out the pinholes and render them unusable?

To flash my D4S I used a fine diamond file to make the points on the dupont cables thinner and with a shallower angle. It didn’t take that much on each one and now they’ll wedge nicely in the holes. I’ve kept the 6 together to use solely for the D4S, which I’ve flashed a couple of times now.
byarnell05
Offline
Last seen: 6 hours 26 sec ago
Joined: 09/13/2011 - 02:32
Posts: 112
Location: Washington
TMaxxJJ wrote:
byarnell05 wrote:
Anyone else have trouble getting their D4S to flash using the dupont cable method? I flashed mine a while back to Anduril and had trouble getting it to flash but eventually got it to work. Then with Anduril2 being a thing I wanted to update it to that but can’t get it to work on avrdude via a mac or using the new android app method. I got the test command to show 100% success 1 time so I quickly ran the full flash command and it failed and the light is now not functioning at all and I cant get the cables to make proper connection long enough to do anything. Is it possible to “wollow” out the pinholes and render them unusable?
To flash my D4S I used a fine diamond file to make the points on the dupont cables thinner and with a shallower angle. It didn’t take that much on each one and now they’ll wedge nicely in the holes. I’ve kept the 6 together to use solely for the D4S, which I’ve flashed a couple of times now.

I tried sharpening mine and still can’t successfully flash mine. I get close to success but always end up with this when it does actually try to flash

avrdude: error: usbasp_transmit: Input/output error
avrdude: error: wrong responds size
avrdude: error: usbasp_transmit: Input/output error
avrdude: error: wrong responds size
Writing | ################################################## | 100% 5.94s

avrdude: 7864 bytes of flash written
avrdude: verifying flash memory against anduril.2020-09-27.emisar-d4s.hex:
avrdude: load data flash data from input file anduril.2020-09-27.emisar-d4s.hex:
avrdude: input file anduril.2020-09-27.emisar-d4s.hex auto detected as Intel Hex
avrdude: input file anduril.2020-09-27.emisar-d4s.hex contains 7864 bytes
avrdude: reading on-chip flash data:

Reading | | 0% 0.00savrdude: error: usbasp_transmit: Input/output error
avrdude: error: usbasp_transmit: Input/output error
avrdude: error: wrong reading bytes ffffffff
avrdude: error: usbasp_transmit: Input/output error
avrdude: error: wrong responds size
avr_read(): error reading address 0×0000 read operation not supported for memory “flash”
avrdude: failed to read all of flash memory, rc=-2
avrdude: error: usbasp_transmit: Input/output error

avrdude done. Thank you.

The whole time its “writing” its constantly spamming
avrdude: error: usbasp_transmit: Input/output error
avrdude: error: wrong responds size

Any ideas?