[Flashing drivers] Lexels firmware builds and flashing guide

22 posts / 0 new
Last post
Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany
[Flashing drivers] Lexels firmware builds and flashing guide
Edited by: sb56637 on 09/08/2019 - 22:13
Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

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

Quote:
avrdude -c usbasp -p t85 -u -Uflash:w:Anduril.hex -U lfuse:w:0xd2:m -U hfuse:w:0xde:m -U efuse:w:0xff:m

or use the full file directory
Tiny 25

Quote:
./avrdude.exe -c usbasp -p t25 -u -Uflash:w:C:\Flashlight\drivers\Firmwares\Bistro\bistro-HD v1.7.1\hex\bistro-TAv1-OTSM-HD-attiny25.hex -U lfuse:w:0xd2:m -U hfuse:w:0xde:m -U efuse:w:0xff:m

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

Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

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

Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

Anduril

Download my whole Atmel studio project here

Main changes to the source code

1. I added here a set of different set of options to activate different config file builds

uncomment the one you want to build

/********* User-configurable options *********/
// Anduril config file name (set it here or define it at the gcc command line)
#define FSM_BLF_GT_DRIVER
//#define FSM_BLF_MF01_BUCK_DRIVER
//#define FSM_BLF_MF01_DD_DRIVER
//#define FSM_BLF_CC_FET_DRIVER
//#define FSM_BLF_L6
//#define FSM_BLF_GT_MINI_DRIVER
//#define FSM_BLF_Q8_DRIVER
//#define FSM_EMISAR_D1_DRIVER
//#define FSM_EMISAR_D18_DRIVER
//#define FSM_EMISAR_D1S_DRIVER
//#define FSM_EMISAR_D4_DRIVER
//#define FSM_EMISAR_D4_219C_DRIVER
//#define FSM_EMISAR_D4S_DRIVER
//#define FSM_EMISAR_D4S_219C_DRIVER
//#define FSM_FF_ROT66_DRIVER
//#define FSM_FF_ROT66_219_DRIVER
//#define FSM_FW3A_DRIVER
//#define FSM_SOFIRN_SP36_DRIVER

2. to get this working more code added a bit down

Quote:
/***** specific settings for known driver types *****/
#include “tk.h”

#if defined(FSM_BLF_GT_DRIVER)
#include “cfg-blf-gt.h”

#elif defined(FSM_BLF_MF01_BUCK_DRIVER)
#include “cfg-blf-MF01-Buck.h”

#elif defined(FSM_BLF_MF01_DD_DRIVER)
#include “cfg-blf-MF01-DD.h”

#elif defined(FSM_BLF_CC_FET_DRIVER)
#include “cfg-blf-CC-FET.h”

#elif defined(FSM_BLF_L6)
#include “cfg-blf-L6.h”

#elif defined(FSM_BLF_GT_MINI_DRIVER)
#include “cfg-blf-gt-mini.h”

#elif defined(FSM_BLF_Q8_DRIVER)
#include “cfg-blf-q8.h”

#elif defined(FSM_EMISAR_D1_DRIVER)
#include “cfg-emisar-d1.h”

#elif defined(FSM_EMISAR_D18_DRIVER)
#include “cfg-emisar-d18.h”

#elif defined(FSM_EMISAR_D1S_DRIVER)
#include “cfg-emisar-d1s.h”

#elif defined(FSM_EMISAR_D4_219C_DRIVER)
#include “cfg-emisar-d4-219c.h”

#elif defined(FSM_EMISAR_D4_DRIVER)
#include “cfg-emisar-d4.h”

#elif defined(FSM_EMISAR_D4S_219C_DRIVER)
#include “cfg-emisar-d4s-219c.h”

#elif defined(FSM_EMISAR_D4S_DRIVER)
#include “cfg-emisar-d4s.h”

#elif defined(FSM_FF_PL47_DRIVER)
#include “cfg-ff-pl47.h”

#elif defined(FSM_FF_ROT66_DRIVER)
#include “cfg-ff-rot66.h”

#elif defined(FSM_FF_ROT66_219_DRIVER)
#include “cfg-ff-rot66-219.h”

#elif defined(FSM_FW3A_DRIVER)
#include “cfg-fw3a.h”

#elif defined(FSM_SOFIRN_SP36_DRIVER)
#include “cfg-sofirn-sp36.h”

#endif

3. 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

Quote:
#define RAMP_LENGTH 150
#define PWM1_LEVELS \
1,1,2,2,3,3,4,4, 5,6,7,8,9,10,12,13, \
14,15,17,19,20,22,24,26, 29,31,34,36,39,42,45,48, \
51,55,59,62,66,70,75,79, 84,89,93,99,104,110,115,121, \
127,134,140,147,154,161,168,176, 184,192,200,209,217,226,236,245, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,0

#define PWM2_LEVELS \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,5,7,10, \
13,16,19,23,26,30,33,37, 40,44,48,52,56,60,64,69, \
73,78,82,87,92,96,101,106, 111,117,122,127,133,139,144,150, \
156,162,168,174,181,187,194,201, 207,214,221,228,236,245,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255, \
255,255,255,255,255,0,0

#define PWM3_LEVELS \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, \
0,0,0,0,0,0,0,0, 1,1,2,2,3,4,4,5, \
6,7,8,10,12,15,18,21, 25,29,33,38,43,48,54,60, \
66,72,79,86,93,100,108,116, 124,132,141,150,159,169,179,189, \
200,211,222,233,244,255,255

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

Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

NarsilM v1.2

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

Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

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

Lexel
Lexel's picture
Offline
Last seen: 7 hours 31 min ago
Joined: 11/01/2016 - 08:00
Posts: 5254
Location: Germany

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

id30209
id30209's picture
Online
Last seen: 10 min 7 sec ago
Joined: 05/17/2018 - 12:20
Posts: 373
Location: Croatia

Many thx for all of these info’s!

WTB Titanium 4sevens Quarks & Jetbeam TCR1

raccoon city
raccoon city's picture
Offline
Last seen: 3 hours 45 min ago
Joined: 10/06/2010 - 02:35
Posts: 13051
Location: रॅकून सिटी Palm Desert CA USA

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

zeremefico
zeremefico's picture
Offline
Last seen: 3 hours 25 min ago
Joined: 03/27/2012 - 02:44
Posts: 1324
Location: Greece

Sweet!

₪₪₪₪ ΟΥΔΕΝ ΚΡΥΠΤΟΝ ΥΠΟ ΤΟΝ ΗΛΙΟ ₪₪₪₪

My YouTube channel

Flashlights & edc gear

K40M F16

CRX
CRX's picture
Offline
Last seen: 2 hours 56 min ago
Joined: 04/02/2013 - 15:27
Posts: 3737
Location: Scotland
Thumbs Up
sb56637
sb56637's picture
Offline
Last seen: 1 day 11 hours ago
Joined: 01/08/2010 - 09:29
Posts: 6508
Location: The Light

Thanks! Sticky’d.

Budget Light Forum ...where Frugal meets with Flashlight!

KevinZA1988
KevinZA1988's picture
Online
Last seen: 9 min 6 sec ago
Joined: 02/26/2018 - 02:26
Posts: 621
Location: South Africa

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

BLF Q8, BLF A6, BLF FW3A, BLF FW3C, Convoy L2, Convoy L6, Convoy C8+ , Convoy S3, Convoy M21A, Convoy S11, Emisar D4, Fireflies E07, Jaxman E2L, Olight S1R Baton II special edition series, S2R Baton II, Nitecore HC65, Olight H1R Nova.

hasddie293
hasddie293's picture
Offline
Last seen: 1 hour 2 min ago
Joined: 03/05/2019 - 08:53
Posts: 116
Location: Brunei

Great works! Thumbs Up

In search of the most ideal flashlight in town:
1. BRIGHTNESS
2. Durabillity
3. Design
4. Quality
5. Price$$$

Chatika vas Paus
Offline
Last seen: 1 hour 2 min ago
Joined: 09/03/2017 - 13:46
Posts: 468

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

lichtpfadfinder
lichtpfadfinder's picture
Offline
Last seen: 3 hours 8 min ago
Joined: 04/29/2017 - 08:07
Posts: 79
Location: Germany

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

MRsDNF
MRsDNF's picture
Offline
Last seen: 1 day 9 hours ago
Joined: 12/22/2011 - 21:18
Posts: 12946
Location: A light beam away from the missus in the land of Aus.

Thanks Lexel. Nice work putting this together. I still dont understand it though. Facepalm Smile

 

djozz quotes, "it came with chinese lettering that is chinese to me".

                      "My man mousehole needs one too"

old4570 said "I'm not an expert , so don't suffer from any such technical restrictions".

Old-Lumens. Highly admired and cherished member of Budget Light Forum. 11.5.2011 - 20.12.16. RIP.

 

trailhunter
Offline
Last seen: 17 min 53 sec ago
Joined: 12/23/2015 - 17:56
Posts: 464
Location: VA

Thanks Lexel! This is huge!

ToyKeeper
ToyKeeper's picture
Offline
Last seen: 6 hours 1 min ago
Joined: 01/12/2013 - 14:40
Posts: 9810
Location: (469219) 2016 HO3

Thanks for this. 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.

i42dk
i42dk's picture
Offline
Last seen: 9 hours 14 min ago
Joined: 08/30/2017 - 05:35
Posts: 178
Location: Denmark

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 Crying

KawiBoy1428
KawiBoy1428's picture
Offline
Last seen: 20 min 34 sec ago
Joined: 04/11/2014 - 18:05
Posts: 3769
Location: The Motor City

Nice work Lexel! Beer

KB1428 “Live Life WOT

trailhunter
Offline
Last seen: 17 min 53 sec ago
Joined: 12/23/2015 - 17:56
Posts: 464
Location: VA

you sir are a noble and a scholar!