Code:
:10000000C008EF93FF93EEEFFCE00995FF91EF91AD
:100010000895E0E6FCE00994FFFFFFFFFFFFFFFF0C
:10002000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE0
:10003000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFD0
:10004000404142434445FFFF48494A4B4C4D4E4FC7
:1000500050515253FFFF565758595A5B5C5D5E5FD3
:10006000606162636465FFFF68696A6B6C6D6E6FE7
:10007000707172737475767778797A7B7C7D7E7F08
:10008000808182838485868788898A8B8C8D8E8FF8
:10009000909192939495969798999A9B9C9D9E9FE8
:1000A000A0A1A2A3A4A5A6A7A8A9AAABACADAEAFD8
:1000B000B0B1B2B3B4B5B6B7B8B9BABBBCBDBEBFC8
:1000C000C0C1C2C3C4C5C6C7C8C9CACBCCCDCECFB8
:1000D000D0D1D2D3FFFFD6D7D8D9DADBDCDDFFFF12
:1000E000E0E1E2E3E4E5E6E7E8E9EAEBECEDEEEF98
:1000F000F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF88
WTF.
WHERE ARE THOS 0xFFFF's coming from?!
not the ones at the begining I know where they are from, I'm talking about the ones in the code stream. they show up and I can't amke them go away. here is the funny thing.. I implemented the per-word-CRC and it DIDN'T FIX THEM.
That means the problem isn't data transmission, it's data commit. except that means the bug is in a function call so small.. well.. here:
Code:
unsigned char usbFunctionWrite( unsigned char *data, unsigned char len )
{
cli();
data++;
if ( *data == USBCommandEnterApp ) // being asked to commit the code update and jump to the app
{
// now safe to install page 0 (interrupt vector table)
// overwriting our USB hack
for( len=0; len<32; len++ ) // re-using param saves stack-frame constructions opcodes
{
boot_page_fill( len*2, g_pageZero[len] );
}
commitPage( 0 );
for(;;);
asm volatile ("ijmp" ::"z" (0)); // jump to code start
}
// else it is a code page, the only other recognized command
// for the bootloader
data++;
unsigned char pos = *data++;
unsigned char check = *data++;
uint16_t w = check;
w += *data << 8;
check += *data++;
// if command checksum is good, do it
if ( !(s_replyBuffer[2] = ((check + pos) - *data)) )
{
if ( pos == BootloaderCommandCommitPage )
{
if ( w < 0x1900 ) // do not ever overwrite myself! no matter WHAT the PC tells me to do!
{
sei();
commitPage( w );
}
else
{
s_replyBuffer[2] = 2;
}
}
else if ( pos == BootloaderCommandLoadZeroPage )
{
g_pageZero[g_pageZeroIndex++] = w;
}
else // pos is an actual code position
{
boot_page_fill( pos, w );
}
}
sei();
return 1;
}
Grah?! <smashes head on keyboard>