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.

CCS/UCD3138: Why the value after DATA FLASH CHECKSUM would be erased?How to compare the checksum if DFLASH needs to be erased?

Part Number: UCD3138

Tool/software: Code Composer Studio

Hello,

I look through the constants.c in HSFB firmware.And I notice the code as below:

//  ------------- DATA FLASH CHECKSUM  -------------
#pragma DATA_SECTION(pmbus_checksum, ".CONFIG");
volatile const Uint32 pmbus_checksum = 0x87654321;

#pragma DATA_SECTION(pmbus_checksum_b, ".CONFIG_B");
volatile const Uint32 pmbus_checksum_b;

If i write code after that like this:

#pragma DATA_SECTION(hly_set, ".HLY")
volatile const  un_hly hly_set = Z;// Z is constant

The location of ".HLY"(org = 0x00018FA0) is after ".CONFIG" in DFLASH.

However,the Z may be erased while the value before CHECKSUM not.

Could you give me some advices?

Thanks!

  • An expert will get back to you soon.
  • Is the location of ".HLY"(org = 0x00018FA0) in the same segment of DFlash as the checksum or defined far away?
  • Hello,

    I think they are not in the same segment.

    The code in SECTIONS is like this:

        /*------------------------------------------------------------------------------------*/
        /* D-Flash   2K    0x18800 - 0x18FFF                                                  */
        /*------------------------------------------------------------------------------------*/
         .dflash   : {} > (DFLASH align(32))
    		//data flash
    	.CONFIG    : {} > (DFLASH align(32))
        .CONFIG_B  : {} > (DFLASH align(32))
    	.PASSW     : {} > (DFLASH align(32))
    
    	//hly_add20190117
    	.HLY	   : {} > (DFLASHSET1 align(32))
    	.HLY_B	   : {} > (DFLASHSET2 align(32))
    	.HLY_C	   : {} > (DFLASHSET3 align(32))

    The code in MEMORY as below:

        /*------------------------------------------------------------------------------------*/
        /* D-Flash   2K    0x18800 - 0x18FFF                                                  */
        /*------------------------------------------------------------------------------------*/
        DFLASH    (RX) : org = 0x00018800, len = 0x000007A0
        /****************hly_add_2019_02_12***************************************************/
        DFLASHSET1    (RX) : org = 0x00018FA0, len = 0x00000020
        DFLASHSET2    (RX) : org = 0x00018FC0, len = 0x00000020
        DFLASHSET3    (RX) : org = 0x00018FE0, len = 0x00000020

    And .map file says:

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      VECS                  00000000   00000020  00000020  00000000  RWIX
      PFLASH                00000020   00007f38  00005d5e  000021da  R  X
      DEVICEID              00007f58   00000020  0000001f  00000001  R  X
      FIXTFA                00007f78   00000004  00000000  00000004  R  X
      FIXCONST              00007f7c   00000080  00000000  00000080  R  X
      FLASHSUM              00007ffc   00000004  00000000  00000004  R  X
      ROM                   0000a020   00000be0  00000000  00000be0  RWIX
      SINE                  0000ac00   00000282  00000000  00000282  RWIX
      EXP                   0000ae82   0000007a  00000000  0000007a  RWIX
      DFLASH                00018800   000007a0  000002e0  000004c0  R  X
      DFLASHSET1            00018fa0   00000020  00000008  00000018  R  X
      DFLASHSET2            00018fc0   00000020  00000008  00000018  R  X
      DFLASHSET3            00018fe0   00000020  00000008  00000018  R  X
    .CONFIG    0    00018800    00000170     
                      00018800    00000170     constants.obj (.CONFIG)
    
    .CONFIG_B 
    *          0    00018980    00000170     UNINITIALIZED
                      00018980    00000170     constants.obj (.CONFIG_B)
    
    .HLY       0    00018fa0    00000008     
                      00018fa0    00000008     constants.obj (.HLY)
    
    .HLY_B     0    00018fc0    00000008     
                      00018fc0    00000008     constants.obj (.HLY_B)
    
    .HLY_C     0    00018fe0    00000008     
                      00018fe0    00000008     constants.obj (.HLY_C)

    Checksum is in ".CONFIG",and the data in ".HLY" & ".HLY_B" &".HLY_C" may be erased

  • The statement:

    if (erase_segment_counter > 0)
    {
    erase_task(); // Handle the DFlash segment erases
    }

    in the beginning of main() erases the segments in DFlash block that is not valid. This is done in the background.
    If the value of erase_segment_counter which is set by the function calc_flash_segments() is set wrong (higher) , this will cause extra segments to be erased. Comment out the above statement in the main() temporarily, and see if it makes a difference.
    If this helps, you have to check the value of erase_segment_counter and first_segment returned by calc_flash_segments().

    Regards,
  • Thanks for your advice。I'll check it as soon as possible.If it works,I'll click This resolved my issue then.
  • Is this happening intermittently and only with a specific UCD? Or it happens always and with several UCDs/Boards?
  • Hi,

    It hanppened on nothing but one board. Not every time.Sometimes It didin't happen in a day.Sometimes it happened 3 times an hour.
  • Hi,when I tracked start_erase_task(),I found bytes_to_erase is from pmbus_checksum to filter0_pmbus_regs.

    The function look_for_interrupted_dflash_erase() checks DFLASH,but filter0_pmbus_regs is in RAM(0x00019248).

     Is it filter0_pmbus_regs_constants?Or maybe I misunderstood it?

    void look_for_interrupted_dflash_erase(void)
    {
    	volatile Uint32	bytes_to_erase, checksum, checksum_b,blank_checksum;;
    	bytes_to_erase = ((Uint8*)&pmbus_checksum - (Uint8*)&filter0_pmbus_regs);
    	blank_checksum = 0xff * ((Uint8*)&pmbus_checksum - (Uint8*)&filter0_pmbus_regs);
    	checksum = calculate_dflash_checksum((Uint8*)&filter0_pmbus_regs, 
    		(Uint8*)&pmbus_checksum);

  • You are right. That does not make sense.
    Please replace the above with the following:

    void look_for_interrupted_dflash_erase(void)
    {
    volatile Uint32 bytes_to_erase, checksum, checksum_b,blank_checksum;

    bytes_to_erase = ((Uint8*)&pmbus_checksum - (Uint8*)&filter0_pmbus_regs_constants);
    blank_checksum = 0xff * bytes_to_erase;
    checksum = calculate_dflash_checksum((Uint8*)&filter0_pmbus_regs_constants,
    (Uint8*)&pmbus_checksum);
    if(checksum != blank_checksum)
    {
    if((checksum!=pmbus_checksum)&&(pmbus_checksum!=0x87654321))
    { //erase BANK A
    start_erase_task((void*)&filter0_pmbus_regs_constants, (bytes_to_erase + 4));
    return;
    }
    }

    checksum_b = calculate_dflash_checksum((Uint8*)&filter0_pmbus_regs_constants_b,
    (Uint8*)&pmbus_checksum_b);
    if((checksum != blank_checksum) && (checksum_b != blank_checksum))
    {
    //BANK A is available and BANK B is not BLANK; Erase BANK B, ignor any checksum of BANK B.
    //and start erasing BANK B
    start_erase_task((void*)&filter0_pmbus_regs_constants_b, (bytes_to_erase + 4));
    return;
    }
    //BANK B is empty, don't need erase it again.
    erase_segment_counter = 0;
    return;
    }