Using arduino from cmdline, Linux

It seems now that I'm beginning to find the problem as to why I can't program my arduino.
I have GCC 4.1.0 and Binutils 2.17 (configured for AVR) and avr-libc 1.4.5. I'm using avrdude 5.3.1 to program my arduino NG (atmega 168).

I have installed the arduino-core-0007 tarball and am using its Makefile and headers. My Makefile is edited like this:

PORT = /dev/ttyUSB0
TARGET = arduino-test
ARDUINO = /Files/AVR-Cross/arduino-core
SRC = $(TARGET).c $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c $(ARDUINO)/WInterrupts.c
CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WRandom.cpp
MCU = atmega168
#MCU = atmega161
F_CPU = 16000000
FORMAT = ihex

This does not work. It compiles fine and uploads, but nothing happens. (I'm trying to get a LED on pin13 to blink).

But, if I change MCU to atmega161, or atmega8 when compiling, and change back to 168 before uploading, then the LED blinks!
But it blinks way too fast, not at all those 1000ms I wrote in the blink code...

So, this is appearently a bug, and now I'm wondering where? The stuff from arduino-core-0007, gcc, or the bootloader?
Looking forward to your answers! :slight_smile:

At last, I got it working!
It was a matter of left-over object files (the arduino-core-0007 tarball comes with precompiled object files which needs to be removed), I also cleaned up some warnings with this patch:

There's one warning left though, which I didn't know if it should be "fixed":

/Files/AVR-Cross/arduino-core/WInterrupts.c:40:1: warning: "MCUCR" redefined
In file included from /Files/AVR-Cross/lib/gcc/avr/4.1.0/../../../../avr/include/avr/iom168.h:36,
                 from /Files/AVR-Cross/lib/gcc/avr/4.1.0/../../../../avr/include/avr/io.h:258,
                 from /Files/AVR-Cross/arduino-core/WInterrupts.c:27:
/Files/AVR-Cross/lib/gcc/avr/4.1.0/../../../../avr/include/avr/iomx8.h:297:1: warning: this is the location of the previous definition

It's defined in iomx8.h as _SFR_IO8 (0x35) but WInterrupts.c redefines it to EICRA. Is this right??