AVR Embedded Tutorial - Various programmers: what changed
Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.
| Old | New | Line | |
|---|---|---|---|
| 1 | 1 | ## General | |
| 2 | 2 | ||
| 3 | 3 | ### Arduino IDE | |
| 4 | 4 | ||
| 5 | 5 | The easiest way is to determine the necessary parameters for avrdude is to first program the appropriate AVR with the Arduino IDE. | |
| 6 | 6 | ||
| 7 | 7 | Please refer to [[AVR Embedded Tutorial - Set up Lazarus for ATmega and ATTiny|Set up Lazarus for ATmega and ATTiny]]. | |
| 8 | 8 | ||
| 9 | 9 | When programming the AVR for the first time, a boot loader is needed and this is best burned with the Arduino IDE. | |
| 10 | 10 | ||
| 11 | 11 | If you want to change the clock frequency or other parameters, you also have to re-burn the boot loader so that these FUSE parameters are also re-written. | |
| 12 | 12 | ||
| 13 | 13 | ### Lazarus IDE | |
| 14 | 14 | ||
| 15 | 15 | The parameters which you determined using the Arduino IDE are entered in Lazarus under: | |
| 16 | 16 | ||
| 17 | 17 | - "Project \> Project settings ... \> Compiler commands \> Execute after" is entered. | |
| 18 | 18 | ||
| 19 | 19 | The parameters look something like this for an Arduino Nano: | |
| 20 | 20 | ||
| 21 | 21 | ``` bash | |
| 22 | 22 | /home/tux/Programme/arduino-1.8.5/hardware/tools/avr/bin/avrdude -C/home/tux/Programme/arduino-1.8.5/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -Uflash:w:Project1.hex:i | |
| 23 | 23 | ``` | |
| 24 | 24 | ||
| 25 | 25 | ### Install Avrdude | |
| 26 | 26 | ||
| 27 | 27 | If you install avrdude, you can shorten the starting parameter list for Lazarus a lot. | |
| 28 | 28 | ||
| 29 | 29 | #### Linux | |
| 30 | 30 | ||
| 31 | 31 | ``` bash | |
| 32 | 32 | sudo apt-get install avrdude | |
| 33 | 33 | ``` | |
| 34 | 34 | ||
| 35 | 35 | Note: When it comes to Linux package management, avrdude is usually somewhat older than the current version. Usually this is not a problem unless you are using brand new hardware. | |
| 36 | 36 | ||
| 37 | 37 | ### Shortened parameters | |
| 38 | 38 | ||
| 39 | 39 | Since avrdude is in the search path, you can save the entire path specification. The line with avrdude.conf is also not required, since the default avrdude.conf is used, with Linux this is located at /etc/avrdude.conf. | |
| 40 | 40 | ||
| 41 | 41 | ``` bash | |
| 42 | 42 | avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -D -Uflash:w:Project1.hex:i | |
| 43 | 43 | ``` | |
| 44 | 44 | ||
| 45 | 45 | ## Programming via USB | |
| 46 | 46 | ||
| 47 | 47 | Most Arduinos are programmed via USB which looks like this for the following Arduinos: | |
| 48 | 48 | ||
| 49 | 49 | - Arduino UNO: | |
| 50 | 50 | - avrdude -v -patmega328p -carduino -P/dev/ttyACM0 -b115200 -Uflash:w:Project1.hex:i | |
| 51 | 51 | - Arduino Nano, old boot loader (available on most Chinese clones): | |
| 52 | 52 | - avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b57600 -Uflash:w:Project1.hex:i | |
| 53 | 53 | - Arduino Nano, new boot loader (will be used from early 2018): | |
| 54 | 54 | - avrdude -v -patmega328p -carduino -P/dev/ttyUSB0 -b115200 -Uflash:w:Project1.hex:i | |
| 55 | 55 | ||
| 56 | 56 | ## Programming via ISP | |
| 57 | 57 | ||
| 58 | 58 | Arduinos can also be programmed via ISP where the Arduino is connected to an ISP programmer via the 6-pin header. With naked AVR chips, this is done in the same way, only you have to solder the 6-pin connector yourself. | |
| 59 | 59 | ||
| 60 | 60 | ### USBasp | |
| 61 | 61 | ||
| 62 | - | ||
| 62 | + | ```text | |
| 63 | 63 | Atmega328p or Arduino Nano, with an aspISP programmer. | |
| 64 | 64 | ``` | |
| 65 | 65 | ||
| 66 | 66 | #### Linux | |
| 67 | 67 | ||
| 68 | 68 | ``` bash | |
| 69 | 69 | avrdude -v -patmega328p -cusbasp -Pusb -Uflash:w:Project1.hex:i | |
| 70 | 70 | ``` | |
| 71 | 71 | ||
| 72 | 72 | #### Windows | |
| 73 | 73 | ||
| 74 | 74 | The following driver must be installed <https://zadig.akeo.ie/> - USBasp driver | |
| 75 | 75 | ||
| 76 | - | ||
| 76 | + | ```text | |
| 77 | 77 | [Path]\avrdude.exe -v -patmega328p -cusbasp -Pusb -Uflash:w:Project1.hex:i | |
| 78 | 78 | ``` | |
| 79 | 79 | ||
| 80 | 80 | ### Arduino ISP | |
| 81 | 81 | ||
| 82 | 82 | Homemade ISP programmer with an Arduino, according to these tutorials: | |
| 83 | 83 | ||
| 84 | 84 | - <https://flazer.de/blog/14/arduino-atmel-flash-station> - with control LEDs | |
| 85 | 85 | - <https://playground.boxtec.ch/doku.php/arduino/attiny> - without control LEDs, or search for "arduino attiny isp" . | |
| 86 | 86 | - ATTiny2313 with modified Arduino as an ISP programmer. | |
| 87 | 87 | ||
| 88 | 88 | ``` bash | |
| 89 | 89 | avrdude -v -pattiny2313 -cstk500v1 -P / dev / ttyUSB0 -b19200 -Uflash:w:Project1.hex: i | |
| 90 | 90 | ``` | |
| 91 | 91 | ||
| 92 | 92 | ### Release the USB port | |
| 93 | 93 | ||
| 94 | 94 | The USB port may be blocked which causes the following error to occur: | |
| 95 | 95 | ||
| 96 | - | ||
| 96 | + | ```text | |
| 97 | 97 | avrdude: Warning: cannot open USB device: Permission denied | |
| 98 | 98 | avrdude: error: could not find USB device with vid=0x16c0 pid=0x5dc vendor='www.fischl.de' product='USBasp' | |
| 99 | 99 | ``` | |
| 100 | 100 | ||
| 101 | 101 | With Ubuntu-based Linux you can fix this by installing AVRdude as follows: | |
| 102 | 102 | ||
| 103 | - | ||
| 103 | + | ```text | |
| 104 | 104 | sudo apt-get install avrdude | |
| 105 | 105 | ``` | |
| 106 | 106 | ||
| 107 | 107 | Note: a PC restart may be necessary. | |
| 108 | 108 | ||
| 109 | 109 | ## See also | |
| 110 | 110 | ||
| 111 | 111 | - [[AVR Embedded Tutorials]] - Overview | |
| 112 | 112 | ||
| 113 | 113 | --- | |
| 114 | 114 | *From the Free Pascal wiki, page "AVR Embedded Tutorial - Various programmers", as it stood on 2021-02-11 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* | |
| 115 | 115 | Category: AVR | |
| 116 | 116 | Category: Arduino | |
| 117 | 117 | Category: Embedded | |
| 118 | 118 | Category: Tutorials |
