Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

CRC using IAR compiler

CRC using IAR compiler

2010-05-05 by Philippe Habib

I'm using the IAR compiler V5.11 or 5.12 and need to use the feature  
that has the linker write a CRC in the last two bytes of the executable.

I got the linker to write the CRC and I am able to read it back.  The  
problem is, I can't manage to compute the same one.  I have tried  
several different routines to generate the CRC and they agree with  
each other, but not with what IAR computes.  In each case, it is  
supposed to be a CRC 16 of the CCITT variety with 0x1021 as the  
polynomial.

Has anyone gotten this to work?  Is there some sample code somewhere  
that has been shown to work with the IAR computed CRC?

Thanks.

Re: [AVR-Chat] CRC using IAR compiler

2010-05-05 by wagnerj@proaxis.com

> I'm using the IAR compiler V5.11 or 5.12 and need to use the feature
> that has the linker write a CRC in the last two bytes of the executable.
>
> I got the linker to write the CRC and I am able to read it back.  The
> problem is, I can't manage to compute the same one.  I have tried
> several different routines to generate the CRC and they agree with
> each other, but not with what IAR computes.  In each case, it is
> supposed to be a CRC 16 of the CCITT variety with 0x1021 as the
> polynomial.
>
> Has anyone gotten this to work?  Is there some sample code somewhere
> that has been shown to work with the IAR computed CRC?
>
> Thanks.
>

Phillip -

There are a number of "standard" initial conditions for the polynomial, I
think. Each one gives a different result. I am using IAR, against my
better instincts, but its at work and I am 300 miles from there. I will be
happy to check when I return on Thursday.

Jim Wagner
Oregon Research Electronics

Re: [AVR-Chat] CRC using IAR compiler

2010-05-05 by wagnerj@proaxis.com

> I'm using the IAR compiler V5.11 or 5.12 and need to use the feature
> that has the linker write a CRC in the last two bytes of the executable.
>
> I got the linker to write the CRC and I am able to read it back.  The
> problem is, I can't manage to compute the same one.  I have tried
> several different routines to generate the CRC and they agree with
> each other, but not with what IAR computes.  In each case, it is
> supposed to be a CRC 16 of the CCITT variety with 0x1021 as the
> polynomial.
>
> Has anyone gotten this to work?  Is there some sample code somewhere
> that has been shown to work with the IAR computed CRC?
>
> Thanks.
>

PS - sorry for misspelling your name!

Jim Wagner

Re: [AVR-Chat] CRC using IAR compiler

2010-05-05 by Philippe Habib

I am using 0 as the initial value.  I tried building the CRC from 0 to  
the end of file -2 (the CRC is in the last 2 bytes) and also going the  
other direction down to 0.

Thanks for the offer to look.
Show quoted textHide quoted text
On May 4, 2010, at 9:12 PM, wagnerj@proaxis.com wrote:

>> I'm using the IAR compiler V5.11 or 5.12 and need to use the feature
>> that has the linker write a CRC in the last two bytes of the  
>> executable.
>>
>> I got the linker to write the CRC and I am able to read it back.  The
>> problem is, I can't manage to compute the same one.  I have tried
>> several different routines to generate the CRC and they agree with
>> each other, but not with what IAR computes.  In each case, it is
>> supposed to be a CRC 16 of the CCITT variety with 0x1021 as the
>> polynomial.
>>
>> Has anyone gotten this to work?  Is there some sample code somewhere
>> that has been shown to work with the IAR computed CRC?
>>
>> Thanks.
>>
>
> Phillip -
>
> There are a number of "standard" initial conditions for the  
> polynomial, I
> think. Each one gives a different result. I am using IAR, against my
> better instincts, but its at work and I am 300 miles from there. I  
> will be
> happy to check when I return on Thursday.
>
> Jim Wagner
> Oregon Research Electronics
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

Re: [AVR-Chat] CRC using IAR compiler

2010-05-06 by Bob Paddock

On Wed, May 5, 2010 at 12:53 AM, Philippe Habib <phabib@well.com> wrote:

>
>
> I am using 0 as the initial value.
>

That will miss inserted leading zeros.  Using 0xFFFF will not have that
problem.

Also if you store the ones compliment of the CRC, low byte first, at the end
of your data, when you CRC that as part of your data you will end up with a
"Magic Number", that will always be the same if the CRC is good.  0xF0B8 is
common for 0x1021 polynomial.  It could also be 0x1D0F in reverse bit order.
 Take a look at the CRC section in http://www.boost.org for a good write up
on CRCs.


[Non-text portions of this message have been removed]

Re: [AVR-Chat] CRC using IAR compiler

2010-05-10 by Philippe Habib

Jim,

Did you happen to get a chance to look at this?  I got pulled off to  
something else for a few days but I'll be getting back to it soon.

Thanks.
Show quoted textHide quoted text
On May 4, 2010, at 9:12 PM, wagnerj@proaxis.com wrote:

>> I'm using the IAR compiler V5.11 or 5.12 and need to use the feature
>> that has the linker write a CRC in the last two bytes of the  
>> executable.
>>
>> I got the linker to write the CRC and I am able to read it back.  The
>> problem is, I can't manage to compute the same one.  I have tried
>> several different routines to generate the CRC and they agree with
>> each other, but not with what IAR computes.  In each case, it is
>> supposed to be a CRC 16 of the CCITT variety with 0x1021 as the
>> polynomial.
>>
>> Has anyone gotten this to work?  Is there some sample code somewhere
>> that has been shown to work with the IAR computed CRC?
>>
>> Thanks.
>>
>
> Phillip -
>
> There are a number of "standard" initial conditions for the  
> polynomial, I
> think. Each one gives a different result. I am using IAR, against my
> better instincts, but its at work and I am 300 miles from there. I  
> will be
> happy to check when I return on Thursday.
>
> Jim Wagner
> Oregon Research Electronics
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

Re: [AVR-Chat] CRC using IAR compiler

2010-05-10 by Jim Wagner

Sorry, forgot all about it. I'll check in the morning at work.

Jim
On May 9, 2010, at 9:58 PM, Philippe Habib wrote:

> Jim,
>
> Did you happen to get a chance to look at this? I got pulled off to
> something else for a few days but I'll be getting back to it soon.
>
> Thanks.
>
> On May 4, 2010, at 9:12 PM, wagnerj@proaxis.com wrote:
>
> >> I'm using the IAR compiler V5.11 or 5.12 and need to use the  
> feature
> >> that has the linker write a CRC in the last two bytes of the
> >> executable.
> >>
> >> I got the linker to write the CRC and I am able to read it back.  
> The
> >> problem is, I can't manage to compute the same one. I have tried
> >> several different routines to generate the CRC and they agree with
> >> each other, but not with what IAR computes. In each case, it is
> >> supposed to be a CRC 16 of the CCITT variety with 0x1021 as the
> >> polynomial.
> >>
> >> Has anyone gotten this to work? Is there some sample code somewhere
> >> that has been shown to work with the IAR computed CRC?
> >>
> >> Thanks.
> >>
> >
> > Phillip -
> >
> > There are a number of "standard" initial conditions for the
> > polynomial, I
> > think. Each one gives a different result. I am using IAR, against my
> > better instincts, but its at work and I am 300 miles from there. I
> > will be
> > happy to check when I return on Thursday.
> >
> > Jim Wagner
> > Oregon Research Electronics
> >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
>
>
> 



[Non-text portions of this message have been removed]

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.