avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creatin


From: Colin D Bennett
Subject: [avr-gcc-list] Bug? gcc silently assumes mcu model when linking, creating bad executable
Date: Fri, 18 Apr 2008 10:23:04 -0700

Hi,

I spent two days trying to track down why my program was behaving
unexpectedly -- as in, when I write to a global variable, it does not
read back as the same value! I finally tracked it down to this:
the global variable was getting placed at RAM address 0x60 on my
ATmega88, which is the location of one of the watchdog registers!

It turns out that my Makefile was not passing the -mmcu=X flag when I
linked my object files together (with avr-gcc), so gcc silently assumed
that putting the variable at 0x60 is OK.  By adding -mmcu=atmega88 to
the linker flags, the variable was then placed at RAM address 0x100,
which then made the code behave properly on the target device.

When you compile code with avr-gcc and avr-libc without specifying
-mmcu=X, you get a warning; shouldn't it be the same with linking?
Clearly, the default assumption of the linker will not result in a
working program for all AVR models, as I have found.

Am I doing something wrong? Should I have got a warning? Should I be
using 'avr-ld' to link instead of 'avr-gcc'? Do you think that linking
a program for an unknown AVR MCU model makes sense?

Thanks,
Colin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]