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.

Compiler/TMS570LS1115: How to Calculate CRC Checksum for code in Flash (boot loader application)

Part Number: TMS570LS1115

Tool/software: TI C/C++ Compiler


My application requires a boot loader.

I have two separate code areas that I want to calculate a CRC checksum on (CRC32_PRIME), FLASH_BOOT0 & FLASH0 and record the CRC checksum in two separate areas defined as CRC_TABLE_BOOT , CRC_TABLE_CODE.

How do i do this ?

I will then require the TMS570LS.. to perform a CRC on the two code Flash areas and compare the static checksums to the calculated checksums.

Have referenced other similar postings but cant quite grasp the command structures.

If you can provide a Function to calculate the (CRC32_PRIME) to compare against the Static Flash CRC would also be of great assistance.


MEMORY
{

CRC_TABLE_BOOT (RX) : origin=0x00003000 length=0x00000100 fill=0xFFFFFFFF // sect0, 256 bytes
CRC_TABLE_CODE (RX) : origin=0x00003100 length=0x00000100 fill=0xFFFFFFFF // sect0, 256 bytes

FLASH_BOOT0 (RX) : origin=0x00004000 length=0x00008000 fill=0xFFFFFFFF // sect1,2 - 16k,16k length = 0x8000, 32,767 bytes

FLASH0 (RX) : origin=0x00040000 length=0x00060000 fill=0xFFFFFFFF // sect 8,9,10 - Main Code Space 128K x 3 (393,215 bytes)
}

SECTIONS
{

/* calculate CRC for FLASH_BOOT0 and place the CRC table in CRC_TABLE_BOOT */

.data_2b_checked_boot:{ FLASH_BOOT0 } crc_table(flash_boot_crc_table_boot) > CRC_TABLE_BOOT // error this doesn't work

/* calculate CRC for FLASH0 and place the CRC table in CRC_TABLE_CODE */

.data_2b_checked_code:

.text : {} > FLASH0
.const : {} > FLASH0
.cinit : {} > FLASH0
.pinit : {} > FLASH0
.bss : {} > RAM
.data : {} > RAM
.sysmem : {} > RAM

}

  • Hello Rob,

    1. You can use cmd file to calculate the CRC for any output section
    2. You can use CRC module to calculate the CRC of any section of the flash memory. The CRC module has 2 channels. It supports 3 modes: auto mode, semi-CPU mode, and full-CPU mode.

    Using CMD file, you need define the output section:

    output_section_name /* Name the output section */
    {
    file1.obj(.text) /* List the input sections */
    file2.obj(.text)
    file3.obj(.text)
    } > FLASH0 /* Allocate to FLASH memory range */

    This creates an output section named output_section_name. It is composed of 3 input sections: .text from file1.obj, .text from file2.obj, and .text from file3.obj. It is allocated to the FLASH0 memory range.

    Then calculate the CRC for this output section:

    output_section_name : {} palign=8, crc_table(_my_crc_table, algorithm=TMS570_CRC64_ISO) > FLASH0
  • 2. Using semi-CPU mode to calculate the CRC for code in flash:

    dmaEnableInterrupt(DMA_CH0, BTC); /* DMA_CH0 is highest priority */
    dmaEnableInterrupt(DMA_CH1, BTC);

    //using CRC semi-PCU mode
    crcInit();

    _enable_IRQ();

    dmaEnable();

    dma_config.SADD = (uint32_t)&start address of your code in flash;
    dma_config.DADD = (uint32_t)&(crcREG->PSA_SIGREGL1);
    dma_config.CHCTRL = 0;
    dma_config.FRCNT = 0x1000; //64-bit, length of your code section in flash
    dma_config.ELCNT = 1;

    dma_config.ELDOFFSET = 0;
    dma_config.ELSOFFSET = 0;
    dma_config.FRDOFFSET = 0;
    dma_config.FRSOFFSET = 0;
    dma_config.PORTASGN = 4;
    dma_config.RDSIZE = ACCESS_64_BIT;
    dma_config.WRSIZE = ACCESS_64_BIT;
    dma_config.TTYPE = BLOCK_TRANSFER;
    dma_config.ADDMODERD = ADDR_INC1;
    dma_config.ADDMODEWR = ADDR_FIXED;
    dma_config.AUTOINIT = AUTOINIT_OFF;

    // setting dma control packets for receive
    dmaSetCtrlPacket(DMA_CH0, dma_config);
    dmaReqAssign(DMA_CH0, 26); //DMA request line 26, CRC1 channel0
    dmaSetChEnable(DMA_CH0, DMA_SW);