How-To: D4 with Anduril + Aux support (windows)

Hello Guys,

I know many of you would prefer the D4 with Anduril and Lexels AWESOME Aux Boards controlled by Anduril. So far people seem to either hard-wire the Aux boards to battery or flash the D4s Variant of Anduril/Ramping OS. While this seems to work it’s not perfect, as the D4s is different in driver components and thermal mass, which is reflected in its firmware.

I have never edited or compiled firmware before. It’s actually rather straight forward, but I did struggle a lot in the process because you have to skim info from many different threads and places. So here is my guide which hopefully makes the process easier for others.

1 Editing the files for the D4 to enable Aux support
This is done to tell the software that the light has a board with aux LEDs. Without that step, the Aux Pad next to the switch will not work!

hwdef
cfg

1.1 Add those lines to the D4 hwdef file:

1.2 Add those lines to the D4 cfg file:

This is also a good time to adjust Anduril to your preferences. You can easily comment out additional flashing modes etc. I for instance removed bike, party and tactical modes.

2.1 Download and install Atmel Studio 7
2.2 Create a new Project “Anduril_d4aux” (Executable Project)
2.3 Paste the required files into the directory which Atmel Studio just created for your project. This is important and the main reason why I failed before.
these are located in:
…/head:/ToyKeeper/
…/head:/ToyKeeper/spaghetti-monster/
…/head:/ToyKeeper/spaghetti-monster/anduril/
Important: hwdef and cfg need to be replaced with the ones you just edited before!

2.4 Replace the code in the active Atmel Studio window for “main.c” with the code for Anduril, which you take from anduril.c
2.5 add the line to define Attiny85 to main.c (which is now anduril c)

2.6 compile the code buy selecting “Build Anduril” from the menu
2.7 if you did everything right you will get no errors. Several new files are created in the working dir, one of them is anduril_d4aux.hex

3 Flashing
3.0 connect everything to the ATTINY85
3.1 get the drivers from USBasp AVR Programmer, Program Atmel AVR microcontrollers
3.2 get AVRDude
3.3 To test your connection! make a backup using AVRDude by running: avrdude.exe -p attiny85 -c usbasp -U eeprom:r:backup.hex:a
3.4 To finally flash run this command (the hex should be in the avrdude directory): avrdude.exe -p attiny85 -c usbasp -Uflash:w:anduril_d4aux.hex:a

4 The Aux Board needs to be soldered to the Aux Pad (the empty pad next to the switch pad) and ground (the big pad at the AMC for example).




good luck and have fun!

Thanks for putting this together, I do all of this on linux/debian/raspbian but I like the one-stop approach. Good information. And huge thanks to the entire BLF technical team and contributors.

Does anyone have the a diagram of how the physical connections are setup? I bought one of these boards. (Still trying to figure out what resistors to use) I have never reflowed solder before so this is my first SMD build. I am not sure what resistors to use and where to place them. I understand that they will affect the brightness but I do not know what values to even try. I am not really looking to test a lot of values because I have never used SMD before. Kind of looking for someone else values. I also do not know enough about the attiny 85, so i am not sure where to connect the wires.
thanks

Thanks, this motivated me to finally install Atmel Studio and begin playing with the Anduril code.

Even though I don’t have a D4 aux board I have been meaning to try a dual switch Anduril build for the C8F 21700 and I did get it to compile after enabling the dual switch and disabling the strobes (to make room). I guess i’ll figure out something more appropriate to strip out if this works. I followed your steps and with a little troubleshooting I got a ROT66 based build to compile (which fits my own custom C8F better I think).

yes. It actually is not that hard, unless you try to figure it out via trial and error.

I found almost all the info scattered over many blf threads and after finally succeeding I thought I should put it all together for my fellow windows buddies.

In fact its really fun to tinker with Toykeepers absolutely fantastic work.

so big shoutout to Toykeeper

:beer:

Wow! Thanks for this guide!!!

Going to give this a shot once my parts arrive.

Though, I’m going to see if I can flash unmodified Anduril onto my D4. Tried last week and hit a snag and now my computer refuses to even run AVRdude.

I had absolutely no issues using those drivers linked above. Windows 10 1809 Update

I don’t think my problem with Windows 10 is a driver issue.

I think somehow something I did caused Windows to see AVRdude as a hostile program and ban it. When I type “AVRdude” in the command line I get “does not have permission”. This now happens even when AVRdude is not installed.

The solution is probably to system restore to a point before Windows chose to do this. Unfortunately, I waited to long and no such system restore point exists on my computer. I suppose I could reinstall Windows but that’s way too much effort to try to get AVRdude running.

I got AVRdudess running, but I’m not sure that will actually flash anything if doing so would mimic AVRdude. Also, I can copy-paste a command line instruction to flash AVRdude, but have no idea how to use AVRdudess.

My backup plan is to try installing AVRdude on a different computer and hope it works there.

When I read in the D4 mod thread you had successfully did this Pobel, I told myself it was too much work to figure it all out, even though I knew the information was available. Now that you have gathered the information into one place, I can see myself doing this in the not too distant future.

Thank so much!! :beer:

Just took a closer look at the first steps for modifying the hex file and I’m majorly confused. :weary:

Questions:

Question 1. Step 1 of the guide says to modify the hwf and cfg files and provides links. I downloaded the files from the links, but what do I use to edit them? When I tried notepad, the content of the files comes out in one big line with no returns. Is there a better app for editing these files?

Question 2. Step 2.3 provides three links and says go there and download the “required files” for Anduril.

… but which files are the “required files”? There’s a lot of files on those links and no list of which ones I need?

These questions probably sound dumb to the experienced programmers here. Unfortunately, I know nothing about programming and would rather not mess up a functioning light if I can help it. :open_mouth:

Perhaps it would be easier if someone posts a complied D4 Anduril hex file where the only thing changed is enabling the aux LEDs? :slight_smile:

use notepad to edit

the files you need to download are those in the picture below. these are located in the 3 directories linked above the picture

do a backup before flashing so you can always go back

Stuck those files in the directory. Checked that I had each one. Used Notepad to make the edits. Downloaded and installed Atmel7.

No luck. Compiled failed, got a couple error messages.

Closed Atmel and tried opening up my project again to find the error message but this time I don’t even see an option to build the project. GRRRR! :smiling_imp:

I really have zero interest in customizing Anduril other than turning on aux LED support for the D4. Any chance I could get your hex file since we know it works?

Nice write up. This should help a lot!
One thing that I might add to this to make it easier. They can be a little finicky at times but a lot easier than soldering wires.
https://www.amazon.com/CPT-063-Test-Clip-SOIC8-Pomona/dp/B00HHH65T4

absolutely - I now have one of these as well, but at the time of writing it was still in the mail and I did not want to wait :smiley:

@firelight
I sent you a pm

Thanks for the pm Pobel. I sent a response. :+1:

Me too, Does anyone already have a link to the d4 aux led function already compiled?
thanks

I tried to compile the firmware but I failed

did someone did this? It would be great if someone could compile the original stock Anduril for D4 with aux led enabled