Bash script for avr-gcc and avrdude

This script will take a c file (named main.c), compile it into a main.o file, convert this to a .elf file and then convert the .elf to a .hex and finally flash the chip with this hex using avrdude.

First install avrdude by opening terminal and entering :

sudo apt-get install avrdude

Then install avr-gcc:

sudo apt-get install gcc-avr

Here is the bash script:

#!/bin/bash
 
#!/bin/bash
 
avr-gcc -g -Os -mmcu=atmega1281 -c main.c &&
avr-gcc -g -mmcu=atmega1281 -o main.elf main.o &&
avr-objcopy -j .text -j .data -O ihex main.elf out.hex &&
avrdude -p atmega1281 -c jtag2 -P usb  -U flash:w:out.hex


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s