Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

Checksum Problem Part B

Checksum Problem Part B

2006-01-10 by carlosahsilva

I have made some tests on the Program CheckSum generated by IAR 
compiler and there is realy something fish.

First I edited the segmentation to place the CheckSum as first byte 
after the end of my code:
--------------------------------------------------------------------- 
?CHECKSUM   CHECKSUM          __checksum       00037FFF  
Program     Relative 
module      segment 
            00037FFF - 
            00037FFF
            Segment part 1. 
            ROOT.  
--------------------------------------------------------------------

The IAR compiler informed me the value and calculation range
----------------------------------------------------------------------
Checksums

Symbol      Checksum  Memory  Start      End 
__checksum  0xcc      CODE    00000000 - 00037FFE 

-----------------------------------------------------------------------

I selected the simple checksum (not any CRC) and wrote the code below 
to test it

/*-----------------------------------------------------------------
CheckSum calculation routine
-----------------------------------------------------------------*/
void CalcCheckSum(void)
{
   unsigned char *pby;
   unsigned char *pCksGen;
   unsigned char CksGen;
   char STRCksCalc[] = "AAAAAAAAAAAAAAAAA";
   char STRCksGen[] = "AAAAAAAAAAAAAAAA";

   // Indicate start of the calculation
   UART_PutStringByPolling (UART0, "\n\rCalculation Start.\n\r"); /**/
   UART_PutStringByPolling (UART0, "\n\r\n\r");

   // Point to Address 0x00000000
   pby = (unsigned char *)0x00000000;
   // Start the Sum with zero
   unsigned char ValCheckSum = 0;	
   // Sum all bytes between 0x00000000 and 0x00037FFF.
   for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
     // Read a byte and sum it
     ValCheckSum += *pby;
     // Increment pointer
     pby++;
   }

   // Indicates the end of the calculation
   UART_PutStringByPolling (UART0, "\n\rCalculation End.\n\r"); /**/

   // Get the value of the CheckSum stored in the firmware
   pCksGen = (unsigned char *)0x00037FFF;
   CksGen = *pCksGen;

   // Transform both values in string
   sprintf (STRCksCalc, "%x", ValCheckSum);
   sprintf (STRCksGen, "%x", CksGen);
   // Send the Vavlues by the serial
   UART_PutStringByPolling (UART0, "\n\r\n\r");
   UART_PutStringByPolling(UART0, STRCksCalc);
   UART_PutStringByPolling (UART0, "\n\r\n\r");
   UART_PutStringByPolling(UART0, STRCksGen);
   UART_PutStringByPolling (UART0, "\n\r\n\r");
}

How ever when I runned the code the genarate value and calculated 
values are different:

==============================================================
Calculation Start.

Calculation End.

22 - Calculated
cc - Generated by the compiler
===============================================================

Does any one call tell me what I do wrong or provide me a sample?

Thanks

Re: [lpc2000] Checksum Problem Part B

2006-01-10 by Robert Adsett

At 08:30 PM 1/10/06 +0000, carlosahsilva wrote:
>I have made some tests on the Program CheckSum generated by IAR
>compiler and there is realy something fish.
<snip>

>    for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
>      // Read a byte and sum it
>      ValCheckSum += *pby;
>      // Increment pointer
>      pby++;
>    }

Just a thought, are you sure they are using addition for the 
checksum.  Not, say, xor?

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Re: Checksum Problem Part B

2006-01-10 by carlosahsilva

The help says it is a sum, but I found an apllication note and a 
sample of CRC checksum in the IAR suport page, I am testing it now
 
--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...> 
wrote:
>
> At 08:30 PM 1/10/06 +0000, carlosahsilva wrote:
> >I have made some tests on the Program CheckSum generated by IAR
> >compiler and there is realy something fish.
> <snip>
> 
> >    for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
> >      // Read a byte and sum it
> >      ValCheckSum += *pby;
> >      // Increment pointer
> >      pby++;
> >    }
> 
> Just a thought, are you sure they are using addition for the 
> checksum.  Not, say, xor?
> 
> Robert
> 
> " 'Freedom' has no meaning of itself.  There are always 
restrictions,   be 
> they legal, genetic, or physical.  If you don't believe me, try to 
chew a 
Show quoted textHide quoted text
> radio signal. "  -- Kelvin Throop, III
> http://www.aeolusdevelopment.com/
>

Re: Checksum Problem Part B

2006-01-11 by unity0724

I thought vectors are DWords and not Bytes?

--- In lpc2000@yahoogroups.com, "carlosahsilva" <carlosahsilva@t...> 
wrote:
>
> I have made some tests on the Program CheckSum generated by IAR 
> compiler and there is realy something fish.
> 
> First I edited the segmentation to place the CheckSum as first 
byte 
> after the end of my code:
> -------------------------------------------------------------------
-- 
> ?CHECKSUM   CHECKSUM          __checksum       00037FFF  
> Program     Relative 
> module      segment 
>             00037FFF - 
>             00037FFF
>             Segment part 1. 
>             ROOT.  
> -------------------------------------------------------------------
-
> 
> The IAR compiler informed me the value and calculation range
> -------------------------------------------------------------------
---
> Checksums
> 
> Symbol      Checksum  Memory  Start      End 
> __checksum  0xcc      CODE    00000000 - 00037FFE 
> 
> -------------------------------------------------------------------
----
> 
> I selected the simple checksum (not any CRC) and wrote the code 
below 
> to test it
> 
> /*-----------------------------------------------------------------
> CheckSum calculation routine
> -----------------------------------------------------------------*/
> void CalcCheckSum(void)
> {
>    unsigned char *pby;
>    unsigned char *pCksGen;
>    unsigned char CksGen;
>    char STRCksCalc[] = "AAAAAAAAAAAAAAAAA";
>    char STRCksGen[] = "AAAAAAAAAAAAAAAA";
> 
>    // Indicate start of the calculation
>    UART_PutStringByPolling (UART0, "\n\rCalculation 
Start.\n\r"); /**/
>    UART_PutStringByPolling (UART0, "\n\r\n\r");
> 
>    // Point to Address 0x00000000
>    pby = (unsigned char *)0x00000000;
>    // Start the Sum with zero
>    unsigned char ValCheckSum = 0;	
>    // Sum all bytes between 0x00000000 and 0x00037FFF.
>    for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
>      // Read a byte and sum it
>      ValCheckSum += *pby;
>      // Increment pointer
>      pby++;
>    }
> 
>    // Indicates the end of the calculation
>    UART_PutStringByPolling (UART0, "\n\rCalculation 
End.\n\r"); /**/
Show quoted textHide quoted text
> 
>    // Get the value of the CheckSum stored in the firmware
>    pCksGen = (unsigned char *)0x00037FFF;
>    CksGen = *pCksGen;
> 
>    // Transform both values in string
>    sprintf (STRCksCalc, "%x", ValCheckSum);
>    sprintf (STRCksGen, "%x", CksGen);
>    // Send the Vavlues by the serial
>    UART_PutStringByPolling (UART0, "\n\r\n\r");
>    UART_PutStringByPolling(UART0, STRCksCalc);
>    UART_PutStringByPolling (UART0, "\n\r\n\r");
>    UART_PutStringByPolling(UART0, STRCksGen);
>    UART_PutStringByPolling (UART0, "\n\r\n\r");
> }
> 
> How ever when I runned the code the genarate value and calculated 
> values are different:
> 
> ==============================================================
> Calculation Start.
> 
> Calculation End.
> 
> 22 - Calculated
> cc - Generated by the compiler
> ===============================================================
> 
> Does any one call tell me what I do wrong or provide me a sample?
> 
> Thanks
>

Re: Checksum Problem Part B

2006-01-11 by carlosahsilva

Solved!!! using IAR Technical Note 91733

The CRC16 check value is working!!!



--- In lpc2000@yahoogroups.com, "carlosahsilva" <carlosahsilva@t...> 
wrote:
>
> The help says it is a sum, but I found an apllication note and a 
> sample of CRC checksum in the IAR suport page, I am testing it now
>  
> --- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...> 
> wrote:
> >
> > At 08:30 PM 1/10/06 +0000, carlosahsilva wrote:
> > >I have made some tests on the Program CheckSum generated by IAR
> > >compiler and there is realy something fish.
> > <snip>
> > 
> > >    for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
> > >      // Read a byte and sum it
> > >      ValCheckSum += *pby;
> > >      // Increment pointer
> > >      pby++;
> > >    }
> > 
> > Just a thought, are you sure they are using addition for the 
> > checksum.  Not, say, xor?
> > 
> > Robert
> > 
> > " 'Freedom' has no meaning of itself.  There are always 
> restrictions,   be 
> > they legal, genetic, or physical.  If you don't believe me, try 
to 
Show quoted textHide quoted text
> chew a 
> > radio signal. "  -- Kelvin Throop, III
> > http://www.aeolusdevelopment.com/
> >
>

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.