Attiny-wdt » History » Version 7
laforge, 08/23/2022 02:30 PM
1 | 4 | laforge | {{>toc}} |
---|---|---|---|
2 | |||
3 | h1. attiny-wdt |
||
4 | 1 | laforge | |
5 | @attiny-wdt@ is an OSHW + open source firmware project of turning an Attiny{4,5,9,10} microcontroller into a hardware watchdog that can be used to reset another CPU/SoC when it gets stuck. |
||
6 | |||
7 | The primary use case was to use it with Raspberry Pi devices. Those do have a built-in hardware watchdog themselves, but unfortuantelly it is not documented at the register-level and there is no option to enable it straight from the boot loader, so it is not really providing the kind of guarantees one would expect from a watchdog. |
||
8 | |||
9 | 3 | laforge | h2. Operating Principle |
10 | |||
11 | The general idea is to use the Timer/Counter block of the ATTiny9 in the following way: |
||
12 | * Clear the output @OC0B@ on BOTTOM (counter == 0) |
||
13 | ** this generates a rising edge on the @!RESET@ signal of the CPU we're guarding |
||
14 | * Set the output @OC0B@ when counter reaches @OCR0B@ |
||
15 | ** this generates a falling edge on the @!RESET@ signal of the CPU we're guarding |
||
16 | * Wrap the counter once it reaches @OCR0A@ |
||
17 | ** this determines the amount of time until a reset |
||
18 | * Configure any falling edge on the INT0 pin to re-set the counter to zero |
||
19 | ** this is what the software on the CPU we're guarding nees to do to avoid the watchdog from expiring |
||
20 | |||
21 | h2. Pinout |
||
22 | |||
23 | The board contains two connectors: |
||
24 | |||
25 | 5 | laforge | h3. JP3 |
26 | 3 | laforge | |
27 | This header is used in two cases: |
||
28 | # *programming phase:* the firmware into the ATtiny9 (using the TPI protocol) |
||
29 | # *normal use:* To supply VCC to the watchdog and to connect its output with @!RESET/GLOBAL_EN@ of the target |
||
30 | |||
31 | 1 | laforge | |_.Number|_.Name|_.Description|_.Programming Function| |
32 | 5 | laforge | |1|GLOBAL_EN|open collector watchdog output; xpected to be connected to the !RESET of the CPU we're guarding (or GLOBAL_EN in case of Raspi)|-| |
33 | |2|VCC|3.3V supply voltage powering the watchdog|VCC| |
||
34 | |3|TPICLK|-|TPICLK| |
||
35 | |4|PB0|-|TPIDATA| |
||
36 | |5|!RESET|-|!RESET| |
||
37 | |6|GND|Ground|GND| |
||
38 | 3 | laforge | |
39 | |||
40 | h3. JP2 |
||
41 | |||
42 | |_.Number|_.Name|_.Description| |
||
43 | |1|GND|Ground| |
||
44 | |2|PB2|Input; any falling edge re-sets the counter to zero. Connected to GPIO26 on Raspi| |
||
45 | |3|PB0/GPIO19|No function; RFU| |
||
46 | |||
47 | 1 | laforge | h2. Pictures |
48 | |||
49 | The pictures below show one of the first hand-soldered prototypes: |
||
50 | |||
51 | 6 | laforge | {{thumbnail(attiny_wdt_v2_top.jpg)}} {{thumbnail(attiny_wdt_v2_bot.jpg)}} |
52 | 5 | laforge | |
53 | h2. Flashing |
||
54 | |||
55 | You need |
||
56 | * an attiny-wdt |
||
57 | * a TPI-capable programmer for ATtiny9, such as the "guloprog":https://guloshop.de/shop/Mikrocontroller-Programmierung/guloprog-der-Programmer-von-guloshop-de::70.html |
||
58 | * a 2x3 to 1x5pin adapter cable (custo made) to connect the guloprog TPI Connector to attiny JP3 |
||
59 | * a Linux machine with "avrdude":https://www.nongnu.org/avrdude/ (e.g. installed via @apt install avrdude@ on Debian/Ubuntu). Tested with avrdude 6.3 |
||
60 | |||
61 | h3. Physical connection |
||
62 | |||
63 | h4. full setup with usb cable, guloprog, 2x3-1x5 cable and attiny-wdt: |
||
64 | |||
65 | {{thumbnail(attiny_wdt_with_gulprog_cable.jpg)}} |
||
66 | |||
67 | h4. detailed view of 2x3 cable in guloprog |
||
68 | |||
69 | {{thumbnail(guloprog_with_cable.jpg)}} |
||
70 | |||
71 | h4. detailed view of 1x5 cable in attiny-wdt |
||
72 | |||
73 | {{thumbnail(attiny_with_cable.jpg)}} |
||
74 | |||
75 | h3. avrdude command for flashing |
||
76 | |||
77 | Assuming your firmware file is called @attiny-wdt.hex@, you can use the fa command like: |
||
78 | <pre> |
||
79 | avrdude -p attiny9 -P usb -c usbasp -U flash:w:attiny-wdt.hex |
||
80 | </pre> |
||
81 | |||
82 | The successful output looks like this: |
||
83 | |||
84 | <pre> |
||
85 | avrdude: AVR device initialized and ready to accept instructions |
||
86 | |||
87 | Reading | ################################################## | 100% 0.00s |
||
88 | |||
89 | avrdude: Device signature = 0x1e9008 (probably t9) |
||
90 | avrdude: NOTE: "flash" memory has been specified, an erase cycle will be performed |
||
91 | To disable this feature, specify the -D option. |
||
92 | avrdude: erasing chip |
||
93 | avrdude: reading input file "attiny-wdt.hex" |
||
94 | avrdude: input file attiny-wdt.hex auto detected as Intel Hex |
||
95 | avrdude: writing flash (116 bytes): |
||
96 | |||
97 | Writing | ################################################## | 100% 0.41s |
||
98 | |||
99 | avrdude: 116 bytes of flash written |
||
100 | avrdude: verifying flash memory against attiny-wdt.hex: |
||
101 | avrdude: load data flash data from input file attiny-wdt.hex: |
||
102 | avrdude: input file attiny-wdt.hex auto detected as Intel Hex |
||
103 | avrdude: input file attiny-wdt.hex contains 116 bytes |
||
104 | avrdude: reading on-chip flash data: |
||
105 | |||
106 | Reading | ################################################## | 100% 0.04s |
||
107 | |||
108 | avrdude: verifying ... |
||
109 | avrdude: 116 bytes of flash verified |
||
110 | |||
111 | avrdude done. Thank you. |
||
112 | </pre> |
||
113 | 7 | laforge | |
114 | h2. LED test assembly. |
||
115 | |||
116 | This is a small helper that allows to test attiny-wdt without a Raspi target device. It will illuminate a yellow LED whenever the GLOBAL_EN (reset) is asserted. |
||
117 | |||
118 | {{thumbnail(attiny_wdt_led_test.jpg)}} |