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.

TMS320F28379D: Problem with erasing and programming secured flash sector from within the secured zone

Part Number: TMS320F28379D

Hi,

I have my own bootloader in FLASHA and B. I am trying to erase and then program the application in consecutive flash sectors.

I setup security zone 1 by:

1) Z1-GRABSECT = 0x0555 5555 (all flash sectors in zone Z1)

2) Z1-GRABRAM = 0x1000 5015 (cla, ramd0, ramd1, ramls0-2 in the zone)

Flash programming functions are located in ramd0-1, by linker settings:

.TI.ramfunc: { -l F021_API_F2837xD_FPU32.lib }
LOAD = FLASHAB, PAGE = 0
RUN = RAMD0_1, PAGE = 0,
LOAD_START(_RamfuncsLoadStart),
LOAD_SIZE(_RamfuncsLoadSize),
LOAD_END(_RamfuncsLoadEnd),
RUN_START(_RamfuncsRunStart),
RUN_SIZE(_RamfuncsRunSize),
RUN_END(_RamfuncsRunEnd),
table(BINIT)

When there is no security setup the application is programmed properly, it means corresponding flash sector (i.e. flashC) is properly erased and programmed and next started.

When the security zone is enabled the operation of erasing the sector hangs inside the function:
      Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32 *)address);   //        (address is 0x84000)

It is called but never returns.

I read "Updating Firmware on Security Enabled TMS320F2837xx or TMS320F2807x Devices", and followed the second option when providing the key and unlock is not necessary:

"Since code running from within a zone can reprogram any Flash memory in that zone, the password for that zone need not be written into the KEY register and the zone will stay locked in the view of the other zone and unsecure space"

Regards,
Piotr Romaniuk

  • I found that common part of code containing Erase command and ready check must be in RAM.

    so now it is like this:

    #pragma CODE_SECTION(".TI.ramfunc")
    Fapi_StatusType EraseSector( Uint32 address )
    {
    Fapi_StatusType retv;

    EALLOW;
    retv = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector,(uint32 *)address);

    while( Fapi_checkFsmForReady() != Fapi_Status_FsmReady);
    EDIS;
    return retv;
    }

    The first function returns ok, the while loop finishes as well. After that I check status by Fapi_getFsmStatus();

    It returns 0x0000.0C10 that means:

    EV =1 Erase verify unsuccessful,

    CSTAT = 1     "Command Status. Once the FSM starts, any failure will set this bit. When set, this bit informs the
    host that the program or erase command failed and the command was stopped. This bit is cleared
    by the Clear Status command. For some errors, this will be the only indication of an FSM error
    because the cause does not fall within the other error bit types."

    Further tests show that the sector is not erased.

  • Hi Piotr,

    Did you configure the FLSEM register correctly for the zone from which you are executing the flash API?

    Please search TRM for more details on this.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    Yes it was FLSEM but I did not post the information yet. I overlooked this type of the semaphore in the document devoted to secure programming. That was because I confused flash pump semaphore and FLSEM - I thought that it is the same. It isn't, there are two types of semaphore:

    1) one is controling access to flash pump and arbitrates between two cores of F28379D i.e. cpu1 and cpu2,

    2) another one (i.e. FLSEM) controls from which zone the code can erase and program the flash memory.

    Maybe it is good idea to add a note to flash api document that in a case of secure zone the FLSEM must be properly set up.

    Regards,
    Piotr Romaniuk

  • Hi Piotr,

    Please see below notes from the flash API guide:

    We will review again and see if we need to add more clarity.  

    Thanks and regards,
    Vamsi

  • Hi Vamsi,

    what is the document and what page that you qouted? The Acrobat does not find FLSEM word in Flash API Reference Guide (v1.55).

    Regards,
    Piotr Romaniuk

  • Hi Piotr,

    By looking at the title of this thread (F28379D), I copied the snaps from the F28379D flash API guide.

    We did not mention FLSEM in the F2837xS flash API guide since we noticed that TRM has confusing documentation about FLSEM - we will add it in the next revision.  Thank you for notifying us.

    Thanks and regards,

    Vamsi

  • Hi Vamsi,

    I am sorry, this is my mistake. I looked in the document for ~S (1.55) instead of ~D chip (1.54). Nevertheless, accidentally I discovered this missing note Slight smile

    Thank you for your help,

    Piotr Romaniuk

    PS
    I need to pay more attention to the headers of documents.