Dynamic arrays into flash memory?

Is there a way to assign dynamic arrays into flash memory? The preferred method would be for the sketh to declare the pointer, allocate the memory and save the data to the memory. Alternatively, a program from a PC could also be used, provided that the sketch knows where to find the array.

If I declare
float *x PROGMEM;
x = (float *)calloc(1, sizeof(float));

I get a compiler error that tells me:

“error: assignment to read-only variable ‘x’.”

Any help will be appreciated.

You can't write to Flash ROM during the execution of a sketch. Are you trying to make a non-volatile memory? If so, you can use the built-in EEPROM. Perhaps you could explain a little more about what you're trying to achieve?

Thank you for your prompt reply. Yes, I am trying to write to non-volatile memory. But the EEPROM is very small. What I am trying to do is to store an array of unknow size into the arduino, but it could be a couple of thousand bytes altogether. These numbers are originated on a PC. My idea was to connect the PC to the arduino via the serial port, and have the sketch store the variables into flash. Alternatively, I could actually have the PC program re-write the sketch, and use the IDE to load the program. Ugly, but doable.

You could add an external EEPROM with larger storage capacity. They usually connect via the I2C interface.

Thank you for the suggestion. I'll research that option. There are a few examples I can follow.