Hello all -
I am unable to program an AT91SAM9XE part with ULINK2 when any of the pages in flash are locked.
I think the ProgramPage code for the part is missing the code to unlock the flash page before it is erased.
Can anyone confirm this?
int ProgramPage (unsigned long adr, unsigned long sz, unsigned char *buf) { unsigned long page; page = (adr - base_adr) / PAGE_SIZE; // should there be a couple of instructions here to unlock the page? // eg. // // *AT91C_EFC_FCR = FKEY | AT91C_EFC_FCMD_CLB | (page << 8); // while (!(*AT91C_EFC_FSR & AT91C_EFC_FRDY_S)); // Copy to the Write Buffer for (sz = (sz + 3) & ~3; sz; sz -= 4, adr += 4, buf += 4) { M32(adr) = *((unsigned long *)buf); } // Start Erase Page and Write Page Command *AT91C_EFC_FCR = FKEY | AT91C_EFC_FCMD_EWP | (page << 8); // Wait until the end of Command while (!(*AT91C_EFC_FSR & AT91C_EFC_FRDY_S)); // Check for Errors if (*AT91C_EFC_FSR & (AT91C_EFC_FCMDE | AT91C_EFC_LOCKE)) return (1); return (0); }
Thanks for any feedback.