PROGMEM no longer working with 0013?

The code below was working for me in 0012 0011 (see update below), but it seems to crash the AVR / return to the bootloader on the strcpy_P() line when uploaded to a stock diecimila.

#include <avr/pgmspace.h>

char string_1[] PROGMEM = "String 1";
char string_2[] PROGMEM = "String 2";
char string_3[] PROGMEM = "String 3";
char string_4[] PROGMEM = "String 4";
char string_5[] PROGMEM = "String 5";

PGM_P PROGMEM string_table[] =

void setup()                    

char buffer[10];
void loop()                     // run over and over again
    for (unsigned char i = 0; i < 5; i++)
       strcpy_P(buffer, (char * )pgm_read_word(&(string_table[i])));
       Serial.println( buffer );
       delay( 500 );

update: code worked in 0011, not 0012

That PROGMEM stuff is awfully subtle. If you change the string_table to

PROGMEM const char *string_table[] =

it will work under 0013. (At least it does for me.)


See also (though it looks like your problem may be different.)

Good observation, westw. It may be the same problem, since the main difference in ahoeben's implementation and mine is that his uses PGM_P, which maps indirectly to prog_char.


I was wrong about my code working in 0012. The last version it worked with as posted is 0011, so it does seem to be the same issue as posted by westfw.

Between 0011 and 0012, newer versions of avr-gcc (4.3.0) and avr-libc (1.6) were included. Some more about the issue here:

With Mikal’s changes, I can confirm the code works with 0013. So there seems to be a workaround. Yay!

This page should probably be updated to reflect this workaround:

I changed the docs a bit.

Can someone have a go at recommending which form for variable declarations we should recommend to users

dataType variableName[] PROGMEM = {}; // eenie dataType PROGMEM variableName[] = {}; // meenie, minie PROGMEM dataType variableName[] = {}; // mo

From the discussion, seems like form 3 should be the current form.

Please note that PROGMEM is not part of the Arduino language and disseminating this information throughout the Arduino community should be done at your own risk.