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.

[参考译文] TMS320F280037C:BGCRC 和 SREC CRC 不匹配。

Guru**** 2534260 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1172262/tms320f280037c-bgcrc-and-srec-crc-does-not-match-up

器件型号:TMS320F280037C

你好!  

我正在尝试通过 BGCRC ( 闪存组)运行128KB 的数据。  )。 我无法一次运行所有数据、因为它位于闪存中。 我检索一些数据、通过 BGCRC 运行它、在计算完成后、我使用 CRC 结果作为下一次计算的种子。 在执行另一个计算之前、Code Composer 会检查 BGCRC 是否空闲。 我要比较的 CRC 使用 SREC 进行计算。

此外... BGCRC 使用什么 CRC32算法?

SREC:

Fill 0xFFs
srec_cat.exe %outputfolder%\%projname%_clean.S -fill 0xFF %AppStartAddress% %AppEndAddress% -o %outputfolder%\%projname%_temp.S -Output_Block_Size=%blocksize%

Calculate checksum on filled hex file
%btfolder%\SREC\srec_cat.exe %outputfolder%\%projname%_temp.S -crop %AppStartAddress% %AppEndAddress% -CRC32LE %AppCrcAddress% -o %outputfolder%\%projname%_temp.S -Motorola 8 -Output_Block_Size=64

CCS:

INT16U  data[128] __attribute__ ((section(".BGCRC")));

//These are run in an init function:
BGCRC_setConfig(BGCRC_CPU_BASE, BGCRC_NMI_DISABLE, BGCRC_EMUCTRL_SOFT);
BGCRC_setRegion(BGCRC_CPU_BASE, (INT32U)&data, BGCRC_SIZE_BYTES_256, BGCRC_CRC_MODE);


void CheckFlashBankCRC(void)
{
    static INT32U WordsLeft = 57344; // Number of words in 14 sectors.
    static INT16U offset = 0;
    static INT32U crc = 0;
    INT32U receivedCrc = 0;
    static BOOL crcFinished = FALSE;



    // Check if BGCRC is finished with the previous calculation.
    if((BGCRC_getRunStatus(BGCRC_CPU_BASE) == BGCRC_IDLE))
    {
        crc = BGCRC_getResult(BGCRC_CPU_BASE);

        // Check if the crc is done.
        if(crcFinished)
        {
            // Read the received CRC in the flash bank.
            memcpy(receivedCrc, (INT32U*)(0x8DFFE + bankOffset), 2);

            // Check if CRC is OK
            if(receivedCrc == crc)
            {
                //Write revision
            }

            WordsLeft = 57344;
            offset = 0;
            crcFinished = FALSE;
        }
        else
        {
            BGCRC_setSeedValue(BGCRC_CPU_BASE, crc);
            
            if(WordsLeft <= 128)
            {
                // Read 128 words from Flash to RAM
                memcpy(data, (INT32U*)(0x80000 + bankOffset + offset), 128);
                // Last two words is set to FFFF because they contain the received CRC
                memset(data + 126, 0xFFFF, 2);
            }
            else
            {
                // Read 128 words from Flash to RAM
                memcpy(data, (INT32U*)(0x80000 + bankOffset + offset), 128);
            }

            WordsLeft -= 128;
            offset += 0x80;

            if(WordsLeft <= 0)
            {
                crcFinished = TRUE;
            }

            BGCRC_start(BGCRC_CPU_BASE);
        }
    }
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
    [引用 userid="534186" URL"~/support/microcontrollers/c2000-microcontrollers-group/c2000/f/c2000-microcontrollers-forum/1172262/tms320f280037c-bgcrc-and-srec-crc-does-not-match-up "]我要比较的 CRC 是使用 SREC 计算的。

    您可能会发现您的问题是 srec.exe 无法正确解释.hex/.s 文件、因为根据我的经验、由于最小可寻址单元为16位、许多第三方工具无法解析来自 hex2000.exe 的 TI 十六进制文件输出。 使用一条记录创建一个小的十六进制文件、您可以手动计算 CRC、并确信 srec 将计算预期的 CRC。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我已检查 SREC 文件、这是正确的。 我的同事查看了 SREC 的源代码并创建了一个 CRC32函数、使 CRC 匹配。 感谢您的回复!