Generating CRC32 from .srec files

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Generating CRC32 from .srec files

ソリューションへジャンプ
9,042件の閲覧回数
robertpoor
Senior Contributor I

I'm using the flash-resident Kinetis 2.x bootloader, and now my goal is to enable CRC checking in the Boot Configuration Area. 

I've read Erich Styger's excellent blog entry on CRC Checksum Generation with ‘SRecord’ Tools for GNU and Eclipse, that has gotten me 80% of the way toward my goal.

The challenge is that the CRC32 algorithm required by the Kinetis 2.0 bootloader is not supported by the SRecord tool suite.  In particular, the bootloader is expecting a CRC32 computed with the following parameters:

     crcUserConfigPtr.crcBits = kCrcBits32;
     crcUserConfigPtr.seed = 0xffffffff;
     crcUserConfigPtr.polynomial = 0x04c11db7U;
     crcUserConfigPtr.complementChecksum = false;
     crcUserConfigPtr.reflectIn = false;
     crcUserConfigPtr.reflectOut = false;

... and neither of the CRC32 algorithms provided with SRecord (CRC32 and STM32) supports this particular combination of parameters (notably reflectIn = false and reflectOut = false).

So: what's the shortest path to generating the CRC32 from a .srec file using those parameters?  Yes, I could write a parser for .srec files, compute the proper CRC and insert it into the Boot Configuration Area using SRecord, but it would seem like someone must have been down this path.  (It would be super if there was an add-on utility for KDS 3.x, but that might be asking too much!  Smiley Happy)

- Robert Poor

P.S. For some more information and context, you may look at this stack overflow entry.

ラベル(1)
タグ(2)
1 解決策
7,236件の閲覧回数
robertpoor
Senior Contributor I

It turns out that with the right switches and filters, you can use srec_cat to generate a valid  KBoot 2.0 CRC32 from a .srec file:

$ srec_cat test.srec -Bit_Reverse -CRC32LE 0x1000 -Bit_Reverse -XOR 0xff -crop 0x1000 0x1004 -Output -HEX_DUMP 00001000: 93 8F 97 9A                                      #....

In other words, bit reverse the bits going to the CRC32 algorithm, bit reverse them on the way out, and 1's compliment them.  I'm now using this technique to generate CRCs for the Bootloader Configuration Area.

元の投稿で解決策を見る

5 返答(返信)
7,236件の閲覧回数
padmanabhlanke
Contributor III
0 件の賞賛
返信
7,236件の閲覧回数
robertpoor
Senior Contributor I

Padmanabh: I looked at the link you provided about generating CRC values from SREC files, and though it uses the same Srecord tool as in the "Correct Answer" above, I believe it will NOT generate the correct CRC for KBoot 2.0 with the switches provided.  

For generating CRC for KBoot 2.0, please refer to:

https://community.nxp.com/thread/462397#comment-955757 

Thanks!

7,236件の閲覧回数
BlackNight
NXP Employee
NXP Employee

In addition to Robert's answer, and as well referencing his posts, here are some more details about that subject: Tutorial: CRC32 Checksum with the KBOOT Bootloader | MCU on Eclipse 

I hope this helps,

Erich

0 件の賞賛
返信
7,237件の閲覧回数
robertpoor
Senior Contributor I

It turns out that with the right switches and filters, you can use srec_cat to generate a valid  KBoot 2.0 CRC32 from a .srec file:

$ srec_cat test.srec -Bit_Reverse -CRC32LE 0x1000 -Bit_Reverse -XOR 0xff -crop 0x1000 0x1004 -Output -HEX_DUMP 00001000: 93 8F 97 9A                                      #....

In other words, bit reverse the bits going to the CRC32 algorithm, bit reverse them on the way out, and 1's compliment them.  I'm now using this technique to generate CRCs for the Bootloader Configuration Area.

7,236件の閲覧回数
gearhead1107
Contributor IV

Badass find, Robert! I needed this to get the "standard" polynomial for the S32 as well

0 件の賞賛
返信