AVR upload executable file in Terminal

Installation

macOS

brew install avrdude

Linux(debian)

sudo apt-get install -y avrdude

Windows

Download: http://download.savannah.gnu.org/releases/avrdude/

.zipํŒŒ์ผ์„ ๋ฐ›์œผ์‹œ๊ณ  ์›ํ•˜๋Š” ์œ„์น˜์— ์••์ถ•์„ ํ‘ผ ๋’ค, ํ™˜๊ฒฝ ๋ณ€์ˆ˜์˜ Path์— ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ๋ฅผ ๋“ฑ๋กํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

Programmer

Atmel-ICE, USBtoUART, stk500 ๋“ฑ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

USB to UART

CH340G ๋“œ๋ผ์ด๋ฒ„

macOS

Download: http://www.wch.cn/download/CH341SER_MAC_ZIP.html

Linux(debian)

USB to UART ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ ttyUSBx์˜ ์†Œ์œ ๊ถŒ์ด root์—๊ฒŒ ์žˆ๊ณ  ๊ทธ๋ฃน์ด dialout์ด๊ธฐ ๋•Œ๋ฌธ์— ๊ถŒํ•œ ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์‚ฌ์šฉ์ž๋ฅผ dialout ๊ทธ๋ฃน์— ์ถ”๊ฐ€์‹œ์ผœ ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

sudo gpasswd --add $USER dialout

Download: http://wch.cn/downloads/CH341SER_LINUX_ZIP.html

sudo apt-get install -y libelf-dev &&\
unzip CH341SER_LINUX.ZIP &&\
cd CH341SER_LINUX/ &&\
sudo make &&\
sudo make load

make ํ•  ๋•Œ, error๊ฐ€ ์ถœ๋ ฅ๋˜๋ฉด ch34x.c ์— #include <linux/sched/signal.h>๋ฅผ ์ถ”๊ฐ€ํ•˜๊ณ  wait_queue_t๋ฅผwait_queue_entry_t`๋กœ ์ˆ˜์ •ํ•œ ๋’ค, ๋‹ค์‹œ make๋ฅผ ์‹œ๋„ํ•ด๋ณด์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

Windows

Download: http://wch.cn/downloads/CH341SER_ZIP.html

FTDI ๋“œ๋ผ์ด๋ฒ„ ์„ค์น˜

Linux(debian)

Ubuntu 11.10 ์ดํ›„ ๋ฒ„์ „์—์„œ๋Š” FTDI ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์ปค๋„์— ํ†ตํ•ฉ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

macOS, Windows

Download: https://www.ftdichip.com/Drivers/VCP.htm

CP2102 ๋“œ๋ผ์ด๋ฒ„ ์„ค์น˜

Linux(debian)

Linux 3.x.x์™€ Linux 4.x.x ๋ฒ„์ „์—์„œ๋Š” CP2102 ๋“œ๋ผ์ด๋ฒ„๊ฐ€ ์ปค๋„์— ํ†ตํ•ฉ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. Ubuntu ๊ธฐ์ค€ 11.10 ~ 18.04 LTS๋กœ ํ™•์ธ ๋ฉ๋‹ˆ๋‹ค.

macOS, Windows

Download: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

Upload

์—…๋กœ๋“œ๋ฅผ ์ง„ํ–‰ํ•˜๊ธฐ ์ „์— ์‹คํ–‰ ํŒŒ์ผ์ธ .elf ํŒŒ์ผ์ด๋‚˜ .hex ํŒŒ์ผ์ด ์žˆ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

avr-objcopy๋Š” binutils-avr์— ํฌํ•จ๋˜์–ด ์žˆ๋Š” ์˜ค๋ธŒ์ ํŠธ ํŒŒ์ผ์„ ๋ณต์‚ฌํ•˜๊ณ  ๋‹ค๋ฅธ ํŒŒ์ผ๋กœ ๋ณ€ํ™˜ํ•ด์ฃผ๋Š” ๋ช…๋ น์ž…๋‹ˆ๋‹ค. ์—…๋กœ๋“œํ•  ๋•Œ, <executable file>์„ ์ž…๋ ฅํŒŒ์ผ๋กœ ๋ฐ›์•„๋“ค์ด์ง€ ๋ชปํ•˜๋Š” ๊ฒฝ์šฐ, ์•„๋ž˜ ๋ช…๋ น์„ ํ†ตํ•ด .elf ํŒŒ์ผ์—์„œ ํ•„์š”ํ•œ ๋ถ€๋ถ„์„ .hex ํŒŒ์ผ์— ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.(avrdude ๋ฒ„์ „์ด ๋‚ฎ์€ ๊ฒฝ์šฐ elf๋ฅผ ์ž…๋ ฅํŒŒ์ผ๋กœ ์‚ฌ์šฉํ•˜์ง€ ๋ชปํ•ฉ๋‹ˆ๋‹ค.)

avr-objcopy -j .text -j .data -O ihex <elf file> <hex file>

avrdude

Ref: https://nongnu.org/avrdude/user-manual/avrdude_4.html#Option-Descriptions

avrdude๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ AVR MCU์— ์‹คํ–‰ ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•˜๊ฑฐ๋‚˜ ํ“จ์ฆˆ ๋น„ํŠธ, ๋ฝ ๋น„ํŠธ ๋“ฑ์„ ์„ค์ •ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋„๊ตฌ์ž…๋‹ˆ๋‹ค. ์•„๋ž˜ ์˜ต์…˜์„ ํ™•์ธํ•˜๊ณ  ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋จธ์™€ AVR MCU์— ๋”ฐ๋ผ ์˜ต์…˜์„ ์„ ํƒํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

  • -p<partno>: ์‹คํ–‰ ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•  MCU ์„ค์ •.
  • -c<programmer-id>: ์‚ฌ์šฉํ•  ํ”„๋กœ๊ทธ๋ž˜๋จธ(์—…๋กœ๋“œ ์žฅ์น˜) ์„ค์ •.
  • -P<port>: ํ”„๋กœ๊ทธ๋ž˜๋จธ๊ฐ€ ์—ฐ๊ฒฐ๋œ ํฌํŠธ๋ฅผ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • -b<baudrate>: UART ํ†ต์‹ ์„ ํ†ตํ•ด ์—…๋กœ๋“œํ•˜๋Š” ๊ฒฝ์šฐ ๋ณด์˜ค ๋ ˆ์ดํŠธ๋ฅผ ์„ค์ •.
  • -B<bitclock>: JTAG ์ธํ„ฐํŽ˜์ด์Šค ๋˜๋Š” ISP ํด๋Ÿญ์— ๋Œ€ํ•œ ๋น„ํŠธ ํด๋Ÿญ ์ฃผ๊ธฐ. ๊ฐ’์€ ms ๋‹จ์œ„๋กœ ๋ถ€๋™์†Œ์ˆ˜์ ์„ ์‚ฌ์šฉ.
    • 1/<bitclock> MHz
    • ์‚ฌ์šฉ๋œ AVR MCU ํด๋Ÿญ์˜ 1/4 ์ดํ•˜๋กœ ์„ค์ •ํ•˜๋Š” ๊ฒƒ์ด ์ ๋‹นํ•จ.
  • -v: ์—…๋กœ๋“œ ์‹œ ์ƒ์„ธ ์ •๋ณด ํ‘œ์‹œ.
  • -U<memtype:op:filename[:format]> : ์‚ฌ์šฉํ•  ์ €์žฅ ๊ณต๊ฐ„, ์‹คํ–‰ ๋ฐฉ๋ฒ•, ์ž…๋ ฅ ํŒŒ์ผ, ํŒŒ์ผ ํ˜•์‹ ์„ค์ •.
    • memtype: eeprom, flash, fuse, boot ๋“ฑ.
    • op: r, w, v.
    • format: i(intel hex), e(ELF), a(auto detect) ๋“ฑ. e, a ๋“ฑ์€ ์—…๋กœ๋“œํ•  ๋•Œ๋งŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ.
    • .elf ํŒŒ์ผ ์—…๋กœ๋“œ: -Uflash:w:[filename].elf:e
    • .hex ํŒŒ์ผ ์—…๋กœ๋“œ: -Uflash:w:[filename].hex:i

stk500

(@todo stk500 ์‚ฌ์šฉ์‹œ ISP ํด๋Ÿญ ์„ค์ • ํ…Œ์ŠคํŠธ ์•ˆ๋จ.)

avrdude -p<partno> -cstk500 -P<port> -v -Uflash:w:<executable file>:e

avrispmkII

avrdude -p<partno> -cavrispmkII -B0.5 -v -Uflash:w:<executable file>:e

arduino

nano์˜ ๊ฒฝ์šฐ Old Bootloader๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด -b57600์„ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

avrdude -p<partno> -carduino -P<port> -b115200 -v -Uflash:w:<executable file>:e

atmelice_isp

(@todo atmelice_isp ์‚ฌ์šฉ์‹œ ISP ํด๋Ÿญ ์„ค์ • ํ…Œ์ŠคํŠธ ์•ˆ๋จ.)

avrdude -p<partno> -catmelice_isp -v -Uflash:w:<executable file>:e

USBasp

avrdude -p<partno> -cusbasp -B3 -Pusb -v -Uflash:w:<executable>:e`
Last updated on