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.

TMS570LS3137: Writing second time to OTP sector using FlashAPI fails.

Part Number: TMS570LS3137
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

  • Hi Aaron,

    Did you get a chance to refer this pdf:

    0250.Hercules_AJSM_Lock_Unlock.pdf

    --
    Thanks & redgards,
    Jagadish.

  • Hi Jagadish,

    Yes, I have used this presentation as a reference for all AJSM related tasks.

    Here I think my issue comes from the usage of the FlashApi (for this I've used the Reference Guide SPNU501H and the TRM SPNU499C as references). The code I've posted above seems to work sometimes but I don't manage to find why it does fail on other tries. Are there maybe additional bits I need to set in the FlashAPI before writing to the OTP?

    Short background: I was hoping to implement this AJSM locking functionality into a bootloader. But if this does not work reliably, I will just revert to using UNIFLASH for writing the AJSM key to the OTP instead.

    Best regards, Aaron