avr:usage
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| avr:usage [2013/09/10 13:07] – created sdolt | avr:usage [2016/11/09 16:49] (current) – [Liens utiles] sbolay | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Programmation de microprocesseur AVR sous GNU/ | + | ====== Programmation de microprocesseur |
| ===== Premier programme ===== | ===== Premier programme ===== | ||
| 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 | ||
| - | < | + | < |
| # | # | ||
| # | # | ||
| Line 16: | Line 16: | ||
| - | ===== Câblage | + | ===== Câblage ===== |
| - | + | Pour le câblage, se référer à cette page : [[avr:pinout]] | |
| - | [[http:// | + | |
| ===== Compilation et programmation ===== | ===== Compilation et programmation ===== | ||
| Line 31: | 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:// | |Autre|Voir [[http:// | ||
| - | <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 / | avrdude -p t85 -c stk500 -P / | ||
| - | </file> | + | </code> |
| ===== Déboguage ===== | ===== Déboguage ===== | ||
| Line 49: | Line 51: | ||
| Pour l' | Pour l' | ||
| - | des fusibles de configurations à l' | + | des fusibles de configurations à l' |
| <note important> | <note important> | ||
| Exemple pour l' | Exemple pour l' | ||
| - | <file.sh> | + | <code.bash> |
| avrdude -p t85 -c stk500 -P / | avrdude -p t85 -c stk500 -P / | ||
| - | </file> | + | </code> |
| - | + | ||
| - | ==== Câblage du JTAGICE mkII pour debug-wire ==== | + | |
| - | Il faut brancher trois câble | + | Pour le câblage, se référer à cette page : [[avr: |
| - | ^STK500 PORTB^JTAGICE^ | + | |
| - | |PB5|6-nSRST| | + | |
| - | |VTG|4-VTREF| | + | |
| - | |GND|2-GND| | + | |
| ==== Compilation et programmation ==== | ==== Compilation et programmation ==== | ||
| Line 71: | Line 67: | ||
| <note warning> | <note warning> | ||
| - | <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: | avrdude -c jtag2dw -P usb -p t85 -U flash: | ||
| - | </file> | + | </code> |
| Si l' | Si l' | ||
| Line 82: | Line 78: | ||
| Pour débuguer, il faut tout d' | Pour débuguer, il faut tout d' | ||
| - | <file.sh> | + | <file.bash> |
| avarice -2 -w -P attiny85 --jtag usb :4242 | avarice -2 -w -P attiny85 --jtag usb :4242 | ||
| </ | </ | ||
| 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 | ||
| </ | </ | ||
| Dans l' | Dans l' | ||
| - | <file.sh> | + | <file.gdb> |
| target remote :4242 | target remote :4242 | ||
| </ | </ | ||
| Line 111: | 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: |
| - | |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 | avrdude -c jtag2isp | ||
| </ | </ | ||
| On obtient le message suivant : | On obtient le message suivant : | ||
| - | <file.sh> | + | <file.bash> |
| avrdude: jtagmkII_setparm(): | avrdude: jtagmkII_setparm(): | ||
| avrdude: jtagmkII_getsync(): | avrdude: jtagmkII_getsync(): | ||
| Line 143: | 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 | avrdude -c jtag2isp | ||
| </ | </ | ||
| Line 152: | Line 138: | ||
| ^Description^Liens^ | ^Description^Liens^ | ||
| |Calculateur de fusible|[[http:// | |Calculateur de fusible|[[http:// | ||
| + | |Comprendre les registres d' | ||
| + | |AVR-GCC for OSX|[[https:// | ||
| + | ===== FAQ ===== | ||
| + | see error " | ||
| + | look especially to the position of the **-lm** flag | ||
| + | |||
| + | <code bash> | ||
| + | $ avr-gcc -mmcu=attiny85 -o main.elf main.c | ||
| + | / | ||
| + | / | ||
| + | collect2: ld returned 1 exit status | ||
| + | |||
| + | $ avr-gcc -mmcu=attiny85 -lm -o main.elf main.c | ||
| + | / | ||
| + | / | ||
| + | collect2: ld returned 1 exit status | ||
| + | |||
| + | $ avr-gcc -mmcu=attiny85 -o main.elf main.c -lm | ||
| + | $ | ||
| + | </ | ||
avr/usage.1378818473.txt.gz · Last modified: 2013/09/10 13:07 by sdolt