Store and change data on a DUE which are not Reset after power cycle

Hi guys,

I have a general question about the memory abillities of the DUE. On the overview of the DUE website ( the following is said:


The SAM3X has 512 KB (2 blocks of 256 KB) of flash memory for storing code. The bootloader is preburned in factory from Atmel and is stored in a dedicated ROM memory. The available SRAM is 96 KB in two contiguous bank of 64 KB and 32 KB. All the available memory (Flash, RAM and ROM) can be accessed directly as a flat addressing space.

So it has 3 ways to store things on the DUE:

  • 512KB of Flash to store purely program code
  • Bootloader is stored in ROM
  • 96KB SRAM can be accessed directly -> to do what? Store globally declared variables? But they will be lost after a power cycle shut-down.

I am asking because I am looking for a way to store some variables in memory which can be changed using for example bluetooth/wifi/ethernet/etc., and which will not be resetet to their original value after a power cycle. It is not my goal to log sensors and store masses of things on the DUE locally, just some settings. But I want to be able to change them and that they remember it :slight_smile: Not that everytime I want to change a constant I need to reflash it. Is this possible without adding EEPROM or FLASH or SD-cards or etc. to my board?

You can store persistent data in Flash memory. It will persist between power cycles. However, and this is potentially a large issue, flash is completely 100% erased when new firmware is uploaded. All of your settings will disappear. So long as you keep the firmware stable you can continue to use flash memory as storage space. Another possibility, which I don't think anyone as tried, is to read the stored settings from flash before erasing. Then add those settings back into the file to flash, erase the flash, and upload the new firmware + settings. This should work fine but you'd have to create a custom upload script to do this. The easiest approach is really to use an I2C connected EEPROM chip for your storage. They're cheap, easy to wire, and small.

Hi Collin,

Thanks for helping.

  • The persistent data storing in Flash is idd great when the firmware never changes again. Do you have an example sketch to show me how this is done?
  • Your second option takes me beyond my Arduino skills. Lets say my embedded skills. I have no experience in creating/editing upload scripts. It would be nice though if some experts would create such a script. Let's say from the 512KB available, making 1KB available for permanent storing of settings would be great.
  • Using EEPROM with I2C is also a good option. But then I need to build this on a shield or a proto-area which I would rather not do. But as a back-up plan, do you know a good shield or example/tutorial + sketch on this?

I think not being able to store settings permanently from certain variables is a real disadvantage of the DUE.