Other Parts Discussed in Thread: CONTROLSUITE, SYSBIOS
Hello,
We are trying to use Flash APIs to write to the flash of the F28M35H52C processor.
We encounter a random failure where the function gets stuck with the Fapi_setActiveFlashBank function. We use Flash Bank 0.
The function never comes out of it and the device crashes after the issue occurs.
I have attached the code for your reference:
We have placed the Flash APIs in the RAM using the linker file. It is not placed in Flash (then copied to RAM) during execution.
The functions calling the Flash APIs are also placed in the RAM.
Can you please review the code snippet and let us know if we have missed anything. We could more details if required.
uint32_t Fapi_BlockProgram( uint32 u32address, uint8 *u8Data, uint32 SizeInBytes, uint8 u8Writelength) { Fapi_StatusType oReturnCheck; volatile Fapi_FlashStatusType oFlashStatus; uint8_t bytes = 0; // To acces the Flash_api FlashGainPump(); if (SizeInBytes < u8Writelength) bytes = SizeInBytes; else bytes = u8Writelength; oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 75); if(oReturnCheck != Fapi_Status_Success) { //Check Flash API documentation for possible errors //Example_Error(oReturnCheck); #if SYSTEM_TEST_GEN2_2_ERROR printk("Flash_api Initialize issue : %d \n",oReturnCheck); // Send error code to error handler task for processing ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008 #endif } // Fapi_setActiveFlashBank function sets the Flash bank and FMC // for further Flash operations to be performed on the bank oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); #if SYSTEM_TEST_GEN2_2_ERROR printk("Flash_api Flash_Bank issue : %d \n",oReturnCheck); // Send error code to error handler task for processing ProcessSystemError(ERROR_PPS_FLASH_ACCESS_FAILURE, PPS_TASK_CAN); // 1008 #endif } while(Fapi_checkFsmForReady() != Fapi_Status_FsmReady){} // Disable ECC so that error is not generated when reading Flash // contents without ECC HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0x0; while( SizeInBytes > 0) { oReturnCheck = Fapi_issueProgrammingCommand( (uint32 *)u32address,(uint8 *)u8Data, bytes, 0, 0, Fapi_AutoEccGeneration); while( Fapi_checkFsmForReady() == Fapi_Status_FsmBusy ); //while( Fapi_getFsmStatus() != Fapi_Status_Success); printk("Flash_api write Done :[ %x ], Length : %d \n",u32address, SizeInBytes); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); #if SYSTEM_TEST_GEN2_2_ERROR printk("Flash_api write issue : %d \n",oReturnCheck); // Send error code to error handler task for processing ProcessSystemError(ERROR_PPS_FLASH_WRITE_FAILURE, PPS_TASK_CAN); // 1008 #endif } u32address += bytes; u8Data += bytes; SizeInBytes -= bytes; if ( SizeInBytes < u8Writelength) { bytes = SizeInBytes; } } // Enable ECC HWREG(FLASH_ERROR_BASE + FLASHERR_O_ECC_ENABLE) = 0xA; // Leave control over pump FlashLeavePump(); return (0); }
Regards,
Lakshmi