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.
Hi,
I'm using F280049c for CAN UDS bootloader situation.
What we used is F280049c's Flash API library with RAM application.
We see a phenomenon that MCU will go to NMI interrupt ,which is caused by FLUNCERR flag, when doblank_check function, and some other flash operations.
We found that the ECC is enabled by default.
Flash_enableECC(eccBase);
Only if we disable ECC check for Flash. The whole process will be successful.And we double check the data writed into the memory with the orginal hex file. We dowrite the right data.
So, Is there something should I care about that causing ECC error?
Regards
Arrow
Hi Arrow,
How about verify after programming? Is that successful with ECC enabled?
Thanks and regards,
Vamsi
,
Hi Vamsi
I read the data from the memory browser, and the data is the same with what I want to write in .
If I enable the ECC, the core will go to the NMI interrupt first when steps into the function Fapi_doBlankCheck () in Flash erase process.
void sharedErase(uint32_t sectors) { statusCode.status = NO_ERROR; statusCode.address = 0x12345678; int i = 0; Fapi_StatusType oReturnCheck; Fapi_FlashStatusWordType oFlashStatusWord; int fail = 0; // // Note that wait-states are already configured in the Device_init(). // However, if INTOSC is used as the clock source and // if the CPUCLK falls in the range (97,100] (check other ranges given in DS), // then an extra wait state is needed for FSM operations (erase/program). // Hence, below function call should be uncommented in case INTOSC is used. // At 100MHz, execution wait-states for external oscillator is 4 and hence // in this example, a wait-state of 5 is used below. // This example is using external oscillator as the clock source and hence // below is commented. // // This wait-state setting impacts both Flash banks. Applications which // perform simultaneous READ/FETCH of one bank and PROGRAM or ERASE of the other // bank must use the higher RWAIT setting during the PROGRAM or ERASE operation. OR // use a clock source or frequency with a common wait state setting // Example: Use 97MHz instead of 100MHz if it is acceptable for the application. // // In case, if user application increments wait-state before using API, // then remember to revert back to the original wait-state after the API usage // to avoid extra wait-state during application execution from Flash. // // Flash_setWaitstates(FLASH0CTRL_BASE, 4); // Initialize the Flash API by providing the Flash register base address // and operating frequency. // This function is required to initialize the Flash API based on System frequency // before any other Flash API operation can be performed. // This function must also be called whenever System frequency or RWAIT is changed. EALLOW; oReturnCheck = Fapi_initializeAPI(F021_CPU0_BASE_ADDRESS, 100); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); statusCode.status = INIT_ERROR; } // Initialize the Flash banks and FMC for erase and program operations. // Fapi_setActiveFlashBank() function sets the Flash banks and FMC for further // Flash operations to be performed on the banks. // Note: It does not matter which bank is passed as the parameter to initialize. // Both Banks and FMC get initialized with one function call unlike F2837xS. // Hence there is no need to execute Fapi_setActiveFlashBank() for each bank. // Executing for one bank is enough. oReturnCheck = Fapi_setActiveFlashBank(Fapi_FlashBank0); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); statusCode.status = BLANK_ERROR; } EDIS; EALLOW; for (i = 0; i < 32; i++) { if ((sectors & 0x00000001) == 0x00000001) { oReturnCheck = Fapi_issueAsyncCommandWithAddress( Fapi_EraseSector, (uint32_t *) (sectAddress[i])); // // wait until AsyncCommand is done. // while (Fapi_checkFsmForReady() != Fapi_Status_FsmReady) { } // // All 8K sector size // oReturnCheck = Fapi_doBlankCheck((uint32_t *) (sectAddress[i]), B_8KSector_u32length, &oFlashStatusWord); if (oReturnCheck != Fapi_Status_Success) { // // first fail // if (fail == 0) { statusCode.status = BLANK_ERROR; statusCode.address = oFlashStatusWord.au32StatusWord[0]; } statusCode.status = BLANK_ERROR; } while (Fapi_checkFsmForReady() == Fapi_Status_FsmBusy) { } } sectors = sectors >> 1; } EDIS; return ; }
If I disable the the Fapi_doBlankCheck() function.The Core can go through the sharedErase function.
But when going to next Program_CallFlashAPI() function, it will go to NMI interrupt when steps in to Fapi_issueProgrammingCommand().
void Program_CallFlashAPI(void) { uint32 u32Index = 0; uint16 i = 0; Fapi_StatusType oReturnCheck; Fapi_FlashStatusType oFlashStatus; Fapi_FlashStatusWordType oFlashStatusWord; // A data buffer of max 8 16-bit words can be supplied to the program function. // Each word is programmed until the whole buffer is programmed or a // problem is found. However to program a buffer that has more than 8 // words, program function can be called in a loop to program 8 words for // each loop iteration until the whole buffer is programmed. // // Remember that the main array flash programming must be aligned to // 64-bit address boundaries and each 64 bit word may only be programmed // once per write/erase cycle. Meaning the length of the data buffer // (3rd parameter for Fapi_issueProgrammingCommand() function) passed // to the program function can only be either 4 or 8. // // Program data in Flash using "AutoEccGeneration" option. // When AutoEccGeneration opton is used, Flash API calculates ECC for the given // 64-bit data and programs it along with the 64-bit main array data. // Note that any unprovided data with in a 64-bit data slice // will be assumed as 1s for calculating ECC and will be programmed. // // Note that data buffer (Buffer) is aligned on 64-bit boundary for verify reasons. // // Monitor ECC address for Bank0 Sector6 while programming with AutoEcc mode. // // In this example, 0xFF+1 bytes are programmed in Flash Bank0 Sector6 // along with auto-generated ECC. // // Fill a buffer with data to program into the flash. // /* for(i=0; i <= WORDS_IN_FLASH_BUFFER; i++) { Buffer[i] = i; }*/ for(i=0, u32Index = canHandle->Addr_FlashStart; (u32Index < (canHandle->Addr_FlashStart + 0.5*(canHandle->counter_byte -2))) ; i+= 8, u32Index+= 8) { oReturnCheck = Fapi_issueProgrammingCommand((uint32 *)u32Index,Buffer+i, 8, 0, 0, Fapi_AutoEccGeneration); // Wait until the Flash program operation is over while(Fapi_checkFsmForReady() == Fapi_Status_FsmBusy); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); statusCode.status = PROGRAM_ERROR; } // Read FMSTAT register contents to know the status of FSM after // program command to see if there are any program operation related errors oFlashStatus = Fapi_getFsmStatus(); if(oFlashStatus != 0) { //Check FMSTAT and debug accordingly //FMSTAT_Fail(); statusCode.status = PROGRAM_ERROR; } // Verify the programmed values. Check for any ECC errors. // The program command itself does a verify as it goes. // Hence program verify by CPU reads (Fapi_doVerify()) is optional. oReturnCheck = Fapi_doVerify((uint32 *)u32Index, 4, Buffer32+(i/2), &oFlashStatusWord); if(oReturnCheck != Fapi_Status_Success) { // Check Flash API documentation for possible errors //Example_Error(oReturnCheck); statusCode.status = PROGRAM_ERROR; } } if(statusCode.status != PROGRAM_ERROR) { statusCode.status = NO_ERROR; } }
Again, I can go through the whole bootloader process, when I disable ECC.
I can't verify after programming when ECC enabled.
Arrow
Hi Arrow,
Did you check the ECC error log registers to know the address at which ECC error is occurring?
Please inspect that address and make sure whether the corresponding flash and ECC are erased or not.
Note: I am out of office and may return early next week.
I will ask our team to monitor this post for you.
Thanks and regards,
Vamsi
Hi Vamsi
I will check the register to see the address.
Since I can skip the ECC to fulfill the flash process , this is not an urgent issue now.
I'll keep you informed the lastest result maybe this Saturday, since now is the China's national holiday.
Thanks and regards
Arrow
Hi Arrow,
Thanks for your reply, enjoy the national holiday! Please note that Vamsi will be out of office until early to mid-next week. Any replies before that may not be seen.
Regards,
Vince
Hi Arrow,
Do you need further help on this? Did you check the suggested registers?
Thanks and regards,
Vamsi
Hi Arrow,
I am closing this post since I did not hear back from you in the last 3 weeks.
Please open a new post as needed.
Thanks and regards,
Vamsi