This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RM48L952: RM48 Prefetch exception while flashing OTP bits

Part Number: RM48L952

I am getting a prefetch exception while trying to program the AJSM code register. I am executing the F021 library out of RAM and have been doing so for a while now without issues when flashing other places in flash. I am not currently using ECC, but I do notice that bits 27 and 27 of the auxiliary control are 1s. Here is the code I am using with debug print statements to do it.

	sciInit();


	uint32_t ajsm[4] = {0, 0xAECD0001, 0xAECD0002, 0xAECD0003};

	copyFlashAPIIntoRAM();
	initFlash(200.000F);

	Print("1\n\r");

	while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );

	Print("2\n\r");

	Fapi_StatusType status = Fapi_setActiveFlashBank(Fapi_FlashBank0);//????
	if(status)
	{
		while(1);
	}
	Print("3\n\r");
	while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
	Print("4\n\r");

	uint8_t banksMaks = 0xFF;//TODO: NOT SURE ABOUT THIS. should be bank 0
	status = Fapi_enableBanksForOtpWrite(banksMaks);
	Print("5\n\r");
	if(status)
	{
		while(1);
	}
	Print("6\n\r");

	while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
	Print("7\n\r");


	status = Fapi_issueProgrammingCommand((uint32_t *)(0xF0000000), (uint8_t *)(&ajsm[0]), 16, NULL, 0, Fapi_AutoEccGeneration);//TODO: CHANGE TO ADD ECC TOO!
	Print("8\n\r");
	if(status)
	{
		while(1);
	}
	Print("9\n\r");

	while( FAPI_CHECK_FSM_READY_BUSY != Fapi_Status_FsmReady );
	Print("10\n\r");


	status = Fapi_disableBanksForOtpWrite();
	Print("11\n\r");
	if(status)
	{
		while(1);
	}

	Print("Success\n\r");


	while(1);

I get the exception some time during the call to Fapi_issueProgrammingCommand(), but if I step through line by line it will not through an exception and also not make any change to the flash. After the exception is thrown, I check find the instruction fault status to be 0x409 and the instruction fault address 0xC.

Thanks in advance,

Westin

  • The code that calls Fapi_issueProgrammingCommand() until the FSM is no longer busy must also be in RAM. The call to issueProgrammingCommand starts the flash state-machine, but you cannot execute from the bank you are programming until the state-machine has finished. The OTP locations of the AJSM are part of flash bank 0. If your code were executed from bank 1, this should work. (In fact, you would not need to copy the API into RAM.)
  • Yes, that was the issue. I now have it executing out of ram, but weird things are still happening. The debugger shows it executing the code just fine, although flash does not seem to be changed. Also, once I return from the function in RAM, the disassembly window shows all zeros for the instructions. Refreshing the window a few times seems to bring the code back. If I just hit the resume button in the debugger and let it run, it gets an undefined exception.
  • Okay, I got it working. I had commented out the while loop to wait until the FSM was no longer busy at the end, so it must have been returning to flash before it should have.

  • Great. Glad you figured it out.