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.

AIS CRC calculation and operation (C6748)

Other Parts Discussed in Thread: TMS320C6748, OMAP-L138

A continuation of this thread

http://e2e.ti.com/support/dsp/tms320c6000_high_performance_dsps/f/115/t/119062.aspx

but for the C6748.

I am writing a user bootloader that will use the AISGEN format for the application. I will be using CRC to check for data corruption. The CRC Look Up Table is incorrect in

Application Report, SPRAAT2E–August 2011, Using the TMS320C6748/C6746/C6742 Bootloader, Appendix C CRC Computation Algorithm

Using the above published table, the computed CRC does NOT match the one from AISGEN D800K008.

Using dvflashutils source, I regenerated the table with "reflected=1". That table appears to work properly.

I am guessing the TRM is wrong. Similiarly the CRC errors in C6747 TRM has been identified in the other thread but changes have not made to newer TRMs. The C6748 TRM does not have important info from the other thread as well. Notably that CRC includes SIZE, ADDR. The CRC has an initial value of 0xFFFFFFFF and is XOR'ed with 0xFFFFFFFF at the end.

  • Thank you for the feedback Norman.

    I confirm that the change acknowledged on the other thread hasn`t found its way to the bootloader user guide. We are working on fixing this issue. If it helps the CRC implementation in the AISGen tools is provided in complete source in the Serial Flash and boot utilities package under the path OMAP-L138_FlashAndBootUtils_2_40\OMAP-L138\GNU\AISUtils\HexAIS\CRC.module.

    Regards,

    Rahul

  • I have been using that source to figure out the algorithm. I actually used the other copy at OMAP-L138_FlashAndBootUtils_2_40\Common\UtilLib\CRC.cs. Both are the same. It is 788 lines, 27,130 bytes of obtuse and inefficient C# code. None of which is usable in an embedded C environment. The use of "reflected" flag to generate the Look Up Table is mathematically questionable. The CRC polynomial will be reversed end to end. I am beginning to doubt if a CRC enabled boot image will actually boot on a C6748. I'll test that next.

  • Hi

    I have modified the old genAIS.pl so that it generates the correct CRC for C6748. See diff below:

    Regards

    Fredrik


    --- a/dsp_src/dsp_tools/genAIS.pl
    +++ b/dsp_src/dsp_tools/genAIS.pl
    @@ -67,6 +67,7 @@ use File::Basename;
    use XML::Simple;
    use MIME::Base64;
    use File::Temp qw(tempfile tempdir);
    +use Compress::Zlib qw(crc32);

    my ($CFG);
    my ($COFF);
    @@ -687,8 +688,15 @@ sub CreateAISStream {
    $seek = int ($secSize + $sizeOfSectionLoad + $sizeOfRequestCrc);

    $crcVal = 0 if ($genCrc eq '1');
    - $crcVal = calcCrcWord($runAddr,$crcVal);
    - $crcVal = calcCrcWord($secSize,$crcVal);
    + #$crcVal = calcCrcWord($runAddr,$crcVal);
    + #$crcVal = calcCrcWord($secSize,$crcVal);
    +
    + # C6748 bootloader uses standard CRC32 algorithm
    + # while the older DSPs used some unstandard algorithm
    + # therefore we have replaced the crc calculations
    + $crcVal = crc32(pack('V', $runAddr),$crcVal);
    + $crcVal = crc32(pack('V', $secSize),$crcVal);
    +
    if ($debug) {
    printf $fh ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n";
    printf $fh ";;; Calling calcCrc for Section :%s:\n",$secName;
    @@ -709,7 +717,10 @@ sub CreateAISStream {
    }
    }

    - $crcVal = calcCrcSection($secSize,$crcVal,0, $fh);
    + #$crcVal = calcCrcSection($secSize,$crcVal,0, $fh);
    + for($j=0; $j < $numWords; $j++) {
    + $crcVal = crc32(pack('V', $secRawData[$j]), $crcVal);
    + }

    if ($genCrc eq '1') {
    if (($oType eq "ASM") || ($debug)) {
  • I had forgotten about this thread. It has been 3 years since I finished this project. I did eventually successfully calculate a matching CRC. Forgot what I did. Reviewing my old code, I found that SPRAAT2 is correct but its listed column major rather than row major. Makes it difficult to cut and paste into C code. The sample code provides the core of the CRC calc. It is a bit incomplete as it does tell not how to the use the calc properly. The key is the additional CRC of address and length. Plus other fields. Not much point in expecting the TRM to state this when various code out there shows the steps more succinctly. Call it solved.

    I don't remember using the genAIS.pl script with the C6748. I think that it applies to that series. Thanks for the info on genAIS.pl anyway.

  • You can find the genAIS.pl here: www-s.ti.com/.../sprc203.zip

    It is made for C672x but works fine for C6748 except for the CRC calculation. As you might see I did use the crc32 function from perl zlib library. I would assume that you could do the same in C. I.e. use the zlib crc32 function instead of copying the lookup table and the crc code from the TI datasheet.
  • My task was to build a secondary bootloader that loaded a CRC'ed image. I did not want to create another desktop tool to add an CRC to an image, so I use AISGEN to build CRC'ed image. I wanted the seconday bootloader to be as simple as possible. In theory, I could have ported over the zlib code. At the time, it seems that the CRC was custom. Besides porting over zlib would be a heavier than woud need be for a bootloader.