Can one use programme space memory for data logging?

I have a requirement for a one-off data logger which needs more than the 2k EEPROM of a pro-mini. The code will be << 10k.

Can I use the use the unused program memory space for this?

Allan

Never come across an Arduino sketch/library doing that on ATmega chips. On the other hand, the bootloader can clearly do it. Maybe some security feature prevents code outside the bootloader from doing it, otherwise to would be all too easy to "brick" an Arduino, especially for a beginner.

You can do it on some other chips, eg. Esp8266

There is a dedicated bootloader that seems to support it. Do a search :wink: Alternative is using an external eeprom/fram/sd.

Be aware that writing flash is limited to 10,000 cycles (against eeprom 100,000 cycles) per cell.

To write to flash from the user application, you need a specialized bootloader. There is a modified version of optiboot with this capability (eventually to be part of the official optiboot).

The easiest way to get the modified optiboot is by using MiniCore:

  • Install MiniCore
  • Tools > Board > ATmega328
  • Tools > Clock > select the appropriate clock configuration for you Pro Mini (depends on whether you are using the 5 V or 3.3 V version)
  • Tools > Variant > 328P / 328PA
  • Tools > Bootloader > Yes
  • Connect an ISP programmer to your Pro Mini
  • Tools > Programmer > select the appropriate programmer
  • Tools > Burn Bootloader

You can find an example of writing to flash under File > Examples > Optiboot flash read/write > SerialReadWrite.