I'm trying to write to pages using the EEFC on the SAM3X.
I've successfully managed to write and read lock-bits using code like the following.
EFC0->EEFC_FCR = (0x5A << 24) | 0x0A;
while (!EEFC_FSR_FRDY) {
}
Serial.print("FRR: ");
Serial.println(EFC0->EEFC_FRR);
If I read the flash descriptor using
EFC0->EEFC_FCR = (0x5A << 24) | 0x00;
I am informed that there is 1 plane of 256kB of memory. Each page is 256 bytes and there are 16 lock bits covering 16384 bytes (64 pages) each.
Isn't the SAM3X meant to have two planes of 256kB for a total of 512kB?
Nevertheless, using these figures I calculated that 0xBE800 should correspond to the 1000th page (0x3E8).
pp = (uint32_t*)0xBE800;
*pp++ = 0xFF00FF00;
*pp++ = 0xFF00FF00;
*pp++ = 0xFF00FF00;
*pp++ = 0xFF00FF00;
EFC0->EEFC_FCR = (0x5A << 24) | ( 0x3E8 << 8 ) | 0x03;
The Arduino hangs.
But upon reboot... success! The page of flash was written correctly.
If I try using EEFC1, the Arduino remains responsive but the page is not written.