Flashlight Firmware Repository

I've been collecting flashlight firmwares into one place and I hope it can become a central place for everyone to keep their code.

The repository is linked in my signature, or you can click here:

Anyone can create an account, branch the code, upload modified versions, file or fix bugs, submit merge proposals, and so on.

A quickstart is in the README (also included below), including links about how to flash drivers. To get an idea what is included in the repository, or to find a project relevant to your needs, look through the auto-generated INDEX file for projects matching your criteria.

If you have created any firmwares you don't mind sharing, please create a new branch and merge proposal with your code, or send me the files and I'll add them.

I'm using bzr and Launchpad to track and host the code, but if there is sufficient interest I am open to the idea of moving to git and a git-based project platform.

This thread is intended to provide a central place to discuss firmware in general, announce updates, and to avoid cluttering other project-specific threads with off-topic chatter.


Here's what it says in the README file:

ToyKeeper's flashlight firmware repository
==========================================

This is a collection of firmware for flashlights or torches, mostly
collected from BLF (http://budgetlightforum.com/). It's collected
here mostly for convenience, and to provide bug tracking and revision
control services for the code.

See the INDEX file to find out which projects might be relevant to
your needs.

Getting Started

The central firmware thread on BLF is here:

A general overview of what you need to get going is here:

http://flashlightwiki.com/AVR_Drivers

Some useful hardware for flashing firmware:

http://www.fasttech.com/product/1002900-atmega-attiny-51-avr-isp-usbasp-usb-programmer
http://www.fasttech.com/product/1011800-40-pin-splittable-ribbon-cable-20cm
http://www.digikey.com/product-detail/en/5250/501-1311-ND/745102

For Windows users, these links may be useful:

Hoop's guide:

Comfychair's guide:

WarHawk-AVG's guide:

Getting a USBasp to work in Windows:

http://rayshobby.net/dead-simple-driver-installation-for-usbasp-and-usbtiny-on-windows/

To set up an attiny dev environment on Ubuntu (13.10):

sudo apt-get install flex byacc bison gcc libusb-dev libc6-dev
sudo apt-get install gcc-avr avr-libc binutils-avr
sudo apt-get install avrdude avrdude-doc

Optional: (make avrdude usable by non-root users, is a security risk)
sudo chmod u+s $(which avrdude)

Building/installing attiny dev tools on other UNIX systems (in general):

http://www.ladyada.net/learn/avr/setup-unix.html

After wiring everything up, this tests the connection to the ATTINY13A chip:

avrdude -p t13 -c usbasp -n
(you may need to put 'sudo' in front, on UNIX systemsā€¦
or set the suid bit on the avrdude binary, which is convenient but a
potential security risk)

To test if you can flash firmware correctly, or to restore a light to something
like a default state, try flashing the NLITE driver from DrJones. It's similar
to the default nanjg / qlite firmware, but better.

./bin/flash.sh DrJones/NLITE/nlite.hex

For a quick test to make sure your tool chain works and your flashing tools
are working, try the 'hello world' program:

cd hello_world
make
make flash

If that works, you should be ready to start making changes to the code, or
flashing any of the pre-built firmwares.

Okay, Iā€™m terrible at keeping up with my todo list. Iā€™m putting it out in public in hopes that more of it will get done, faster. Help is welcome but not expected; Iā€™m putting it here more for my own accoutability. :slight_smile:

Iā€™m not sure if this is a good place for it or if perhaps I should track each of these as bugs on Launchpad. The bug tracker there is very nice, and works well as a task list.

  • Figure out an easy way for people to build these projects in Windows. Template WinAVR project or something, I donā€™t know. Help would be very appreciated.
  • Make periodic full-repository .zip releases, maybe, to make things easier for people who donā€™t have bzr?
  • Pull in pd68ā€™s tripledown code.
  • Test LVP in tripledown.
  • Pull in mk2ā€™s code.
  • Pull in guardiorā€™s sharkdrv and possibly other code.
  • Update alexvhā€™s code.
  • Finish merging some of Tom Eā€™s code (PM thread), which I started but never finished.
  • Pull in chousterā€™s code.
  • Pull in 3-channel version of blf-a6, and investigate pd68ā€™s other two requests at the same link.
  • Pull in CKā€™s code?
  • Document Mike Cā€™s awesome trick for putting multiple functions on a single pin.
  • Check the license in each project and tag it in the projectā€™s ā€œmetaā€ file.
  • Test LVP in each project and tag working ones with ā€œLVPā€ in the projectā€™s ā€œmetaā€ file.
  • Describe each project in more detail in the ā€œmetaā€ files, and copy the summaries into a project list in this thread.
  • Add homepage / URL info to each projectā€™s ā€œmetaā€ file.
  • Investigate, measure, and document ultra-low-power sleep modes. (Cruxā€™s posts here and here, ideas here and here and here)
  • Investigate brownout detection behavior in more detail to determine its actual effects.
  • Test how long the MCU can run after power is disconnected, in its absolute lowest-power mode.
  • Document how to make firmwares work on zener-modded drivers.
  • Document the exact components used on popular drivers.
  • Check if _delay_5ms() is worth using.
  • On super-fast strobes, try using digital pin state instead of PWM, for more fine-grained timing control. (60Hz strobe looks erratic)
  • Check if TheStar has any updates.
  • Make BLF-A6 (and tk-otc.c) easier to convert to single-channel.
  • Make Bistro easier to convert to single-channel.
  • Attempt to write a more robust code base for e-switch (and maybe dual-switch) drivers, using a state change table to define the interface.
  • X6R-compatible firmware.
  • Test the fancy lighted tailcap code and merge it into trunk after itā€™s verified.
  • Make blf-a6 and bistro and related tools more zener-friendly. For example, voltage_blinks uses a 3.5-bit voltage value but needs to be 4.4 to allow voltages higher than 7.9V.
  • Pull in Tom Eā€™s latest Narsil code. (done 2016-03-22)

Looking at this list, Iā€™m thinking it might be best to actually track each as a separate bug on Launchpad. Itā€™s a mess in the form of a simple list.

Thank you very much ToyKeeper!

Your repository helped me alot in creating my favorite UI.
So much work already done and easily available :slight_smile:

Especially the new wear leveling write and the read code part was just what i was looking for.

I modified Dr JonesĀ“ luxdrv for multiple groups (no wear leveling so far) and offtime-memory
using the NOINIT-section.

Awesome, thank you ToyKeeper!

Now we just need some ATtiny25 sample code :)

Iā€™ve been using you repo for a while. But now I will be able to find it much easier :slight_smile:

Great work with all the firmware!

Iā€™ve been loving your brass-edc but it looks like I might be switching over to your A6 firmware. Does your A6-biking have additional blinkers?

thank you ToyKeeper!

Sounds pretty cool; Iā€™d love to include it if possible. DrJones hasnā€™t given luxdrv an open license though, so we might need to get his permission to publish derivatives.

How about attiny85? I hear Mike C has some code working on that, and Iā€™m hoping heā€™ll decide to share it. :slight_smile:

Or, if I ever end up with an attiny25-based driver, Iā€™d be happy to port something to it. I donā€™t really have the ability to build the driver myself though.

No, the BLF A6 firmware only has one strobe (or biking flasher) and a beacon/battcheck mode. Also, it requires an offtime capacitor and itā€™s designed for dual PWM, so it might not work on the same drivers as brass-edc.c.

However, I made a stripped-down version which removes the runtime config options in favor of making room for other featuresā€¦ so itā€™d be relatively easy to add other blinky modes. Itā€™s ToyKeeper/blf-a6/tk-otc.c in my repo, and the entire purpose of it is to make it easier for people to build derivatives. Iā€™m assuming that, if someone is modding code, they can configure it at compile time instead of runtime.

Ahh, thanks! Didn't know I could update it directly. I'll try to create an acct and directly update then...

I'm all ears on Mike's ATtiny85 version - very, very interested. Can't stand this 13A code limit.

Gotta take a look at your tk-otc version - sounds like what I need. I'd want a STAROffTime or your noinit with a strobe option. Adding strobe would be much better with a "short cycle" mode method, but looks like your A6 two method of clicks (quick and hold) would be as good or better. Right now I don't see an easy way to integrate a strobe into STAROffTime

Iā€™ll be sharing it. It wouldnā€™t exist if 13A code wasnā€™t so freely shared by others here.

I have voltage monitoring working, and have coded a user interface so the user can re-program the amount of modes and levels. Iā€™ll make it 105C compatible with defines, so it can be used for 105Cs out of the box. Working on another light right now, but will get back to the 85 shortly. Next on the agenda is getting to know how the temperature sensor works, but it look s fairly simple as itā€™s the same routine as checking voltage levels with the ADC. Itā€™s the calibration routine that could be the hardest part.

BTW, if you use bzr at a command line instead of using a GUI front end, the commands to clone the repo, modify it, and publish a new version are: (ā€˜%ā€™ represents a command prompt, the lines you would type in)

% bzr branch lp:flashlight-firmware
% cd flashlight-firmware
(hack, hack, hack, maybe 'bzr add' new files)
% bzr ci
% bzr push lp:~myusername/flashlight-firmware/my-branch-name

Then either submit a merge proposal or simply let me know the branch exists, and I can merge it into trunk.

I generally prefer to keep a local copy of trunk along with a ā€œfeature branchā€ for each set of changes I make, to help keep things clean. This approach is pretty standard, and is discussed in more detail here, along with how the usage compares with git. But if you donā€™t know how to do that, I can easily accept patches or branches or merge proposals or whatever.

There are a few cross-platform GUIs available for those who want one ā€” Bazaar Explorer, QBzr, and TortoiseBzr.

Since there are so many flashers here :bigsmile: , I thought Iā€™d ask a question about multiple flash/test sessions. Is it OK to leave the SOIC clip attached when doing a short test of a revised firmware? In trying to learn this language (which started out as Martian, but is now more like Swahili) Iā€™m going to be revising this or that in the code, flashing a driver on the test bench to see if it works, then repeat. It would be nice if I didnā€™t have to reconnect the clip for every iteration, as I have a feeling the clipā€™s lifespan is related to the number of connection cycles.

I can see a couple problems:

  1. Backfeeding voltage into the USBasp.
  2. PWMing a 20cm piece of straight wire, and that could cause EMI gremlins to appear and possibly affect the outcome of the test. Iā€™m not even sure if the PWM pin(s) are connected to the clip.

Opinions?

Thanks.

Thanks for your input.

I emailed the question to the USBaspā€™s developer. Maybe heā€™ll respond.

Thanks Toy Keeper and everyone else for all the hard work. I wish I had something to contribute but Iā€™m only just starting with the flashing but this helps for sure.

I was going through this last night and found a couple that were nice.

For us complete laymen a section with just hex files along with a brief description would really be great, but Beggars canā€™t be choosers right!!

I tried this a while backā€¦ and again just now. It didnā€™t damage anything, but it didnā€™t work very well either. There were two issues:

  • The clip can short some pins, resulting in strange behavior which differs from how the light behaves without the clip attached.
  • The clip doesnā€™t stay on very well on its own, so itā€™s difficult to test the light without the clip coming off.

So, itā€™s generally a not good idea to leave the clip on during testing. Itā€™s possible that the clip could cause damage, and it changes the driver behavior (which kind of invalidates the test results).

TK - I pm'ed you the link to my versions (google_drive_tome_drivers).

Not sure if this is the right thread for this, but here it goes... Your blf-a6 and tk-otc drivers have a couple of features I haven't seen before:

  • The "OWN_DELAY" option to use our own timer delay rather than the delay supplied with the compiler/tool. Interesting because I just noticed on recent Nanjg 101-AK-A1 builds with STARNoInit, the two minutes for a turbo timeout is really 2 mins 20 secs - off by quite a bit
  • you are mixing FET output and the single 7135 output in some modes but not full turbo. This is interesting, and I assume you did test out these combos to find a nice spread of output levels. I notice you didn't publish what the approximate percentage of outputs are in either the source code or blf-a6.txt. Do you have that info now?
  • I assume you set the turbo mode to phase-correct PWM and not fast PWM because it doesn't really matter (PWM's are not used on max setting of 255)

I'm going to try your blf-a6 version on a A17DD-SO8 board. I'm thinking I could just zero set the mode values for the "small circuit" (MODES1x1 and MODES1x2) and set the big circuit PWM mode values to what I normally use for the A17DD-S08. Do you think this would work ok? Is this the easiest approach?

For the future, I plan on dropping the A17DD-S08 driver in favor of wight's FET+1 driver but I still have stock of drivers (most assembled) to use up.

BTW, This BLF-A6 driver is the most advanced for a clicky power switch light I'm aware of in source code. You did a great job on this!! Thanx!!!

Edit: I found one issue in using blf-a6 on a FET only board - the blink'ing is set for the 2nd PWM output port (the 7135), so I simply changed it to the primary PWM port, using a value of 5, and works like a charm now. I added a compile switch for that. From my bench test, it all looked good. Stupid me though -- put it in a Convoy C8 (old style) and it grounded a LED wire lead to the reflector after I tightened the bezel -- fried both the driver and LED Frown. It looked like there was plenty of clearance, but I guess tightening down the bezel really pushed down on the reflector, causing the short...

If i remember correctly, on fast PWM, PWM IS used on maximum setting ( ON for 255/256).
CanĀ“t find the thread at the moment, but it was Dr Jones who discovered that in a commercial firmware.

Very nice work! Hat's off to all of you!