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.

MCU-PLUS-SDK-AM243X: Calculate CRC of sections with MCRC and compare with linker results

Part Number: MCU-PLUS-SDK-AM243X


Tool/software:

Hi,

I would like to calculate the CRC of different sections of RAM through the MCRC module and compare it with the value calculated by the linker.

In the linker I added these parts to calculate the CRC:

[...]

    GROUP {
        .text:   {} palign(8)   /* This is where code resides */
        .rodata: {} palign(8)   /* This is where const's go */
    } crc_table(application_crctab) > DDR_CORE_0_APP

[...]

    .TI.crctab : {} > DDR_CORE_0_CRC

[...]

	DDR_CORE_0_CRC          : ORIGIN = 0x83E00000, LENGTH = 0x00200000 /*  2 MB */

[...]

Then in source code I have a task with:

#include <crc_tbl.h>

#include <kernel/dpl/AddrTranslateP.h>
#include <drivers/crc.h>

#include "ti_drivers_open_close.h"
#include "ti_board_open_close.h"

#define APP_CRC_PATTERN_SIZE                ((uint32_t) 8U)
#define APP_CRC_SECT_CNT                    ((uint32_t) 1U)
#define APP_CRC_WATCHDOG_PRELOAD_VAL        ((uint32_t) 0U)
#define APP_CRC_BLOCK_PRELOAD_VAL           ((uint32_t) 0U)


extern CRC_TABLE application_crctab;

static void taskCrc(void *args)
{

    uint32_t                loopCnt, patternCnt, baseAddr;
    CRC_Channel_t           chNumber;
    CRC_Signature           signVal;
    CRC_SignatureRegAddr    psaSignRegAddr;

    CRC_RECORD    crc_rec = application_crctab.recs[0];

    /* Configure CRC parameters */
    baseAddr           = (uint32_t) AddrTranslateP_getLocalAddr(CONFIG_CRC0_BASE_ADDR);
    DebugP_assert(crc_rec.size % APP_CRC_PATTERN_SIZE == 0);
    patternCnt         = crc_rec.size / APP_CRC_PATTERN_SIZE;
    chNumber           = CRC_CHANNEL_3;

    /* Get CRC PSA signature register address */
    CRC_getPSASigRegAddr(baseAddr, chNumber, &psaSignRegAddr);

    /* Initialize and Configure CRC channel */
    CRC_initialize(baseAddr, chNumber, APP_CRC_WATCHDOG_PRELOAD_VAL, APP_CRC_BLOCK_PRELOAD_VAL);

    CRC_configure(baseAddr, chNumber, patternCnt, APP_CRC_SECT_CNT, CRC_OPERATION_MODE_FULLCPU);

    /* Reset the CRC channel*/
    CRC_channelReset(baseAddr, chNumber);

    uint64_t* buffer = (uint64_t*) crc_rec.addr;

    /* compute the CRC by writing the data buffer on which CRC computation is needed */
    for (loopCnt = 0; loopCnt < patternCnt ; loopCnt++)
    {
        *(volatile uint64_t *) ((uintptr_t) psaSignRegAddr.regL) = buffer[loopCnt];
    }

    /* Fetch CRC signature value */
    CRC_getPSASig(baseAddr, chNumber, &signVal);

    /* Compare CRC signature value against reference CRC signature */
    char CRCresult = ( ((crc_rec.crc_value & 0xFFFFFFFF) == signVal.regH) &&
                  (((crc_rec.crc_value >> 32) & 0xFFFFFFFF) == signVal.regL) );
    
    [...]
}

For now as a test I only calculate the CRC of the section .text. The result is always wrong, why?
I read here that the MCRC module calculates CRC with the TMS570_CRC64_ISO algorithm, so I make copies directly with uint64_t data on the psaSignRegAddr.regL register, is this correct?

Best regards,

Andrea