<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://www.penguindevelopment.org/index.php?action=history&amp;feed=atom&amp;title=Timelapse%2FINSTALL</id>
	<title>Timelapse/INSTALL - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.penguindevelopment.org/index.php?action=history&amp;feed=atom&amp;title=Timelapse%2FINSTALL"/>
	<link rel="alternate" type="text/html" href="https://www.penguindevelopment.org/index.php?title=Timelapse/INSTALL&amp;action=history"/>
	<updated>2026-04-19T18:47:51Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://www.penguindevelopment.org/index.php?title=Timelapse/INSTALL&amp;diff=192&amp;oldid=prev</id>
		<title>Link: Created page with &quot;{{plaintext doc|file=INSTALL|tarball=[http://proj.penguindevelopment.org/timelapse/timelapse-0.1.tar.xz timelapse-0.1.xz]}} &lt;pre&gt;This document describes the general procedure ...&quot;</title>
		<link rel="alternate" type="text/html" href="https://www.penguindevelopment.org/index.php?title=Timelapse/INSTALL&amp;diff=192&amp;oldid=prev"/>
		<updated>2013-08-17T20:22:11Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{plaintext doc|file=INSTALL|tarball=[http://proj.penguindevelopment.org/timelapse/timelapse-0.1.tar.xz timelapse-0.1.xz]}} &amp;lt;pre&amp;gt;This document describes the general procedure ...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{plaintext doc|file=INSTALL|tarball=[http://proj.penguindevelopment.org/timelapse/timelapse-0.1.tar.xz timelapse-0.1.xz]}}&lt;br /&gt;
&amp;lt;pre&amp;gt;This document describes the general procedure of compiling and flashing the&lt;br /&gt;
timelapse firmware. It should be noted that a working Intel Hex file is&lt;br /&gt;
provided, which can be flashed immediately -- unless you really wish to&lt;br /&gt;
compile the firmware yourself, you can skip straight to the FLASHING section.&lt;br /&gt;
&lt;br /&gt;
COMPILING&lt;br /&gt;
In order to compile the firmware from source, it is necessary to have a&lt;br /&gt;
working AVR toolchain. Setting up such a toolchain is beyond the scope of this&lt;br /&gt;
document; it is henceforth assumed that at least a working avr-gcc and&lt;br /&gt;
avr-objcopy are present on the host system. Compilation has been tested with&lt;br /&gt;
avr-gcc-4.8.1, however, different versions should also work (possibly using&lt;br /&gt;
different command-line arguments).&lt;br /&gt;
&lt;br /&gt;
The suggested sequence of commands for compiling the timelapse firmware using&lt;br /&gt;
GCC 4.8.1 is as follows:&lt;br /&gt;
&lt;br /&gt;
  cd src/&lt;br /&gt;
  avr-gcc -std=gnu89 -g -Wall -Os -Wextra -Werror -pedantic \&lt;br /&gt;
    -pedantic-errors -mmcu=attiny2313 -Wl,--as-needed,-Map,timelapse.map \&lt;br /&gt;
    -flto -fwhole-program -mrelax -mstrict-X -maccumulate-args -o timelapse \&lt;br /&gt;
    lcd.c main.c&lt;br /&gt;
  avr-objcopy -j .text -j .data -O ihex timelapse timelapse.hex&lt;br /&gt;
&lt;br /&gt;
Very aggressive size optimisation is necessary to allow the firmware to fit on&lt;br /&gt;
an ATtiny2313 or ATtiny2313A. After successfully compiling the firmware, the&lt;br /&gt;
size of the resulting binary can be determined with the following command:&lt;br /&gt;
&lt;br /&gt;
  avr-size -A timelapse&lt;br /&gt;
&lt;br /&gt;
The sum of the sizes of the .text and .data sections must be 2048 or less for&lt;br /&gt;
the firmware to fit on an ATtiny2313(A). (The hex file shipped in the source&lt;br /&gt;
tarball has, at the time of writing, a cumulative .text and .data size of 2044&lt;br /&gt;
bytes.)&lt;br /&gt;
&lt;br /&gt;
It is important to note that `-mmcu=attiny2313&amp;#039; should be used, even when&lt;br /&gt;
the target device an an ATtiny2313A or ATtiny4313. These newer devices are&lt;br /&gt;
fully backwards-compatible with code compiled for ATtiny2313, however the&lt;br /&gt;
headers specific to these devices as shipped with GCC are presently broken.&lt;br /&gt;
&lt;br /&gt;
The suggested compilation commands should complete without error and should&lt;br /&gt;
result in the creation of the files `timelapse&amp;#039; (an ELF binary),&lt;br /&gt;
`timelapse.map&amp;#039; (a linker map file) and `timelapse.hex&amp;#039; (an Intel HEX file).&lt;br /&gt;
&lt;br /&gt;
COMPILE-TIME CONFIGURATION&lt;br /&gt;
Some elements of the firmware may be configured at compile-time, most&lt;br /&gt;
prominently through editing settings.h. The most prominent options shall&lt;br /&gt;
briefly be explained here; see settings.h for additional documentation.&lt;br /&gt;
&lt;br /&gt;
(1) Clock frequency&lt;br /&gt;
It is possible to run the timelapse board from a number of different crystal&lt;br /&gt;
frequencies. The shipped HEX file assumes 4.096 MHz, however any crystal&lt;br /&gt;
frequency which is divisible by 256 kHz may be used. It is critically&lt;br /&gt;
important that the F_CPU #define in settings.h is set to the correct value&lt;br /&gt;
(i.e. the crystal&amp;#039;s frequency in hertz). Please take care to burn the correct&lt;br /&gt;
fuses for the selected crystal frequency; see the FLASHING section in this&lt;br /&gt;
document.&lt;br /&gt;
&lt;br /&gt;
(2) EEPROM address of runtime configuration&lt;br /&gt;
timelapse stores the user-configured timing settings to the AVR&amp;#039;s EEPROM. By&lt;br /&gt;
default, this information is simply placed at the start of the EEPROM (address&lt;br /&gt;
0x00). The EE_CONFIG_ADDR #define can be used to change this default address.&lt;br /&gt;
Care should be taken that the entire configuration structure fits in the space&lt;br /&gt;
after this address. At the time of writing, the configuration takes twelve&lt;br /&gt;
bytes of space; EE_CONFIG_ADDR should therefore be at least twelve bytes less&lt;br /&gt;
than the total EEPROM size (e.g. on the ATtiny2313(A), which has 128 bytes of&lt;br /&gt;
EEPROM, the maximum value of EE_CONFIG_ADDR is 116). It is highly recommended&lt;br /&gt;
to erase the EEPROM when changing this value!&lt;br /&gt;
&lt;br /&gt;
(3) Debounce time&lt;br /&gt;
The push-buttons on the timelapse board are debounced in software using a&lt;br /&gt;
timer, and the duration of this timer is set by the DEBOUNCE #define. The&lt;br /&gt;
duration in milliseconds is given by 256000*(DEBOUNCE+1)/F_CPU. The default&lt;br /&gt;
value of DEBOUNCE is 799, which gives a duration of 50 ms. If button presses&lt;br /&gt;
are registered twice, increase DEBOUNCE. If some short button presses fail to&lt;br /&gt;
register at all, decrease DEBOUNCE.&lt;br /&gt;
&lt;br /&gt;
FLASHING&lt;br /&gt;
Flashing the firmware requires AVRDUDE[1] or an equivalent program; AVRDUDE&lt;br /&gt;
version 5.11.1 has been confirmed to work. timelapse is in-system&lt;br /&gt;
programmable; this requires a programmer with a six-pin connector. The&lt;br /&gt;
USBTinyISP[2] by Adafruit Industries has been confirmed to work. Programming&lt;br /&gt;
the AVR requires a firmware HEX file; such a file, suitable for the reference&lt;br /&gt;
design, should be provided with the source distribution. See the section&lt;br /&gt;
COMPILING in this document if you wish to compile the firmware yourself.&lt;br /&gt;
&lt;br /&gt;
Perhaps the most important step when flashing the firmware is to ensure the&lt;br /&gt;
fuses are set correctly. The CKSEL and SUT fuses are of particular importance&lt;br /&gt;
as they affect the timing characteristics; the necessary values for these&lt;br /&gt;
fuses depends on the crystal used. Make sure the CKDIV8, CKOUT and WDTON fuses&lt;br /&gt;
are NOT set. With a 4.096 MHz crystal, low, high and extended fuse values of&lt;br /&gt;
0xcd, 0xdf and 0xff, respectively, have been confirmed to work. See the table&lt;br /&gt;
below for recommended fuses:&lt;br /&gt;
&lt;br /&gt;
+---------------+------+------+------+&lt;br /&gt;
| Crystal freq. | Low  | High | Ext  |&lt;br /&gt;
+---------------+------+------+------+&lt;br /&gt;
| 0.4-0.9 MHz   | 0xc9 | 0xdf | 0xff |&lt;br /&gt;
| 0.9-3.0 MHz   | 0xcb | 0xdf | 0xff |&lt;br /&gt;
| 3.0-8.0 MHz   | 0xcd | 0xdf | 0xff |&lt;br /&gt;
| 9.0-20.0 MHz  | 0xcf | 0xdf | 0xff |&lt;br /&gt;
+---------------+------+------+------+&lt;br /&gt;
&lt;br /&gt;
These fuses are valid for ATtiny2313, ATtiny2313A and ATtiny4313.&lt;br /&gt;
Some additional and potentially useful options which should not affect normal&lt;br /&gt;
operation can be set by changing the High fuse. These options are the&lt;br /&gt;
brown-out detector and the EESAVE fuse. The brown-out detector (BOD) resets&lt;br /&gt;
the AVR if the voltage drops below a certain threshold, and the EESAVE fuse&lt;br /&gt;
enables you to preserve the user configuration when re-flashing the AVR. The&lt;br /&gt;
brown-out threshold can be set to 4.3 V, 2.7 V or 1.8 V; only 4.3 V is&lt;br /&gt;
recommended. The table below lists the High fuse value for these options:&lt;br /&gt;
&lt;br /&gt;
+-----+--------+-----------+&lt;br /&gt;
| BOD | EESAVE | High fuse |&lt;br /&gt;
+-----+--------+-----------+&lt;br /&gt;
| No  | No     |      0xdf |&lt;br /&gt;
| Yes | No     |      0xd9 |&lt;br /&gt;
| No  | Yes    |      0x9f |&lt;br /&gt;
| Yes | Yes    |      0x99 |&lt;br /&gt;
+-----+--------+-----------+&lt;br /&gt;
&lt;br /&gt;
Once you have determined the fuses you wish to use, connect the programmer to&lt;br /&gt;
the ISP header (J1). (In the current PCB  design, the pin closest to the&lt;br /&gt;
crystal is pin 1.) Some programmers allow the board to either be self-powered&lt;br /&gt;
or powered by the programmer. If the programmer allows 5 V signals, it is&lt;br /&gt;
recommended to use the self-powered configuration (i.e. powering the timelapse&lt;br /&gt;
board using a 9 V battery, as in normal operation). Powering the timelapse&lt;br /&gt;
board through the programmer is also possible; however, as this reverse-biases&lt;br /&gt;
the on-board regulator, this is not recommended.&lt;br /&gt;
&lt;br /&gt;
Using AVRDUDE, the following commands should program the AVR correctly:&lt;br /&gt;
&lt;br /&gt;
  cd src/&lt;br /&gt;
  avrdude -c usbtiny -p t2313 -U lfuse:w:0xcd:m -U hfuse:w:0xdf:m \&lt;br /&gt;
          -U efuse:w:0xff&lt;br /&gt;
  avrdude -c usbtiny -p t2313 -U flash:w:timelapse.hex&lt;br /&gt;
&lt;br /&gt;
In the above commands, `usbtiny&amp;#039; should be replaced with your programmer of&lt;br /&gt;
choice, and `t2313&amp;#039; should be replaced by t4313 if an ATtiny4313 is used. The&lt;br /&gt;
lfuse, hfuse and efuse settings should of course be set to match the desired&lt;br /&gt;
settings from the tables above.&lt;br /&gt;
&lt;br /&gt;
If the timelapse firmware and fuses have been programmed correctly, the LCD&lt;br /&gt;
should display text immediately after the firmware is flashed (provided it was&lt;br /&gt;
connected during programming). If this does not happen, disconnect the&lt;br /&gt;
programmer and power the timelapse board from an external battery.&lt;br /&gt;
&lt;br /&gt;
LINKS&lt;br /&gt;
[1] http://www.nongnu.org/avrdude/&lt;br /&gt;
[2] http://learn.adafruit.com/usbtinyisp&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Link</name></author>
	</entry>
</feed>