Initialize BootLoader

  • Reset ( further Infos here: en/SerialProtocol )

     SendOutData('R', 0, NULL, 0);   
    Enter Bootloader
     SEND_CHAR(27);      // ESC
     Delay(20);          
     SEND_CHAR(0xAA);
     Delay(80);           
    Bootloader will send "MKBL" on success Get AVR-Signature:
     SEND_CHAR('t');   // get signature
     Answer:
     RxBuffer[0] = 0x74 ; RxBuffer[1] = 0x00 = MEGA644
     RxBuffer[0] = 0x76 ; RxBuffer[1] = 0x00 = MEGA8
     RxBuffer[0] = 0x78 ; RxBuffer[1] = 0x00 = MEGA168
     RxBuffer[0] = 0x7A ; RxBuffer[1] = 0x00 = MEGA1284
     RxBuffer[0] = 0xE0 ; RxBuffer[1] = 0x00 = STR91x 
    set Device:
     SEND_CHAR('T'); 
     END_CHAR(devicetyp);   // set devicetyp = 0x74 or 0x76 or 0x78 or 0xE0
    
     Answer:  RxBuffer[0] = 0x0D      // OKAY 

    Get Version (BootBlock)

     SEND_CHAR('V');
    
     Answer:
     RxBuffer[0] = Major;
     RxBuffer[1] = Minor; 
    Get Buffer Size:
     SEND_CHAR('b'); 
    
     Answer:
     RxBuffer[0] = 'Y'
     (unsigned int) SendBufferSize = RxBuffer[1]* 0x100 + RxBuffer[2];    

Flash Firmware

  • Set size of Flash to clear ( only navi ):
     cmd[0] = 'X';
     cmd[1] = (Size >> 16) & 0xFF;
     cmd[2] = (Size >> 8) & 0xFF;
     cmd[3] = Size & 0xFF;
     SEND_BYTES(cmd, 4);
     
    
     Answer:
     RxBuffer[0] = 0x0D      // OKAY 
    clear Flash:
     SEND_CHAR('e');
    
     Answer:
     RxBuffer[0] = 0x0D      // OKAY 
    Set Adress:
     cmd[0] = 'A';
     cmd[1] = 0x00;
     cmd[2] = 0x00;
     SEND_BYTES(cmd, 3);
    
     Answer
     RxBuffer[0] = 0x0D      // OKAY  
    write Block:

    get data from Hex according http://www.schulz-koengen.de/biblio/intelhex.htm

     cmd[0] = 'B';
     cmd[1] = (SendBufferSize >> 8) & 0xFF;
     cmd[2] = SendBufferSize & 0xFF;
     cmd[3] = 'F';
     SEND_BYTES(cmd, 4);
     SEND_BYTES(data, SendBufferSize);
    
     Antwort:
     RxBuffer[0] = 0x0D      // OKAY 

    /!\ set buffersize correctly at last block /!\ when flashing the Navi-Ctrl you have to add CRC16 to every block - don't increase cmd[1]/cmd[2] with the 2 bytes of the crc


    Optional: Read Block to verify written Data (FC only): - set Addr to 0x00 ( see above )

     cmd[0] = 'g';
     cmd[1] = (SendBufferSize >> 8) & 0xFF;
     cmd[2] = SendBufferSize & 0xFF;
     cmd[3] = 'F';
     SEND_BYTES(cmd, 4);
            
      Answer:
      1 Block data - sizze according cmd[1] and cmd[2] 

Reset Settings

  • /!\ only for FC

     cmd[0] = 'B';
     cmd[1] = 0;
     cmd[2] = 4;
     cmd[3] = 'E';
     SEND_BYTES(cmd, 4);
    
     cmd[0] = 0xFF;
     cmd[1] = 0xFF;
     cmd[2] = 0xFF;
     cmd[3] = 0xFF';
     SEND_BYTES(cmd, 4); 

Exit Bootloader

  •  SEND_CHAR('E'); 


CategoryCoding