AVR-NET-IO: Den ATmega32 mit avrdude und dem USBtiny ISP flashen
Zum Flashen des AVR-NET-IO Boards wird in dieser Anleitung der USBtiny In-System Programmer (ISP) verwendet, welchen Sie sich selber bauen können. Den benötigten Schaltplan und eine kurze Beschreibung dazu finden Sie unter http://www.gtkdb.de/index_18_1035.html.
Vorbereitungen
Verbinden Sie den USBtiny In-System Programmer mit einem 10 poligen 1:1 Kabel mit dem ISP Connector auf dem AVR-NET-IO Board. Danach verbinden Sie den USBtiny In-System Programmer mit einem USB-Port Ihres Rechners. Schließen Sie erst jetzt die Spannungsversorgung an das AVR-NET-IO Board an.
Flash-Speicher auslesen
Falls Sie vor dem Flashen eine Sicherung des Flash-Speichers erstellen wollen, können Sie diesen durch den folgenden Befehl auslesen und in die Datei avr-net-io-dump.hex speichern.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U flash:r:avr-net-io-dump.hex:h
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading flash memory:
Reading | ################################################## | 100% 17.15s
avrdude: writing output file "avr-net-io-dump.hex"
avrdude: safemode: Fuses OK
avrdude done. Thank you.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading flash memory:
Reading | ################################################## | 100% 17.15s
avrdude: writing output file "avr-net-io-dump.hex"
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Durch die Option -c wird der verwendete Adapter für die Programmierung (hier USBtiny) spezifiziert. Mit -p wird der Mikrocontroller-Typ angegeben. Für den ATmega32 müssen Sie m32 angeben. Durch -U flash:r:avr-net-io-dump.hex:h wird letztendlich festgelegt, dass der Inhalt des Flash-Speichers in die Datei avr-net-io-dump.hex gesichert werden soll.
Flash-Image in den Flash-Speicher schreiben
Als Beispiel soll hier ein Ethersex Flash-Image auf das AVR-NET-IO Board übertragen und in den Flash-Speicher des ATmega32 geschrieben werden.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U flash:w:ethersex.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "ethersex.hex"
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: writing flash (29346 bytes):
Writing | ################################################## | 100% 17.21s
avrdude: 29346 bytes of flash written
avrdude: verifying flash memory against ethersex.hex:
avrdude: load data flash data from input file ethersex.hex:
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: input file ethersex.hex contains 29346 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 15.36s
avrdude: verifying ...
avrdude: 29346 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "ethersex.hex"
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: writing flash (29346 bytes):
Writing | ################################################## | 100% 17.21s
avrdude: 29346 bytes of flash written
avrdude: verifying flash memory against ethersex.hex:
avrdude: load data flash data from input file ethersex.hex:
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: input file ethersex.hex contains 29346 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 15.36s
avrdude: verifying ...
avrdude: 29346 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Durch -U flash:w:ethersex.hex wird festgelegt, dass das Flash-Image ethersex.hex in den Flash-Speicher des Mikrocontrollers geschrieben werden soll.
Flash-Speicher mit einem Flash-Image vergleichen
Falls Sie irgendwann überprüfen wollen, ob der Inhalt des Flash-Speichers mit dem original Flash-Image übereinstimmt, können Sie dies mit dem folgenden Befehl.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U flash:v:ethersex.hex
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: verifying flash memory against ethersex.hex:
avrdude: load data flash data from input file ethersex.hex:
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: input file ethersex.hex contains 29346 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 15.36s
avrdude: verifying ...
avrdude: 29346 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: verifying flash memory against ethersex.hex:
avrdude: load data flash data from input file ethersex.hex:
avrdude: input file ethersex.hex auto detected as Intel Hex
avrdude: input file ethersex.hex contains 29346 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 15.36s
avrdude: verifying ...
avrdude: 29346 bytes of flash verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Fuse-Bits auslesen
Die Fuse-Bits eines Mikrocontrollers dienen zu dessen Konfiguration und können von der darauf laufenden Software nicht verändert werden. Durch die Fuse-Bits können gewisse Funktionen eines Mikrocontrollers ein- oder ausgeschaltet werden.
Der auf dem AVR-NET-IO Board verbaute ATmega32 verfügt über insgesamt 16 Fuse-Bits die als High- und Low-Fuse-Byte zusammengefasst sind. Die aktuellen Zustände der Fuse-Bits können Sie mit dem folgenden Befehl auslesen und in die Dateien hfuse.hex und lfuse.hex speichern.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U hfuse:r:hfuse.hex:h -U lfuse:r:lfuse.hex:h
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading hfuse memory:
Reading | ################################################## | 100% 0.00s
avrdude: writing output file "hfuse.hex"
avrdude: reading lfuse memory:
Reading | ################################################## | 100% 0.00s
avrdude: writing output file "lfuse.hex"
avrdude: safemode: Fuses OK
avrdude done. Thank you.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ cat hfuse.hex
0xca
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ cat lfuse.hex
0xff
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading hfuse memory:
Reading | ################################################## | 100% 0.00s
avrdude: writing output file "hfuse.hex"
avrdude: reading lfuse memory:
Reading | ################################################## | 100% 0.00s
avrdude: writing output file "lfuse.hex"
avrdude: safemode: Fuses OK
avrdude done. Thank you.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ cat hfuse.hex
0xca
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ cat lfuse.hex
0xff
Weitere Informationen zu den Fuse-Bits finden Sie unter http://www.gtkdb.de/index_18_1044.html.
Fuse-Bits setzen
Falls Sie den Mikrocontroller des AVR-NET-IO Boards austauschen oder zusäztliche Funktionen nutzen wollen, müssen Sie gegebenenfalls die Fuse-Bits neu setzen. Dazu verwenden Sie den folgenden Befehl. Die Zustände der Fuse-Bits werden als hexadezimaler Wert angegeben. In diesem Beispiel wird das High-Fuse-Byte mit dem Wert 0xCA und das Low-Fuse-Byte mit dem Wert 0xFF gesetzt.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U hfuse:w:0xca:m -U lfuse:w:0xff:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading input file "0xca"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: reading input file "0xca"
avrdude: writing hfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of hfuse written
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.01s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: reading input file "0xff"
avrdude: writing lfuse (1 bytes):
Writing | ################################################## | 100% 0.00s
avrdude: 1 bytes of lfuse written
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Fuse-Bits vergleichen
Wenn Sie die Zustände der Fuse-Bits nur mit eigenen Werten vergleichen wollen, hilft Ihnen der folgende Befehl weiter.
georg@ubuntu1004:~/ethersex-ethersex-f29e0d7$ sudo avrdude -c usbtiny -p m32 -U hfuse:v:0xca:m -U lfuse:v:0xff:m
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.01s
avrdude: Device signature = 0x1e9502
avrdude: verifying hfuse memory against 0xca:
avrdude: load data hfuse data from input file 0xca:
avrdude: input file 0xca contains 1 bytes
avrdude: reading on-chip hfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of hfuse verified
avrdude: verifying lfuse memory against 0xff:
avrdude: load data lfuse data from input file 0xff:
avrdude: input file 0xff contains 1 bytes
avrdude: reading on-chip lfuse data:
Reading | ################################################## | 100% 0.00s
avrdude: verifying ...
avrdude: 1 bytes of lfuse verified
avrdude: safemode: Fuses OK
avrdude done. Thank you.
Funktionstest
Nachdem das Flash-Image erfolgreich in den Flash-Speicher des Mikrocontrollers geschrieben und gegebenenfalls auch die Fuse-Bits gesetzt wurden, trennen Sie die Spannungsversorgung und den USBtiny In-System Programmer vom AVR-NET-IO Board. Anschließend verbinden Sie das AVR-NET-IO Board mit Ihrem Netzwerk und schließen die Stromversorgung wieder an.
Für einen ersten Funktionstest können Sie jetzt entweder über einen Web-Browser auf das AVR-NET-IO Board zugreifen oder eine Telnet-Verbindung zum Port 2701 aufbauen. Falls Sie die IP-Adresse während der Konfiguration von Ethersex nicht geändert haben, ist das AVR-NET-IO Board unter der IP-Adresse 192.168.0.90 erreichbar.
georg@ubuntu1004:~$ telnet 192.168.10.50 2701
Trying 192.168.10.50...
Connected to 192.168.10.50.
Escape character is '^]'.
version
Aug 2 2010 21:08:30
Trying 192.168.10.50...
Connected to 192.168.10.50.
Escape character is '^]'.
version
Aug 2 2010 21:08:30
Dieser Eintrag wurde am 16.08.2010 erstellt und zuletzt am 12.02.2016 bearbeitet.
Direkter Link zu dieser Seite: http://www.gtkdb.de/index_18_1038.html
[ Zur Startseite ] [ Zur Kategorie ]
© 2004-2021 by Georg Kainzbauer