Hello,
I’m working with an AT91SAM7X256 and I would like to clear the NVM bit 2 in order to boot on Samba at next boot. I’d like to do that from the device (in the flash or the SRAM) and not from the host. When I do that from the host using AT91Boot_DLL.dll it works fine. When I want to do that in the firmware, I loose the execution as son as I send my command to the EFC (Embedded Flash Controller). Apparently the processor goes into the abort state. I tried the same in SRAM using __ramfunc, but the behavior is the same. If I unplug and replug the device it indeed starts on Samba, so the command has been taken.
Can somone tell me what I do wrong below?
Thanks in advance
Hannibal
void SetNextBootOnRom(void)
{
__disable_interrupt();
AT91C_BASE_MC->MC_FMR = 0x00480100;
// Wait that the EFC is ready to take a new command
while ((AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY) == 0x00000000);
// Cursor
TRACE_CURSOR("Before bit change\n\r");
// Send the command to the the EFC to set the bit
//AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, 0x5A00020D);
AT91F_MC_EFC_PerformCmd(AT91C_BASE_MC, AT91C_MC_CORRECT_KEY | AT91C_MC_FCMD_CLR_GP_NVM | (AT91C_MC_PAGEN & (2 << 8)));
// Cursor
TRACE_CURSOR("This line is never executed !\n\r");
// Wait that the bit is set
while ((AT91C_BASE_MC->MC_FSR & AT91C_MC_FRDY) == 0x00000000);
__enable_interrupt();
}