[Flashing drivers] Lexels firmware builds and flashing guide

How to flash drivers and program

How to compile a project in Atmel Studio 7

Source codes with all my changes to it so it works in Atmel Studio 7
Anduril
NarsilM
Bistro HD OTSM v1.7.1

calibrate the voltage and temperature readings

Installing USBasp drivers and software
https://www.fischl.de/usbasp/

.

Getting a proper working driver using Zadig
you can read proper instructions here
https://sparks.gogo.co.nz/usbasp_drivers.html

.

How to flash using CMD
open cmd in the folder the .hex files are
then use the command string with proper fuses
Tiny 85

or use the full file directory
Tiny 25

How to flash using Atmel studio adding an external tool added as a button in the main menu header
http://www.ledoelectronics.com/Productos/AVR/usbasp_s7.pdf

for Tiny25 and 85 you need 2 different commands

To compile a hex file in Amtel Studio 7

The how to do in Amtel Studio 5 can lead to errors if the file also needs to load information from the config files, you see more files in the Bistro HD folder

You can simply load the BistroHD.c file
And then start from build in the how to create hex in studio 5
The studio will have also the other files

Right click on solution explorer on the right side
Click on add new project,
Remove the main.c
Add existing Item BistroHD.c and the other files
from there you can use the how to in the BLF topic from comfychair

Comment out or disable just add // in front
Enable remove //

For different PWM channels you need to enable or disable the channels in top section of the file, read the comments on the code lines they tell you what to do

There is only one hex file!
The Amtel studio loads from all those config files what it needs and build a flash code in the hex file

If you got the hex file you need also use the right fuses to flash the driver, most will have add a .bat file to do so

New project

Select your Chip

if you use a different than the 25 you need to change that in the BistroHD.c file as well

Delete the main.c

Getting the files loaded

Load all the files for the solution

Building the hex file

here you find the hex files

fuses
the text file is from Texas Bistro including the whole command prompt to flash

Anduril

Download my whole Atmel studio project
04-2020 build
09-2019 build
old version about 03-2019 about march with old config selection

Thermal values and ramping tables are changed on some light builds
you can download the original config files here

on some .cfg files I sorted the ramping tables like in NarsilM

there are spaces between the left and right 8 values the forum deletes

NarsilM v1.2

Mostly untouched but some ramping tables are optimized to my needs
L6 AMC less driver support added

Bistro HD OTSM v1.7.1

if you want to change the flash and later reset values to a different behavior change the Boot up values

#define USE_FIRSTBOOT //Enables reset menu option, only costs a couple of bytes.

#define INIT_MODEGROUP 11 // which mode group will be default, mode groups below start at zero, select the mode group you want and subtract one from the number to get it by defualt here
#define INIT_ENABLE_MOON 1 // Should we add moon to the set of modes?
#define INIT_REVERSE_MODES 0 // flip the mode order?
#define INIT_MEMORY 0 // mode memory, or not
#define INIT_OFFTIM3 1 // enable medium-press by default?
#define INIT_MUGGLE_MODE 0 // simple mode designed for mugglesotsm
#define INIT_LOCKSWITCH 0 // 0 => E-swtich enabled, 1 => locked.
#define INIT_MAXTEMP 88 // maximum temperature

Calibrate voltage readings

Anduril

3 clicks from off shows you the read battery voltage compare to measured voltage or assume full battery is 4.2V

in the light specific hwdef-“lights name”.h file

for 1S builds without voltage divider
// average drop across diode on this hardware
#ifndef VOLTAGE_FUDGE_FACTOR
#define VOLTAGE_FUDGE_FACTOR 6 // add 0.25V
#endif

change the diode offset value in 0.05V steps

.

for builds with LDO
// Raw ADC readings at 4.4V and 2.2V (in-between, we assume values form a straight line)
#ifndef ADC_44
#define ADC_44 184
#endif
#ifndef ADC_22
#define ADC_22 92
#endif

#define VOLTAGE_FUDGE_FACTOR 0 // add 0.25V

2 options:

- change the voltage fudge factor –1 is here about 0.1V lower

  • change the ADC_44 and ADC_22 value similar to NarsilM

.

NarsilM

look if 3 clicks show proper voltage reading either at full or drained battery

Changes in the Setups.h file

LDO Builds
in NarsilM I have added different voltage reading tables those you can simple enable
#define VOLTAGE_MON // Comment out to disable - ramp down and eventual shutoff when battery is low
//#define VOLT_MON_R1R2 // uses external R1/R2 voltage divider, comment out for 1.1V internal ref
//#define USING_2200K
//#define USING_1000K // for 4S
//#define USING_1000K_01 // 2.8V +0.1
//#define USING_1000K_02 // 2.7V +0.2
//#define USING_1000K_m01 // 3V –0.1
//#define USING_1000K_m005 // 2,95V –0.05
//#define USING_680K // for 3S GT buck
//#define USING_680K_02 // 2.8V +0.2
//#define USING_680K_01 // 2.8V +0.1
//#define USING_680K_m01 // 3.0V –0.1
//#define USING_680K_m02 // 3.1V –0.2
//#define USING_680K_m03 // 3.2V –0.2
#define USING_360K // for using a 360K resistor (LDO and 2S cells)
//#define USING_360K_m01 // 3V –0.1
//#define USING_360K_m005 // 2.95V –0.05
//#define USING_360K_005 // 2.85V +0.05
//#define USING_360K_01 // 2.8V +0.1
//#define USING_220K // for using a 220K resistor (LDO and 1S cells)

.

for 1S builds change the diode offset
#define D1_DIODE 4 // Drop over rev. polarity protection diode: 0.2V normally, 0.3V for Q8, bigger value for too high voltage

.

Bistro HD

see if full battery shows 4.2 blinks in hidden modes or if the LVP is at 2.7V

change v correction value in the fr-calibration.h file

1S builds
//Calibration for traditional voltage-divider, NON LDO*/////////
//
#define v_correction 0.0 //in volts for minor calibration adjustment.

.

LDO builds
//LDO OTSM calibrataion//
//
#else // next version is the value used for LDO OTSM configs where the divider voltage is read relative to Vcc
#define v_correction 0.0 //in volts for minor calibration adjustment.

.

.

Calibrate temperature readings

Anduril

read the actual MCU temperature

  • 3 clicks from Off followed by 3 double presses
    measure the driver’s temperature with IR thermometer or use room temperature

2 options:

  1. while you are in the temp read from above do 4 clicks then follow user manual to set the calibration and the max. temp value

2. if use 10 clicks for thermal calibration is enabled in the setup file
10 click and then follow the manual

NarsilM

read actual MCU temp by 3 clicks followed by double press

in Setup.h
// Temperature Calibration Offset
#define TEMP_CAL_OFFSET (–6)

- change this value and compile a .hex so that the readout is as the drivers temp

  • flash driver and check if it is now equal

Bistro HD

set the max limit in the light

Many thx for all of these info’s!

As I don't flash drivers, this thread isn't really for me, but it looks impressive!

Sweet!

:+1:

Thanks! Sticky’d.

Thank you Lexel… Can’t wait to ruin one of my FW3A drivers lol

Great works! :+1:

Thank you Lexel. Very useful informations. I just realized that none of my bistro hd drivers have voltage calibration.

You have little bug in post #7
Should be:
Calibrate voltage readings
and then
Calibrate temperature readings
You have Calibrate voltage readings twice

Great ressource you provided here. Got it working all by myself, but this thread would have saved me a lot of time :)

Thanks Lexel. Nice work putting this together. I still dont understand it though. :person_facepalming: :slight_smile:

Thanks Lexel! This is huge!

Thanks for this. :slight_smile:

It’ll be a big help for anyone who has a light based on your work and wants to get the sources for reflashing or modifications. Also very helpful for investigating and fixing any potential issues people might discover.

With open-source stuff like this, the main idea behind the license is that it stays open. To do that, it requires that anyone who distributes a compiled version also needs to make sure the sources are available and information about how to get it is published in an easily-found place.

A thread like this helps a lot with that goal.

Awesome work :beer:

If someone succesdes to update the “Anduril Atmel project folder” to the latest files, do share :wink:

It worked out of the box, even with the changes I made to Anduril, it built a hex file. I flashed it, and it worked. HUZZAH.

My issue is that it’s based on an older revision of Anduril, on older files (fx.: 2-level lockout is missing) . When the files are updated, it makes 5-6 errors and doesn’t compile anymore :cry: