<!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>
<DIV><FONT face=Arial>Hi,</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</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>&nbsp;</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>{ <BR>&nbsp;unsigned int crc = 0;<BR>&nbsp;unsigned 
i;<BR><BR>&nbsp;const unsigned char *p = ( const unsigned char 
*)0x000000;<BR>&nbsp;const unsigned char *n = ( const unsigned char 
*)MEM_SIZE;<BR><BR>&nbsp;busSendText("Skip the Loader 
routine\r\n");<BR><BR>&nbsp;do<BR>&nbsp; {<BR>&nbsp; crc = CRC(crc, 
*p++);<BR>&nbsp; }<BR>&nbsp;while (--n);<BR><BR>&nbsp;// Application Section 
damaged<BR>&nbsp;// do not jump to Reset Vector of the Application Section<BR>if 
(crc) <BR>&nbsp;{<BR>&nbsp;busSendText("\r\nApplication Section damaged\r\n"); 
<BR>&nbsp;while(1);<BR>&nbsp;}<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> <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>&nbsp;</DIV>
<DIV><FONT face=Arial>Note i changed the above code from IAR which was: 
-</FONT></DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial></FONT>&nbsp;</DIV>
<DIV><FONT size=2>
<P 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'"> 
CRC_CHECK<?xml:namespace prefix = o ns = 
"urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P 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></P>
<P 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></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>unsigned</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> <SPAN 
style="COLOR: blue">int</SPAN> crc = 0;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>unsigned</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> <SPAN 
style="COLOR: blue">char</SPAN> APPFLASH *p = (<SPAN 
style="COLOR: blue">unsigned</SPAN> <SPAN style="COLOR: blue">char</SPAN> 
APPFLASH *)0x000000;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>unsigned</SPAN><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'"> <SPAN 
style="COLOR: blue">char</SPAN> APPFLASH *n = (<SPAN 
style="COLOR: blue">unsigned</SPAN> <SPAN style="COLOR: blue">char</SPAN> 
APPFLASH *)MEM_SIZE;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><SPAN 
style="mso-spacerun: yes">&nbsp;</SPAN>do<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">crc = CRC(crc, 
*p++);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">}<o:p></o:p></SPAN></P>
<P 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'"> 
(--n);<o:p></o:p></SPAN></P>
<P 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></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Arial','sans-serif'">// 
-&gt; do not jump to Reset Vector of the Application 
Section<o:p></o:p></SPAN></P>
<P 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'"> (crc) 
{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">DDRB = 
0xff;<o:p></o:p></SPAN></P>
<P 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'"> 
{<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">PORTB ^= 
0xff;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">__delay_cycles( 
1000000 );<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">} <SPAN 
style="COLOR: blue">while</SPAN>(1);<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: green; FONT-FAMILY: 'Arial','sans-serif'">// 
continue;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'">}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'">#endif</SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><FONT 
face=Arial></FONT></SPAN>&nbsp;</P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'">Where 
the folling are defined:-</SPAN></P>
<P style="MARGIN: 0cm 0cm 0pt"><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><FONT 
face=Arial></FONT></SPAN>&nbsp;</P><SPAN 
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Arial','sans-serif'"><FONT 
size=4>
<P></FONT><FONT size=3>#if MEM_SIZE &lt; 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></P></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>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Many Thanks </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Andy </FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV></BODY></HTML>