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.

UCD3138: rom password example

Part Number: UCD3138

Hello UCD friends,

I'd like to implement rom password pmbus command, this is help to protect device from erase it's password. 

Can you please help me know which command support this? And that would be perfect if you could share the code inside this command routine.

  • Hi Jack,

    I should have the code but due to bad weather South campus is closed and I do not have access to the code at the moment.

    I will hopefully take care of this next week.

    Sorry for the delay caused.

    Regards,

  • Hello Jack,

    Sorry for the delay caused.

    Are you referring to protection against accidental erase of Dflash, or something else?

    Please add some more details,

    Regards,

  • Hello again Jack,

    The best way to protect Dflash or PFlash against accidental erase or write is to have the PFlash or DFlash key in written in RAM by a separate PMBus command, instead of having it as a constant in the code.

    This way you need to first send a command that writes the key in RAM (Choose you own command code) and then a second command (0xD9 ) that uses the key in RAM to open the Flash for erase or write.

    Here’s the code for protecting DFlash, but the code for PFlash protection is very similar.

    It’s a pretty simple set of changes:

     

    1. Create a new variable in RAM:

    EXTERN Uint32 dflash_key;

    1. Create a new pmbus command function:

    int32 pmbus_write_dflash_key(void)

    {

                    dflash_key = (pmbus_buffer[2] << 24) + (pmbus_buffer[3] << 16) + (pmbus_buffer[4] << 8) + pmbus_buffer[5];

     

                    return PMBUS_SUCCESS;

    }

    1. Add a case to the pmbus_write_message function to handle writing to dflash_key.  I have arbitrarily picked a command code of 0xf3.  You will have to pick your own that’s available with your command set:

                    case PMBUS_CMD_MFR_SPECIFIC_35: //this translates to command 0xf3

                                    return pmbus_write_dflash_key();

    1. There are at least 3 spots in the software interrupt function that write or erase the data flash.  Case 1, case 3, and case 13 should be the specific cases
      1. All the cases will have a line something like this:

    DecRegs.FLASHILOCK.all = 0x42DC157E; //unlock flash write;

    1. Or this:

            DecRegs.FLASHILOCK.all = DATA_FLASH_INTERLOCK_KEY; //unlock flash write;

    1. Replace the three lines with this:

    DecRegs.FLASHILOCK.all = dflash_key; //unlock flash write;

     

     

    Those are the code changes.  For writing the calibration data, before you send whatever command writes the data, you will need to send the PMBus command to write to the dflash register.  This will be a block write of the correct key, 0X42DC157E.

     

    The details of the block write are as follows:

     

    Start

    Address byte with read/write bit cleared

    Command byte – 0xf3 in example code – whatever you select in your code

    Repeated start

    Number of bytes in block – 04 in this case

    42

    DC

    15

    7E

    PEC byte.

     

    After the write of the data flash, and the erase of the new data flash, you will want to send the command again, only with all zeroes this time, to protect the data flash. 

     

    Note that the data flash write takes about 50 usec per word, and the erase takes 20 msec per page of 32 bytes.  Once the erase is started, the PMBus will be active again.  So if you don’t wait long enough, some of the erase will not be complete when the dflash_key location is changed.  This will make the next write to data flash fail.  You need to add more time for overheand, and because timing imposed by a PC is not well controlled.  It’s easy for the commands that are sent to the API 1 second apart to get much closer by the time they finally get out. 

    Hope this makes sense,

    Regards,

  • Hi Yitzhak,

    Thanks for your strong support here. This is very good point of protecting Pflash and Dflash from erase accidently, and it's clear to me. Thanks...