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.

Calculate Flash CRC and compare to the one stored in flash by linker

Hello,

I want to calculate the .text section's CRC and for that I added the following code to my linker

palign=8, crc_table(g_linker_sourceCrc, algorithm=TMS570_CRC64_ISO)> FLASH0 | FLASH1

and my main.c contains the variable (extern const CRC_TABLE g_linker_sourceCrc;)

After that I get the data I need from the g_linker_sourceCrc constant.

uint8_t *pCrc = (uint32_t)g_linker_sourceCrc.recs[0].addr;
uint64_t crc = g_linker_sourceCrc.recs[0].crc_value;
uint32_t size = g_linker_sourceCrc.recs[0].size/8;

And finally I initiate the CRC module and feed data to it.

CRCReg->CRC_CTRL0 |= 0x00000001;        // reset CRC module
CRCReg->CRC_CTRL0 &= 0xFFFFFFFE;
CRCReg->CRC_CTRL2 |= 0x00000003;        // configure full CPU mode

for(i = 0; i < size; i++) {
	CRCReg->PSA_SIGREGL1 = *pCrc++;
}

This should calculate a CRC that matches the one generated by the linker (true or not?), but I get very different CRCs. What could be the problem?

  • Hi Pablo,

    Which linker version are you using? There was a bug in the linker versions which was fixed in version 5.1.3 and later.

    You can find more details and an example CCS project for the RM48 in this thread: e2e.ti.com/.../288356

    Regards,
    Sunil
  • I'm using compiler version 5.1.1 on CCS 5.5. So .... It's buggy. I would change the compiler version, but this type of project is a bit difficult to change compiler at this time. Is there a way I can fix it without changing the compiler version? Maybe modifying a script or something?
  • Pablo,

    There are also other critical and major bugs fixed from v5.1.1 to v5.1.3. I have attached a document that lists all bugs fixed going from v5.1.1 to v5.1.3.

    Just as a note, the latest version in this compiler version stream is v5.1.12. Do you need a list of all updates from 5.1.1 to 5.1.12?

    I will check with the codegen tools' team to see if there is a way to just fix the CRC generation issue using a script.

    7624.v511_to_v513.pdf

    Regards, Sunil

  • Ok, I installed the latest version of CCS and tried. Again ... the CRC calculation failed, so I must be doing something wrong. Here's my source:

    #include <stdint.h>
    int main(void) {
        uint32_t size;
        uint32_t i;
        uint64_t *pCrc = g_linker_sourceCrc.recs[0].addr;
        uint64_t val;
        uint64_t crc = g_linker_sourceCrc.recs[0].crc_value;
        uint32_t addr = g_linker_sourceCrc.recs[0].addr;
    
        CRCReg->CRC_CTRL0 |= 0x00000001; // reset CRC module
        CRCReg->CRC_CTRL0 &= 0xFFFFFFFE;
        CRCReg->CRC_CTRL2 |= 0x00000003; // configure full CPU mode
    
        size = g_linker_sourceCrc.recs[0].size / 8;
        for(i = 0; i < size; i++) {
            uint64_t swap = *pCrc & 0xFFFFFFFFU;
            swap <<= 32U;
            swap |= (*pCrc >> 32U) & 0xFFFFFFFFU;
            CRCReg->PSA_SIGREG = *pCrc;
            pCrc++;
        }
    
        val = CRCReg->PSA_SECSIGREG;
    }