<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY
style="WORD-WRAP: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space"
bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I think i have found the problem, if i check the
'Treat 'const' as '__flash' (backward compatibility' in the compiler options for
the bootloader in ICCAVR the check sum now works. </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Andy </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=sbeaver@columbus.rr.com href="mailto:sbeaver@columbus.rr.com">Stephen
Beaver</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=icc-avr@imagecraft.com
href="mailto:icc-avr@imagecraft.com">Discussion list for ICCAVR and ICCtiny
Users. You do NOT need tosubscribe to icc-announce if you are a member of
this.</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Thursday, June 05, 2008 9:55
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [Icc-avr] RE; AVR230: DES
Bootloader</DIV>
<DIV><BR></DIV>Perhaps it is a checksum, not a real CRC? It is a common
technique to calculate the checksum of some data, and then add whatever value
it takes to make it zero to the end of the data. That way, a simple non-zero
result indicates an error. Much the same way that parity works.
<DIV><BR></DIV>
<DIV>For example, the 8 bit checksum of "ABC" is 0x86. Adding an 0x79
character (z) to the end of our data so that we have "ABCz" produces a
checksum of 0.<BR>
<DIV><BR></DIV>
<DIV>Steve</DIV>
<DIV><BR></DIV>
<DIV><BR>
<DIV>
<DIV>On Jun 5, 2008, at 4:35 PM, Andrew wrote:</DIV><BR
class=Apple-interchange-newline>
<BLOCKQUOTE type="cite"><SPAN class=Apple-style-span
style="WORD-SPACING: 0px; FONT: 12px 'Lucida Grande'; TEXT-TRANSFORM: none; COLOR: rgb(0,0,0); TEXT-INDENT: 0px; WHITE-SPACE: normal; LETTER-SPACING: normal; BORDER-COLLAPSE: separate; orphans: 2; widows: 2; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0">
<DIV>
<DIV><FONT face=Arial>Hi,</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Has anybody used the AES bootloader from the Atmel
website? i have a port sort of working for the ICCAVR compiler but the
memory check sum fails every time (basically after thr bootloader restarts
and the does not select to bootload the bootloader does a check sum on the
entire memory.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV>
<P><FONT face=Arial color=#000080>#ifdef CRC_CHECK<BR>// Check that the
Application Section contents is undamaged<BR>// by calculating the CRC of
the whole memory.<BR>{<SPAN
class=Apple-converted-space> </SPAN><BR> unsigned int crc =
0;<BR> unsigned i;<BR><BR> const unsigned char *p = ( const
unsigned char *)0x000000;<BR> const unsigned char *n = ( const unsigned
char *)MEM_SIZE;<BR><BR> busSendText("Skip the Loader
routine\r\n");<BR><BR> do<BR> {<BR> crc = CRC(crc,
*p++);<BR> }<BR> while (--n);<BR><BR> // Application Section
damaged<BR> // do not jump to Reset Vector of the Application
Section<BR>if (crc)<SPAN
class=Apple-converted-space> </SPAN><BR> {<BR> busSendText("\r\nApplication
Section damaged\r\n");<SPAN
class=Apple-converted-space> </SPAN><BR> while(1);<BR> }<BR>}<BR>#endif</FONT></P></DIV>
<DIV><FONT face=Arial size=2><FONT size=3>To me the 'if (crc)' should be'
if(!crc)' as it cannot be a very good check sum if it passes as long as the
crc is any number but zero.</FONT><SPAN
class=Apple-converted-space> </SPAN><FONT size=3>If i force the check
sum to pass my sent code works fine / as written.</FONT></FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>Note i changed the above code from IAR which was:
-</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT size=2>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">#ifdef</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN>CRC_CHECK<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Arial, sans-serif">//
Check that the Application Section contents is
undamaged<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Arial, sans-serif">// by
calculating the CRC of the whole memory.<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">{<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><SPAN> </SPAN>unsigned</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">int</SPAN><SPAN
class=Apple-converted-space> </SPAN>crc = 0;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><SPAN> </SPAN>unsigned</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">char</SPAN><SPAN
class=Apple-converted-space> </SPAN>APPFLASH *p = (<SPAN
style="COLOR: blue">unsigned</SPAN><SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">char</SPAN><SPAN
class=Apple-converted-space> </SPAN>APPFLASH
*)0x000000;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><SPAN> </SPAN>unsigned</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">char</SPAN><SPAN
class=Apple-converted-space> </SPAN>APPFLASH *n = (<SPAN
style="COLOR: blue">unsigned</SPAN><SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">char</SPAN><SPAN
class=Apple-converted-space> </SPAN>APPFLASH
*)MEM_SIZE;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><SPAN> </SPAN>do<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">{<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">crc = CRC(crc,
*p++);<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">}<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">while</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN>(--n);<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Arial, sans-serif">//
Application Section damaged<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Arial, sans-serif">//
-> do not jump to Reset Vector of the Application
Section<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">if</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN>(crc) {<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">DDRB =
0xff;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">do</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif"><SPAN
class=Apple-converted-space> </SPAN>{<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">PORTB ^=
0xff;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">__delay_cycles(
1000000 );<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">}<SPAN
class=Apple-converted-space> </SPAN><SPAN
style="COLOR: blue">while</SPAN>(1);<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: Arial, sans-serif">//
continue;<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">}<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial, sans-serif">}<O:P></O:P></SPAN></DIV>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">#endif</SPAN></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><FONT
face=Arial></FONT></SPAN> </P>
<DIV style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif">Where
the folling are defined:-</SPAN></DIV>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><FONT
face=Arial></FONT></SPAN> </P><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: Arial, sans-serif"><FONT
size=4></FONT>
<P><FONT size=3>#if MEM_SIZE < 65536<BR><FONT color=#008000><FONT
color=#008000>//#define BOOTFLASH __flash</FONT></FONT><BR><FONT
color=#008000><FONT color=#008000>//#define APPFLASH
__flash</FONT></FONT><BR>#else<BR><FONT color=#008000><FONT color=#008000>//
#define BOOTFLASH __farflash</FONT></FONT><BR><FONT color=#008000><FONT
color=#008000>// #define APPFLASH
__hugeflash</FONT></FONT><BR>#endif</FONT><FONT size=4></FONT></P><FONT
size=4></FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2>i have commented the defines out as they don't
work with ICCAVR.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>any Ideas help / sugestion, i will finish
commenting my modified code as best i understand and post it.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Many Thanks</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Andy</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial
size=2></FONT> </DIV>_______________________________________________<BR>Icc-avr
mailing list<BR><A
href="mailto:Icc-avr@imagecraft.com">Icc-avr@imagecraft.com</A><BR><A
href="http://dragonsgate.net/mailman/listinfo/icc-avr">http://dragonsgate.net/mailman/listinfo/icc-avr</A><BR></DIV></SPAN></BLOCKQUOTE></DIV><BR></DIV></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>Icc-avr mailing
list<BR>Icc-avr@imagecraft.com<BR>http://dragonsgate.net/mailman/listinfo/icc-avr<BR></BLOCKQUOTE></BODY></HTML>