STN Bootloader Firmware Update Specification for Devices with STN Bootloader
STN Bootloader Table of Contents 1.0 Introduction ....................................................................................................................................................3 2.0 Features ..........................................................................................................................................................3 3.0 Basic Operation ..........................................................................................................................
STN Bootloader 1.0 Introduction STN Bootloader is a resident program that is factory programmed into devices designed by OBD Solutions. Its job is to write application firmware to the device’s flash memory, allowing the device to be easily updated in the field. The updates can be used to remotely fix problems and add new functionality without the need for costly product recalls.
STN Bootloader 4.0 Communication Protocol STN bootloader employs a basic communication protocol that is robust, simple to use, and easy to implement. Flow control is built into the protocol. Thus, for every received command, there is a response (an ACK or a NACK). All multibyte values are big-endian and are transmitted most significant byte first. 4.1 UART Settings The bootloader communicates with the host via UART.
STN Bootloader CRC is calculated on the data field prior to byte stuffing. It is transmitted after the data field, and before the control character. After a response is received, it must first be unstuffed. Then the CRC is calculated over the entire data packet (including the CRC bytes). If the reception is successful, the CRC calculation result will equal zero.
STN Bootloader CRC The bootloader responds with this error when the received packet fails the CRC check. To recover from this error, resend the packet. Packet Too Long Whenever the size of the bootloader’s internal buffer is exceeded, it will stop receiving the command and wait for the character; after it receives the , the bootloader will respond with the Packet Too Long error. When properly formatted, none of the commands with fixed data length will generate this error.
STN Bootloader Connect Start bootloader session. After successfully receiving this command, the bootloader turns off the startup timer, and the device will remain in bootloader mode until it is reset (via hardware reset or a Reset command). The bootloader will not respond to any other command with either ‘ACK’ or ‘NACK’ unless it receives the Connect command. Reset Terminate bootloader session, and reset the device. Send Reset after successfully uploading the firmware, to restart the device in normal mode.
STN Bootloader Table 8 – Firmware Upload Commands Command Name Description 30 StartUpload Start firmware image upload 31 SendChunk Send the next firmware image chunk StartUpload Start firmware image upload. Every firmware image upload must be preceded by a StartUpload command. The StartUpload command packet has the following format: <0x30><0x04>[] Table 9 details the data field format of the StartUpload command.
STN Bootloader Appendix A: Firmware File Format Firmware images to be used with STN Bootloader are released as binary files with a .bin extension. The STN firmware file format is detailed in this section. The current file version is 5. If any other file version is detected, you should abort the upload, because the firmware will not be compatible with the file layout described in this document. Table 11 describes STN firmware file structure. All multi-byte values are bigendian.
STN Bootloader Appendix B: CRC Sample Code Table-based Algorithm unsigned short crcTable[256] = { 0x0000, 0x1021, 0x2042, 0x3063, 0x8108, 0x9129, 0xA14A, 0xB16B, 0x1231, 0x0210, 0x3273, 0x2252, 0x9339, 0x8318, 0xB37B, 0xA35A, 0x2462, 0x3443, 0x0420, 0x1401, 0xA56A, 0xB54B, 0x8528, 0x9509, 0x3653, 0x2672, 0x1611, 0x0630, 0xB75B, 0xA77A, 0x9719, 0x8738, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC
STN Bootloader Efficient Bytewise Algorithm unsigned short UpdateCcittCrc(unsigned short crc, unsigned char data) { unsigned short x; x = ((crc >> 8) ^ data) & 0xFF; x ^= x >> 4; crc = (crc << 8) ^ (x << 12) ^ (x << 5) ^ x; return crc; } unsigned short CalculateCcittCrc(unsigned char* data, int len) { unsigned short crc = 0; while (len-- > 0) crc = UpdateCcittCrc(crc, *data++); return crc; } Appendix C: Device IDs Table 14 lists device IDs for OBD Solutions devices currently in production.
STN Bootloader Appendix D: Revision History Revision A (January 25, 2011) Initial release of this document. Appendix E: Contact Information OBD Solutions 1819 W Rose Garden Ln Ste 3 Phoenix, AZ 85027-2723 United States Phone: Fax: Email: Web: 12 of 12 +1 623.434.5506 +1 623.321.1628 sales@obdsol.com www.obdsol.com www.obdsol.