I've run across a number of problems with existing code and libraries when compiling for the ATmega328. What I've found is that the included AVR header file for the chip has a significant number of define names changed for no apparent reason. When existing code is compiled for the 328 either it fails to compile because of a missing define, or in the case of changed interrupt vectors builds code that locks up.
The header used for the ATmega8/168 is:
/hardware/tools/avr/avr/include/avr/iomx8.h
The header used for the ATmega328 is:
/hardware/tools/avr/avr/include/avr/iom328p.h
Some examples of changes that have caused problems:
PORTB referencesATmega8/168 (iomx8.h):
#define PORTB _SFR_IO8 (0x05)
/* PORTB */
#define PB7 7
#define PB6 6
#define PB5 5
#define PB4 4
#define PB3 3
#define PB2 2
#define PB1 1
#define PB0 0
ATmega328 (iom328p.h):
#define PORTB _SFR_IO8(0x05)
#define PORTB0 0
#define PORTB1 1
#define PORTB2 2
#define PORTB3 3
#define PORTB4 4
#define PORTB5 5
#define PORTB6 6
#define PORTB7 7
There's a lot of code that references PB0 - PB7 and this all breaks because the definitions are changed to PORTB0 - PORTB7. PORTC and PORTD have the same problems.
Interrupt VectorsATmega8/168 (iomx8.h):
#define INT0_vect _VECTOR(1)
#define SIG_INTERRUPT0 _VECTOR(1)
/* External Interrupt Request 1 */
#define INT1_vect _VECTOR(2)
#define SIG_INTERRUPT1 _VECTOR(2)
/* Pin Change Interrupt Request 0 */
#define PCINT0_vect _VECTOR(3)
#define SIG_PIN_CHANGE0 _VECTOR(3)
/* Pin Change Interrupt Request 0 */
#define PCINT1_vect _VECTOR(4)
#define SIG_PIN_CHANGE1 _VECTOR(4)
ATmega328 (iom328p.h):
#define INT0_vect _VECTOR(1) /* External Interrupt Request 0 */
#define INT1_vect _VECTOR(2) /* External Interrupt Request 1 */
#define PCINT0_vect _VECTOR(3) /* Pin Change Interrupt Request 0 */
#define PCINT1_vect _VECTOR(4) /* Pin Change Interrupt Request 0 */
It looks like the "old" names for all of the interrupt vectors have been left out. While I understand that the old names like "SIG_PIN_CHANGE0" are deprecated and should be changed to "PCINT0_vect", there's a large base of existing libraries that reference the old interrupt vector names. I don't see any reason to break all of that code by removing the old names when they don't hurt anything to be there.
I wouldn't be so bad if the code failed to compile, but it doesn't. There's only a warning about a possibly misspelled signal handler. Invalid code still gets built that crashes the chip whenever the interrupt is triggered.
There are probably more differences in the support for 328's but this is what I've come across so far.