Sep 232011
 
Upgraded Arduino

Sanguino is a project which needed a slightly more powerful CPU, so they made Arduino libraries work on the ATmegaxx4 series work. It’s popular as it has slightly more of everything: FLASH, RAM, EEPROM, I/O pins and UARTs. Unfortunately that was when Arduino was at release 18. Current is 22. I could not make this even compile release 18 under Eclipse/avr-gcc 4.3.5.

Luckily someone was not too happy about Arduino only supporting their CPUs (ATmega8/168/328 and ATmega1280 and 2560) either. AVR has very similar CPUs with slightly different I/O configuration, but they are all pretty compatible. So they adopted the Arduino core libraries to run on pretty much any AVR CPU which looks sensible, including the ATmegaxx4 series.

Those libraries did not compile out-of-the box either, but minor modifications concerning the definition of port_to_mode_PGM and related fixed this:

-const uint16_t PROGMEM port_to_mode_PGM[] =
+volatile uint8_t * PROGMEM port_to_mode_PGM[] =
-const uint16_t PROGMEM port_to_output_PGM[] =
+volatile uint8_t * PROGMEM port_to_output_PGM[] =
-const uint16_t PROGMEM port_to_input_PGM[] =
+volatile uint8_t * PROGMEM port_to_input_PGM[] =
and in pins_arduino.h:
-extern const uint16_t PROGMEM port_to_mode_PGM[];
-extern const uint16_t PROGMEM port_to_input_PGM[];
-extern const uint16_t PROGMEM port_to_output_PGM[];
+extern volatile uint8_t * PROGMEM port_to_mode_PGM[];
+extern volatile uint8_t * PROGMEM port_to_input_PGM[];
+extern volatile uint8_t * PROGMEM port_to_output_PGM[];

Compiling the traditional blink program worked as expected.

For reference and for all those who want to use Eclipse, Arduino libraries and a ATmega644P resp. ATmega1284P, here the archives of the Eclipse projects: MultiAVR20.zip and BlinkSanguino.zip.