工具与软件:
您好!
我想通过 MCRC 模块来计算 RAM 不同部分的 CRC、并把它与连接器计算出的值相比较。
在链接器中、我添加了以下器件来计算 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 */
[...]
然后在源代码中、我有一个任务涉及:
#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) );
[...]
}
目前作为测试、我仅计算.text 段的 CRC。 结果总是错误的、为什么?
我 在这里读到 、MCRC 模块使用 TMS570_CRC64_ISO 算法计算 CRC、所以我直接使用 psaSignRegAddr.regL 寄存器上的 uint64_t 数据进行复制、正确吗?
此致、
Andrea




