Problem with AVRDude

I hope this is the right place for this.

I am new to the Ardiuino (although I have a background in software
development). I just purchased an Arduino Uno with an ATMEGA328P-PU. I can
connect it to my computer and load the Blink sketch from the Arduino IDE and
it runs automatically. I would really rather use Eclipse though. So I
installed the necessary plugins based no this page
(http://www.arduino.cc/playground/Code/Eclipse) and have corroborated my
configurations with any other tutorials I can find.

The problem is that when I compile and upload my program to the Arduino, it
doesn’t do anything despite avrdude indicating that it finished successfully.
I have also added verbose logging to the Arduino IDE and it looks like the
commands it calls are very similar to what eclipse is doing. See test program
and outputs below. If there is any other information I can provide, please let
me know. Thanks in advance.

The test program file looks like this:

#include <WProgram.h>
#include <arduino.h>

int main(void)
{
        init();

        pinMode(13, OUTPUT);
        digitalWrite(13, HIGH);   // set the LED on

        for (;;) {
                digitalWrite(13, HIGH);   // set the LED on
                delay(1000);              // wait for a second
                digitalWrite(13, LOW);    // set the LED off
                delay(1000);              // wait for a second
        }

        return 0;
}

code tags added by moderator
(Basically a copy paste from the example sketch with an added main). When I
build it I see this:

**** Build of configuration Release for project Blink ****

make all
Building target: Blink.elf
Invoking: AVR C++ Linker
avr-g++ -s -Os -Wl,–gc-sections -o"Blink.elf" ./main.o -lArduinoCore -lm -
Wl,-Map,Blink.map,–cref -L…/…/ArduinoCore/Release/ -mmcu=atmega328p
Finished building target: Blink.elf

Create Flash image (ihex format)
avr-objcopy -R .eeprom -O ihex Blink.elf “Blink.hex”
Finished building: Blink.hex

Invoking: Print Size
avr-size --format=avr --mcu=atmega328p Blink.elf
AVR Memory Usage

Device: atmega328p

Program: 1456 bytes (4.4% Full)
(.text + .data + .bootloader)

Data: 9 bytes (0.4% Full)
(.data + .bss + .noinit)

Finished building: sizedummy


Which is what I understand it is supposed to look like.

Upload looks like
this:--------------------------------------------------------------------------------------------

Launching /usr/bin/avrdude -pm328p -carduino -P/dev/ttyACM0 -b115200 -D -
Uflash:w:Blink.hex:a
Output:

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file “Blink.hex”
avrdude: input file Blink.hex auto detected as Intel Hex
avrdude: writing flash (1456 bytes):

Writing | ################################################## | 100% 0.27s

avrdude: 1456 bytes of flash written
avrdude: verifying flash memory against Blink.hex:
avrdude: load data flash data from input file Blink.hex:
avrdude: input file Blink.hex auto detected as Intel Hex
avrdude: input file Blink.hex contains 1456 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.21s

avrdude: verifying …
avrdude: 1456 bytes of flash verified

avrdude done. Thank you.

avrdude finished

Why is it that it doesn’t run anything start running? (I see the LEDs flash to
indicate a serial connection but then nothing)

avr-g++ -s -Os -Wl,--gc-sections -o"Blink.elf" ./main.o -lArduinoCore -lm - Wl,-Map,Blink.map,--cref -L../../ArduinoCore/Release/ -mmcu=atmega328p

Doesn't look like F_CPU is defined.

@Coding Bradly Thanks for the reply and fixing the code format(I did look for one, but didn't find the button - I see it now) It looks like slightly different parameters get passed in depending on if it is a clean build. When I ran a clean and rebuild I see the output below which does have -DF_CPU=1843200UL (I am assuming this is what your referring to).

I did try loading this version, and it behaves the same way as before.

As another information point, I have tried hitting the reset button after loading, and that does not do anything ether (except a few LED flashes as it reboots).

**** Build of configuration Release for project Blink ****

make all Building file: ../main.cpp Invoking: AVR C++ Compiler avr-g++ -I"/home/jshaver/arduino/EclipseBlinkProject/ArduinoCore" -w -g2 -gstabs -Os -ffunction-sections -fdata-sections -fno-exceptions -DARDUINO=22 -g -mmcu=atmega328p -DF_CPU=1843200UL -MMD -MP -MF"main.d" -MT"main.d" -c -o"main.o" "../main.cpp" Finished building: ../main.cpp

Building target: Blink.elf Invoking: AVR C++ Linker avr-g++ -s -Os -Wl,--gc-sections -o"Blink.elf" ./main.o -lArduinoCore -lm -Wl,-Map,Blink.map,--cref -L../../ArduinoCore/Release/ -mmcu=atmega328p Finished building target: Blink.elf

Create Flash image (ihex format) avr-objcopy -R .eeprom -O ihex Blink.elf "Blink.hex" Finished building: Blink.hex

Invoking: Print Size avr-size --format=avr --mcu=atmega328p Blink.elf

AVR Memory Usage

Device: atmega328p

Program: 1450 bytes (4.4% Full) (.text + .data + .bootloader)

Data: 9 bytes (0.4% Full) (.data + .bss + .noinit)

Finished building: sizedummy

Where did you get " -DF_CPU=1843200UL"?

Shouldn't it be 1600000? (or are you running a 18.43MHz crystal.)

@James C4S I am running the basic Uno crystal. That number came from Eclipse: Project > Preferences > AVR > Target Hardware and it looked like it was roughly 16 * 1024 * 1024 (now that I do the math it is 16 * 1000 * 1024 which seems slightly odd, but I guess a 16,000 khz crystal is ) in the list.

I just tried it with both 16,777,216 (16 * 1024*1024) and 1600000, and I am seeing the same behavior (or lack of anything really)

how did you build your static library?

#include <arduino.h>

Does not exist in the Arduino world. There is a “Arduino.h” but it is mutually exclusive with “WProgram.h”.

Where did you get the Blink source code?

Force a syntax error. Does the compiler complain when you build?

@Coding Badly, @James C4S - Thanks. That was the problem. I removed Arduino.h from the includes and cleaned and rebuilt my Arduino core project making sure it was targeting the right hardware. Blink is now running.

Thanks for the help.

As an aside to anyone who comes along later, I grabbed the core libraries the from the Eclipse Arudino Project Template. I have done a fair bit of mucking with them by now, so I don't know how close they were to what I needed, but they were a good start.: https://github.com/ricovangenugten/Arduino-Blink-Eclipse-Project

Thank you for the follow-up.