user31139: I'm trying to flash pure c-code to arduino Mega2560 board from linux using avr-gcc & avrdude. Compilation is done , now trying to flash using avr-dude, getting error as "avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00"
I used below command to produce hex file 
avr-gcc -mmcu=atmega2560 -DF_CPU=16000000UL led.c -o led.elf

In file included from led.c:3:0:
/usr/lib/avr/include/util/delay.h:95:3: warning: #warning "Compiler optimizations disabled; functions from  won't work as designed" [-Wcpp]
 # warning "Compiler optimizations disabled; functions from  won't work as designed"
And then
avr-objcopy -j .text -O ihex led.elf led.hex

finally for flashing 
avrdude -F -V -c arduino -p ATMEGA2560 -P /dev/ttyACM3 -b 115200 -U flash:w:led.hex

FYI: port is correct & RX pin is blinking i.e connection is perfect between computer & board

user7508: 
In file included from led.c:3:0:
  /usr/lib/avr/include/util/delay.h:95:3: warning: #warning "Compiler
  optimizations disabled; functions from won't work as designed"

You should start by fixing this. Simply add -Os to the compiler
command line. This means “optimize for size”, and is the standard
optimization option used with Arduinos.

avr-objcopy -j .text -O ihex led.elf led.hex

If your copy of avrdude was compiled with libelf (like the one supplied
with Ubuntu is), you don't need this: you can hand your elf file
directly to avrdude.

avrdude -F -V -c arduino -p ATMEGA2560 -P /dev/ttyACM3 -b 115200 -U flash:w:led.hex

-F tells avrdude to not verify the device signature. -V tells it
to not verify the upload. I wouldn't use any of these options unless
I had a very good reason to do so. -c arduino is wrong: it selects the
upload protocol used by optiboot (used, e.g., in the Uno). The
Mega 2560 uses a different bootloader based on the “wiring”
protocol. I would also add the -D option (disable auto erase) because
I saw the Arduino IDE using it, and because without this option I get
the error:
avrdude: erasing chip
avrdude: stk500v2_command(): command failed

In the end, the upload command ends up being something like:
avrdude -p atmega2560 -c wiring -P /dev/ttyACM3 -b 115200 -D -U led.elf


31139: <p>I'm trying to flash pure c-code to arduino Mega2560 board from linux using avr-gcc &amp; avrdude. Compilation is done , now trying to flash using avr-dude, getting error as "<em>avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00</em>"</p>

<p>I used below command to produce hex file </p>

<pre><code>avr-gcc -mmcu=atmega2560 -DF_CPU=16000000UL led.c -o led.elf
</code></pre>

<p><em>In file included from led.c:3:0:
/usr/lib/avr/include/util/delay.h:95:3: warning: #warning "Compiler optimizations disabled; functions from  won't work as designed" [-Wcpp]
 # warning "Compiler optimizations disabled; functions from  won't work as designed"</em></p>

<p>And then</p>

<pre><code>avr-objcopy -j .text -O ihex led.elf led.hex
</code></pre>

<p>finally for flashing </p>

<pre><code>avrdude -F -V -c arduino -p ATMEGA2560 -P /dev/ttyACM3 -b 115200 -U flash:w:led.hex
</code></pre>

<p>FYI: port is correct &amp; RX pin is blinking i.e connection is perfect between computer &amp; board</p>
 7508: <blockquote>
  <p>In file included from led.c:3:0:
  /usr/lib/avr/include/util/delay.h:95:3: warning: #warning "Compiler
  optimizations disabled; functions from won't work as designed"</p>
</blockquote>

<p>You should start by fixing this. Simply add <code>-Os</code> to the compiler
command line. This means “optimize for size”, and is the standard
optimization option used with Arduinos.</p>

<blockquote>
  <p>avr-objcopy -j .text -O ihex led.elf led.hex</p>
</blockquote>

<p>If your copy of avrdude was compiled with libelf (like the one supplied
with Ubuntu is), you don't need this: you can hand your elf file
directly to avrdude.</p>

<blockquote>
  <p>avrdude -F -V -c arduino -p ATMEGA2560 -P /dev/ttyACM3 -b 115200 -U flash:w:led.hex</p>
</blockquote>

<p><code>-F</code> tells avrdude to <strong>not</strong> verify the device signature. <code>-V</code> tells it
to <strong>not</strong> verify the upload. I wouldn't use any of these options unless
I had a very good reason to do so. <code>-c arduino</code> is wrong: it selects the
upload protocol used by optiboot (used, e.g., in the Uno). The
Mega&nbsp;2560 uses a different bootloader based on the “wiring”
protocol. I would also add the <code>-D</code> option (disable auto erase) because
I saw the Arduino IDE using it, and because without this option I get
the error:</p>

<pre><code>avrdude: erasing chip
avrdude: stk500v2_command(): command failed
</code></pre>

<p>In the end, the upload command ends up being something like:</p>

<pre><code>avrdude -p atmega2560 -c wiring -P /dev/ttyACM3 -b 115200 -D -U led.elf
</code></pre>
