~toykeeper/flashlight-firmware/trunk

1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
1
ToyKeeper's flashlight firmware repository
2
==========================================
3
4
This is a collection of firmware for flashlights or torches, mostly 
5
collected from BLF (http://budgetlightforum.com/).  It's collected 
6
here mostly for convenience, and to provide bug tracking and revision 
7
control services for the code.
8
124.1.4 by Selene Scriven
minor top-level doc updates
9
See the INDEX file to find out which projects might be relevant to 
10
your needs.
11
1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
12
13
Getting Started
14
===============
15
192 by Selene Scriven
Added my firmware thread to the readme.
16
The central firmware thread on BLF is here:
17
18
  http://budgetlightforum.com/node/38364
19
1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
20
A general overview of what you need to get going is here:
21
22
  http://flashlightwiki.com/AVR_Drivers
23
93 by Selene Scriven
added links to flashing hardware
24
Some useful hardware for flashing firmware:
25
207 by Selene Scriven
Added some README info from Ratus: cheaper flashing hardware.
26
  What TK uses:
27
28
    http://www.fasttech.com/product/1002900-atmega-attiny-51-avr-isp-usbasp-usb-programmer
29
    http://www.fasttech.com/product/1011800-40-pin-splittable-ribbon-cable-20cm
30
    http://www.digikey.com/product-detail/en/5250/501-1311-ND/745102
229 by Selene Scriven
added link to HQ ProgKey, since it's increasingly important for newer drivers
31
    HQ ProgKey: http://budgetlightforum.com/node/63230
207 by Selene Scriven
Added some README info from Ratus: cheaper flashing hardware.
32
33
  Ratus' guide:  https://redd.it/8g5l5w  (prices checked 2018-05-01)
34
35
    Store A: About $4.20 shipped
36
      https://www.aliexpress.com/item/USB-ISP-Programmer-for-ATMEL-AVR-ATMega-ATTiny-51-AVR-Board-ISP-Downloader/32699341177.html
37
      https://www.aliexpress.com/item/WAVGAT-Programmer-Testing-Clip-SOP8-SOP-SOIC-8-SOIC8-DIP8-DIP-8-Pin-IC-Test-Clamp/32827794024.html
38
      https://www.aliexpress.com/item/40Pin-20CM-2-54MM-Row-Female-to-Female-F-F-Dupont-Cable-Breadboard-Jumper-Wire-for/32822958653.html
39
40
    Store B: About $4.18 shipped:
41
      https://www.aliexpress.com/store/product/1pcs-New-USBASP-USBISP-AVR-Programmer-USB-ISP-USB-ASP-ATMEGA8-ATMEGA128-Support-Win7-64K/1171090_32809542958.html
42
      https://www.aliexpress.com/store/product/Free-shipping-Programmer-Testing-Clip-SOP8-SOP-SOIC-8-SOIC8-DIP8-DIP-8-Pin-IC-Test/1171090_32402561848.html
43
      https://www.aliexpress.com/store/product/20pcs-20cm-2-54mm-1p-1p-Pin-Female-to-Female-Color-Breadboard-Cable-Jump-Wire-Jumper/1171090_32628811461.html
93 by Selene Scriven
added links to flashing hardware
44
242 by Selene Scriven
added oweban's flashing guides to the README
45
For Windows / MacOS users, these links may be useful:
46
47
  Oweban's guides:  (Windows 10, MacOS X) (not generic, focuses on Anduril)
48
49
    http://budgetlightforum.com/node/73487
132 by Selene Scriven
Improved info for Windows users in the README.
50
51
  Hoop's guide:
52
53
    http://budgetlightforum.com/node/36216
54
55
  Comfychair's guide:
56
57
    http://budgetlightforum.com/node/29081
58
59
  WarHawk-AVG's guide:
60
61
    http://budgetlightforum.com/node/29684
62
174 by Selene Scriven
Added info about getting USBasp to work in Windows (especially Windows 10).
63
  Getting a USBasp to work in Windows:
64
65
    http://rayshobby.net/dead-simple-driver-installation-for-usbasp-and-usbtiny-on-windows/
66
    http://www.protostack.com/accessories/usbasp-avr-programmer
67
1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
68
To set up an attiny dev environment on Ubuntu (13.10):
69
70
  sudo apt-get install flex byacc bison gcc libusb-dev libc6-dev
71
  sudo apt-get install gcc-avr avr-libc binutils-avr
72
  sudo apt-get install avrdude avrdude-doc
73
132 by Selene Scriven
Improved info for Windows users in the README.
74
  Optional:  (make avrdude usable by non-root users, is a security risk)
75
  sudo chmod u+s $(which avrdude)
76
233 by Selene Scriven
Added setup info for Fedora.
77
To set up an attiny dev environment on Fedora (30):
78
79
  sudo dnf install flex byacc bison gcc libusb libusb-devel glibc-devel
80
  sudo dnf install avr-gcc avr-libc avr-binutils
81
  sudo dnf install avrdude
82
132 by Selene Scriven
Improved info for Windows users in the README.
83
Building/installing attiny dev tools on other UNIX systems (in general):
1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
84
85
  http://www.ladyada.net/learn/avr/setup-unix.html
86
87
After wiring everything up, this tests the connection to the ATTINY13A chip:
88
89
  avrdude -p t13 -c usbasp -n
24 by Selene Scriven
Started adding contributions from DrJones.
90
  (you may need to put 'sudo' in front, on UNIX systems...
91
  or set the suid bit on the avrdude binary, which is convenient but a
92
  potential security risk)
93
94
To test if you can flash firmware correctly, or to restore a light to something
95
like a default state, try flashing the NLITE driver from DrJones.  It's similar
96
to the default nanjg / qlite firmware, but better.
97
224 by Selene Scriven
Updated README to point at build/flash scripts.
98
  ./bin/flash-tiny13.sh DrJones/NLITE/nlite.hex
1 by Selene Scriven
Starting a new flashlight firmware repository... just the README so far.
99
4 by Selene Scriven
Included a precompiled version of 'hello world' so people can test the
100
For a quick test to make sure your tool chain works and your flashing tools
101
are working, try the 'hello world' program:
102
103
  cd hello_world
104
  make
105
  make flash
106
24 by Selene Scriven
Started adding contributions from DrJones.
107
If that works, you should be ready to start making changes to the code, or
108
flashing any of the pre-built firmwares.
224 by Selene Scriven
Updated README to point at build/flash scripts.
109
110
Most projects can be compiled with the bin/build.sh script.  For example, to
111
build Crescendo for an attiny25-based driver and then flash it:
112
113
  cd ToyKeeper/crescendo
114
  ../../bin/build.sh 25 crescendo
115
  ../../bin/flash-tiny25.sh crescendo.hex
116
117
Other useful tools are in bin/ too, so they might be worth a look.
188.25.2 by Selene Scriven
Added attiny1616 info to the README, and made bin/build.sh support more flexible.
118
119
120
ATtiny Series 1 (tiny1616) Support
121
==================================
122
188.22.165 by Selene ToyKeeper
just a couple quick notes on using attiny1616, since the process is still evolving
123
In Feb 2022, avr-libc merged in new devices from Atmel's DFP (Device Family
124
Pack).  Depending on how recent your avr-libc package is, support may already
125
be included.  If not, the info below applies:
126
188.25.2 by Selene Scriven
Added attiny1616 info to the README, and made bin/build.sh support more flexible.
127
As of early 2021, the Debian packages for gcc-avr and avrdude do not include
128
support for the Tiny1 series chips.  Extra steps are required to get these
129
working.
130
131
  - Download the Atmel ATtiny Series Device Support pack:
132
    http://packs.download.atmel.com/
133
134
  - Unzip the pack somewhere on your build computer
135
136
  - Set ATTINY_DFP=/path/to/where/you/unzipped/the/pack
137
    (either in your shell, or in this repo's bin/build.sh script)
188.25.8 by Selene Scriven
added attiny1616 flashing instructions, and made flash-tiny1616.sh configurable via environment variables
138
139
    export ATTINY_DFP=$HOME/src/torches/atmel/attiny-dfp
140
188.25.2 by Selene Scriven
Added attiny1616 info to the README, and made bin/build.sh support more flexible.
141
  - Make sure you're using gcc-avr 1:5.4.0+Atmel3.6.2 or newer.
142
    3.6.1 will not work.  It gives errors like:
143
    /usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: address 0x80381e of anduril.elf section `.data' is not within region `data'
144
    This requires debian/bullseye or newer; buster has 3.6.1.
188.25.8 by Selene Scriven
added attiny1616 flashing instructions, and made flash-tiny1616.sh configurable via environment variables
145
188.25.2 by Selene Scriven
Added attiny1616 info to the README, and made bin/build.sh support more flexible.
146
This should at least allow the code to compile.
188.25.8 by Selene Scriven
added attiny1616 flashing instructions, and made flash-tiny1616.sh configurable via environment variables
147
188.22.165 by Selene ToyKeeper
just a couple quick notes on using attiny1616, since the process is still evolving
148
Flashing:
149
150
PyMCUProg
151
152
The recommended solution is to use pymcuprog instead of avrdude.  Details are
153
still being worked out for how to actually set this up though.
154
155
AvrDude
156
188.25.8 by Selene Scriven
added attiny1616 flashing instructions, and made flash-tiny1616.sh configurable via environment variables
157
Some extra steps are also needed to make flashing (avrdude) work:
158
159
  - Get an AVR jtag2 device.
160
    The one I'm using is: "HWAYEH AVR JTAG ICE Version 2.0"
161
    Connect the cables:
162
      - GND   = -
163
      - Vtref = +
164
      - nSRST = R (reset/UPDI)
165
166
  - Flash the jtag2 device with the relevant firmware:
167
    https://github.com/ElTangas/jtag2updi/tree/master/tools/avrjtagicev2
168
169
  - Get an avrdude.conf which supports jtag2updi:
170
171
    - Download avrdude.conf from https://github.com/ElTangas/jtag2updi
172
      and put it in /etc
173
174
    - Or grab the source and set an environment variable:
175
176
      cd ~/src/torches/avrdude
177
      git clone https://github.com/ElTangas/jtag2updi
178
      export AVRDUDE_CONF="-C$HOME/src/torches/avrdude/jtag2updi/avrdude.conf"
179
180
  - Maybe configure which USB serial port to use too:
181
    export AVRDUDE_TTYUSB="/dev/ttyUSB2"
182
183
Afterward, flashing should work.  You may need to unplug and replug the jtag2
184
USB device between uses though, since it may stop responding after each use.