User Tools

Site Tools


avr:usage

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
avr:usage [2013/09/10 15:59] sdoltavr:usage [2016/11/09 16:49] (current) – [Liens utiles] sbolay
Line 3: Line 3:
  
 Squelette de base pour les programmes AVR à créer dans un fichier main.c Squelette de base pour les programmes AVR à créer dans un fichier main.c
-<file.c>+<file c main.c>
 #include<stdint.h> // Ajout des types int#_t et uint#_t, # vaut 8 , 16 ou 32 #include<stdint.h> // Ajout des types int#_t et uint#_t, # vaut 8 , 16 ou 32
 #include<avr/io.h> // Utilisation des entrées sorties #include<avr/io.h> // Utilisation des entrées sorties
Line 30: Line 30:
 ^Programmateur^AVRDUDE^ ^Programmateur^AVRDUDE^
 |Atmel STK500|stk500| |Atmel STK500|stk500|
 +|Atmel JTAGICE mkII mode ISP|jtag2isp|
 +|Atmel JTAGE ICE mkII mode DebugWire|jtage2dw|
 +|Atmel AVR ISP mkII|avrisp2|
 |Autre|Voir [[http://www.nongnu.org/avrdude/user-manual/avrdude_4.html|le manuel]]| |Autre|Voir [[http://www.nongnu.org/avrdude/user-manual/avrdude_4.html|le manuel]]|
  
  
-<file.sh>+<code.bash>
 avr-gcc -mmcu=attiny85 -o main.elf main.c avr-gcc -mmcu=attiny85 -o main.elf main.c
-objcopy -O ihex -R .eeprom main.elf main.hex+avr-objcopy -O ihex -R .eeprom main.elf main.hex
 avrdude -p t85 -c stk500 -P /dev/ttyUSB0 -U flash:w:main.hex avrdude -p t85 -c stk500 -P /dev/ttyUSB0 -U flash:w:main.hex
  
  
-</file>+</code>
  
 ===== Déboguage ===== ===== Déboguage =====
Line 48: Line 51:
  
 Pour l'enclencher, il faut modifier la valeur Pour l'enclencher, il faut modifier la valeur
-des fusibles de configurations à l'aide du STK500+des fusibles de configurations à l'aide d'un programmateur ISP comme le STK500
 <note important>Le STK500 ne gère pas le mode debug-wire, il faudra ensuite utiliser le JTAGICEmkII</note> <note important>Le STK500 ne gère pas le mode debug-wire, il faudra ensuite utiliser le JTAGICEmkII</note>
  
 Exemple pour l'Attiny85, avec utilisation de l'horloge interne 8MHz sans divisions et debug-wire activé. Exemple pour l'Attiny85, avec utilisation de l'horloge interne 8MHz sans divisions et debug-wire activé.
-<file.sh>+<code.bash>
 avrdude -p t85 -c stk500 -P /dev/ttyUSB0 -U lfuse:w:0xfe:m -U hfuse:w:0x9f:m -U efuse:w:0xff: avrdude -p t85 -c stk500 -P /dev/ttyUSB0 -U lfuse:w:0xfe:m -U hfuse:w:0x9f:m -U efuse:w:0xff:
-</file>+</code>
  
-==== Câblage du JTAGICE mkII pour debug-wire ==== +Pour le câblage, se référer à cette page [[avr:pinout]]
- +
-Il faut brancher trois câble : +
-^STK500 PORTB^JTAGICE^ +
-|PB5|6-nSRST| +
-|VTG|4-VTREF| +
-|GND|2-GND|+
  
 ==== Compilation et programmation ==== ==== Compilation et programmation ====
Line 70: Line 67:
 <note warning>La désactivation des optimisations empêche le fonctionnement normal des fonctions de <util/delay.h> comme _delay_us() </note> <note warning>La désactivation des optimisations empêche le fonctionnement normal des fonctions de <util/delay.h> comme _delay_us() </note>
  
-<file.sh>+<code.bash>
 avr-gcc -g -mmcu=attiny85 -o main.elf main.c avr-gcc -g -mmcu=attiny85 -o main.elf main.c
 objcopy -O ihex -R .eeprom main.elf main.hex objcopy -O ihex -R .eeprom main.elf main.hex
 avrdude -c jtag2dw -P usb -p t85 -U flash:w:main.hex avrdude -c jtag2dw -P usb -p t85 -U flash:w:main.hex
-</file>+</code>
  
 Si l'upload ne fonctionne pas, un redémarrage de l'Attiny peut aider. Si l'upload ne fonctionne pas, un redémarrage de l'Attiny peut aider.
Line 81: Line 78:
  
 Pour débuguer, il faut tout d'abord lance avarice : Pour débuguer, il faut tout d'abord lance avarice :
-<file.sh>+<file.bash>
 avarice -2 -w -P attiny85 --jtag usb :4242 avarice -2 -w -P attiny85 --jtag usb :4242
 </file> </file>
 Puis, dans un autre terminal, on lance avr-gdb: Puis, dans un autre terminal, on lance avr-gdb:
-<file.sh>+<file.bash>
 avr-gdb main.elf avr-gdb main.elf
 </file> </file>
  
 Dans l'invite de commande gdb, on peut connecter gdb à avarice avec la commande: Dans l'invite de commande gdb, on peut connecter gdb à avarice avec la commande:
-<file.sh>+<file.gdb>
 target remote :4242 target remote :4242
 </file> </file>
Line 110: Line 107:
 Avec le mode debugWire, on ne peux pas lire les fusibles. Pour désactiver le mode debugWire, il faut connecter le programmateur JTAGICE mkII en mode ISP, soit : Avec le mode debugWire, on ne peux pas lire les fusibles. Pour désactiver le mode debugWire, il faut connecter le programmateur JTAGICE mkII en mode ISP, soit :
  
-^JTAG 10pin^ISP 6pin^STK500^ +Pour le câblage, se référer à cette page : [[avr:pinout]]
-|1-TCK|3|PB2 (SCK)| +
-|2-GND|6|GND| +
-|3-TDO|1|PB1 (MISO)| +
-|4-VTref|2|Vcc| +
-|5-TMS|x|x| +
-|6-nSRST|5|PB5 (RST)| +
-|7-Vsupply|x|x| +
-|8-nTRST|x|x| +
-|9-TDI|4|PB0 (MOSI )| +
-|10-GND|x| x|+
  
  
 Mainteant, si on essaie de programmer de désactiver debugWire : Mainteant, si on essaie de programmer de désactiver debugWire :
  
-<file.sh>+<file.bash>
 avrdude -c jtag2isp  -P usb:070000004DAA  -p t85 -U hfuse:w:0xdf:m avrdude -c jtag2isp  -P usb:070000004DAA  -p t85 -U hfuse:w:0xdf:m
 </file> </file>
  
 On obtient le message suivant : On obtient le message suivant :
-<file.sh>+<file.bash>
 avrdude: jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED avrdude: jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED
 avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire
Line 142: Line 129:
 On peut donc relancer la commande pour programmer le fusible hfuse. On peut donc relancer la commande pour programmer le fusible hfuse.
  
-<file.sh>+<file.bash>
 avrdude -c jtag2isp  -P usb:070000004DAA  -p t85 -U hfuse:w:0xdf:m avrdude -c jtag2isp  -P usb:070000004DAA  -p t85 -U hfuse:w:0xdf:m
 </file> </file>
Line 151: Line 138:
 ^Description^Liens^ ^Description^Liens^
 |Calculateur de fusible|[[http://www.engbedded.com/fusecalc/]]| |Calculateur de fusible|[[http://www.engbedded.com/fusecalc/]]|
 +|Comprendre les registres d'entrée/sortie|[[http://iamsuhasm.wordpress.com/tutsproj/avr-gcc-tutorial/]]|
 +|AVR-GCC for OSX|[[https://obdev.at/products/crosspack/download.html]]|
 +===== FAQ =====
 +see error  "multiple definition of `_floatsisf'"
 +look especially to the position of the **-lm** flag
 +
 +<code bash>
 +$ avr-gcc -mmcu=attiny85 -o main.elf main.c
 +/usr/local/CrossPack-AVR-20130212/lib/gcc/avr/4.6.2/../../../../avr/lib/avr25/libc.a(floatsisf.o):../../../libm/fplib/floatsisf.S:46: multiple definition of `__floatsisf'
 +/usr/local/CrossPack-AVR-20130212/lib/gcc/avr/4.6.2/avr25/libgcc.a(_si_to_sf.o):/Users/cs/Developer/Repos/Microcontroller/CrossPack-AVR/compile/avr-gcc-4.6.2/build-objects/avr/avr25/libgcc/../../.././gcc/fp-bit.c:1336: first defined here
 +collect2: ld returned 1 exit status
 +
 +$ avr-gcc -mmcu=attiny85 -lm -o main.elf main.c
 +/usr/local/CrossPack-AVR-20130212/lib/gcc/avr/4.6.2/../../../../avr/lib/avr25/libc.a(floatsisf.o):../../../libm/fplib/floatsisf.S:46: multiple definition of `__floatsisf'
 +/usr/local/CrossPack-AVR-20130212/lib/gcc/avr/4.6.2/avr25/libgcc.a(_si_to_sf.o):/Users/cs/Developer/Repos/Microcontroller/CrossPack-AVR/compile/avr-gcc-4.6.2/build-objects/avr/avr25/libgcc/../../.././gcc/fp-bit.c:1336: first defined here
 +collect2: ld returned 1 exit status
 +
 +$ avr-gcc -mmcu=attiny85 -o main.elf main.c -lm
 +
 +</code>
avr/usage.txt · Last modified: 2016/11/09 16:49 by sbolay