Other Parts Discussed in Thread: UNIFLASH
Tool/software:
Hello,
I am trying to overwrite the AJSM key programmed in the OTP sector 0 using the FlashApi. I made sure that the new 128-bit key only flips bits from 1 to 0 compared to the previously programmed key.
After enabling programming to the OTP and issuing the programming command, the FSMSTAT register has bit 14 set to 1, corresponding to ILA "illegal address". Is there maybe some side effect that I forgot to consider?
Here's my current code using the FlashAPI:
#include <F021.h> #define AJSM_KEY_LEN 16u ///< The length of the AJSM key in bytes #define AJSM_KEY_ADDRESS (0xF0000000u) bool write_ajsm_key(const uint8_t ajsm_key[AJSM_KEY_LEN]) { const uint8_t unlockOtpBank0 = 1u; Fapi_StatusType fret = Fapi_enableBanksForOtpWrite(unlockOtpBank0); if ((fret != Fapi_Status_Success) || (FAPI_GET_FSM_STATUS != 0)) { return false; } fret = Fapi_issueProgrammingCommand((uint32_t*)AJSM_KEY_ADDRESS, ajsm_key, AJSM_KEY_LEN, NULL, 0u, Fapi_AutoEccGeneration); while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy) { ; } if ((fret != Fapi_Status_Success) || (FAPI_GET_FSM_STATUS != 0)) { Fapi_disableBanksForOtpWrite(); return false; } Fapi_disableBanksForOtpWrite(); Fapi_FlashStatusWordType fsw; return Fapi_doVerifyByByte((uint8_t*)AJSM_KEY_ADDRESS, AJSM_KEY_LEN, ajsm_key, &fsw) == Fapi_Status_Success; }
Thank you for your help.
BR, Aaron