Features • Protocol – UART Used as Physical Layer – Based on the Intel Hex-type Records – Autobaud • In-System Programming – Read/Write Flash and EEPROM Memories – Read Device ID – Full-chip Erase – Read/Write Configuration Bytes – Security Setting From ISP Command – Remote Application Start Command • In-Application Programming/Self Programming – Read/Write Flash and EEPROM Memories – Read Device ID – Block Erase – Read/Write Configuration Bytes – Bootloader Start CAN Microcontrollers Description This doc
Functional Description The AT89C51CC03 Bootloader facilitates In-System Programming and In-Application Programming. In-System Programming Capability In-System Programming allows the user to program or reprogram a microcontroller on-chip Flash memory without removing it from the system and without the need of a pre-programmed application. The UART bootloader can manage a communication with a host through the serial network. It can also access and perform requested operations on the on-chip Flash Memory.
AT89C51CC03 UART Bootloader ISP Communication Management The purpose of this process is to manage the communication and its protocol between the onchip bootloader and an external device (host). The on-chip bootloader implements a Serial protocol (see Section “Protocol”). This process translates serial communication frames (UART) into Flash memory accesses (read, write, erase...).
Security The bootloader has Software Security Byte (SSB) to protect itself from user access or ISP access. The Software Security Byte (SSB) protects from ISP accesses. The command "Program Software Security Bit" can only write a higher priority level. There are three levels of security: • level 0: NO_SECURITY (FFh) This is the default level. From level 0, one can write level 1 or level 2. • level 1: WRITE_SECURITY (FEh) In this level it is impossible to write in the Flash memory, BSB and SBV.
AT89C51CC03 UART Bootloader FLIP Software Program FLIP is a PC software program running under Windows 9x / NT / 2K / XP and LINUX that supports all Atmel C51 Flash microcontrollers. This free software program is available on the Atmel web site. In-System Programming The ISP allows the user to program or reprogram a microcontroller’s on-chip Flash memory through the serial line without removing it from the system and without the need of a pre-programmed application.
Regular Boot Process bit E N B O O T in A U XR 1 R egister is initialized w ith B LJ B inverted Hardware Boot Process RESET No ENBO OT = 0 P C = 0000h Y es B LJB = 1 No Software Boot Process F C O N = 00h ENBOOT = 1 P C = F 800h F C O N = 0F h Y es No S B V < F 8h No Y es S ta rt A pp lica tio n 6 Y es H ardw are C ondition ENBOOT = 1 P C = F 800h F C O N = 00h S tart U se r B o o tlo a d e r S ta rt B o o tlo a d e r AT89C51CC03 UART Bootloader 4266C–CAN–03/08
AT89C51CC03 UART Bootloader Physical Layer Frame Description The UART used to transmit information has the following configuration: • Character: 8-bit data • Parity: none • Stop: 2 bits • Flow control: none • Baud rate: autobaud is performed by the bootloader to compute the baud rate chosen by the host. The Serial Protocol is based on the Intel Hex-type records. Intel Hex records consist of ASCII characters used to represent hexadecimal values and are summarized below. Table 1.
Protocol Overview An initialization step must be performed after each Reset. After microcontroller reset, the bootloader waits for an autobaud sequence (see Section “Autobaud Performances”). When the communication is initialized the protocol depends on the record type issued by the host. Communication Initialization The host initiates the communication by sending a ’U’ character to help the bootloader to compute the baud rate (autobaud). Figure 2.
AT89C51CC03 UART Bootloader Frequency (MHz) Baudrate (kHz) 8 10 11.0592 12 14.746 16 20 24 26.6 38400 - - OK OK OK OK OK OK OK 57600 - - OK - OK OK OK OK OK 115200 - - OK - OK - - - - Command Data Stream Protocol All commands are sent using the same flow. Each frame sent by the host is echoed by the bootloader. Figure 3.
Programming the The flow described below shows how to program data in the Flash memory or in the EEPROM Flash or EEPROM data data memory. The bootloader programs on a page of 128 bytes basis when it is possible. The host must take care that: • The data to program transmitted within a frame are in the same page. Requests from Host Command Name Record Type Load Offset Program Flash 00h Program EEPROM Data 07h Record Length Data[0] ... Data[127] start address nb of Data x ...
AT89C51CC03 UART Bootloader Read the Flash or EEPROM Data The flow described below allows the user to read data in the Flash memory or in the EEPROM data memory. A blank check command is possible with this flow. The device splits into blocks of 16 bytes the data to transfer to the Host if the number of data to display is greater than 16 data bytes.
Example Blank Check ok HOST : 05 0000 04 0000 7FFF 01 78 BOOTLOADER : 05 0000 04 0000 7FFF 01 78 .
AT89C51CC03 UART Bootloader Example Display data from address 0000h to 0020h Program Configuration Information HOST : 05 0000 04 0000 0020 00 D7 BOOTLOADER : 05 0000 04 0000 0020 00 D7 BOOTLOADER 0000=-----data------ CR LF (16 data) BOOTLOADER 0010=-----data------ CR LF (16 data) BOOTLOADER 0020=data CR LF ( 1 data) The flow described below allows the user to program Configuration Information regarding the bootloader functionality.
Flow Description Bootloader Host Write Command Send Write Command Wait Write Command OR Checksum error Wait Checksum Error ’X’ & CR & LF Send Checksum error COMMAND ABORTED NO_SECURITY OR Wait Security Error ’P’ & CR & LF Send Security error COMMAND ABORTED Wait Programming ’.’ & CR & LF Wait COMMAND_OK Send COMMAND_OK COMMAND FINISHED Example Programming Atmel function (write SSB to level 2) HOST : 02 0000 03 05 01 F5 BOOTLOADER : 02 0000 03 05 01 F5.
AT89C51CC03 UART Bootloader Read Configuration Information or Manufacturer Information The flow described below allows the user to read the configuration or manufacturer information.
Flow Description Bootloader Host Read Command Send Read Command Wait Read Command OR Checksum error ’X’ & CR & LF Wait Checksum Error Send Checksum error COMMAND ABORTED RD_WR_SECURITY OR ’L’ & CR & LF Wait Security Error Send Security error COMMAND ABORTED Read Value ’value’ & ’.’ & CR & LF Wait Value of Data Send Data Read COMMAND FINISHED Example Read function (read SBV) HOST : 02 0000 05 07 02 F0 BOOTLOADER : 02 0000 05 07 02 F0 Value .
AT89C51CC03 UART Bootloader • block2 (From 4000h to 7FFFh) • block3 (From 8000h to BFFFh) • block4 (From C000h to FFFFh) Requests from Host Record Type Command Name Load Offset Record Length Data[0] Data[1] Erase block0 (0k to 8k) 00h Erase block1 (8k to 16k) 20h Erase block2 (16k to 32k) 02h 03h 01h 40h x Erase block3 (32k to 48k) 80h Erase block4 (48k to 64k) C0h Full chip erase 01h 07h - As the Program Configuration Information flows, the erase block command has three possibl
Example Full Chip Erase HOST : 01 0000 03 07 F5 BOOTLOADER : 01 0000 03 07 F5 . CR LF Erase Block1(8k to 16k) 18 HOST : 02 0000 03 01 20 DA BOOTLOADER : 02 0000 03 01 20 DA .
AT89C51CC03 UART Bootloader Start the Application The flow described below allows to start the application directly from the bootloader upon a specific command reception. Two options are possible: • Start the application with a reset pulse generation (using watchdog). When the device receives this command the watchdog is enabled and the bootloader enters a waiting loop until the watchdog resets the device.
In-Application Programming/S elfProgramming The IAP allows to reprogram a microcontroller on-chip Flash memory without removing it from the system and while the embedded application is running. The user application can call some Application Programming Interface (API) routines allowing IAP. These API are executed by the bootloader. To call the corresponding API, the user must use a set of Flash_api routines which can be linked with the application.
AT89C51CC03 UART Bootloader API Commands Read/Program Flash and EEPROM Data Memory Several types of APIs are available: • Read/Program Flash and EEPROM Data memory • Read Configuration and Manufacturer Information • Program Configuration Information • Erase Flash • Start bootloader All routines to access EEPROM Data are managed directly from the application without using bootloader resources. To read the Flash memory the bootloader is not involved.
R1 DPTR0 DPTR1 Acc __api_rd_device_id2 00h 0002h x return id2 __api_rd_device_id3 00h 0003h x return id3 __api_rd_bootloader_version 0Fh 0000h x return value • Instruction: LCALL FFF0h. • At the complete API execution by the bootloader, the value to read is in the api_value variable.
AT89C51CC03 UART Bootloader Erase Flash The AT89C51CC03 flash memory is divided in several blocks: Block 0: from address 0000h to 1FFFh Block 1: from address 2000h to 3FFFh Block 2: from address 4000h to 7FFFh These three blocks contain 128 pages. • Parameter settings API name DPTR0 DPTR1 Acc __api_erase_block0 0000h x x __api_erase_block1 2000h x x 4000h x x __api_erase_block3 8000h x x __api_erase_block4 C000h x x __api_erase_block2 • R1 01h instruction: LCALL FFF0h.
APPENDIX-A Table 3. Summary of Frames from Host Record Type Command Record Length Offset Data[0] Data[1] Data[2] Data[3] Data[4] nb of data start address x x x x x Erase block0 (0000h-1FFFh) 00h - - - Erase block1 (2000h-3FFFh) 20h - - - 40h - - - Erase block3 (8000h-BFFFh) 80h - - - Erase block4 (C000h-FFFFh) C0h - - - 00h - - - Program Nb Data Byte in Flash.
AT89C51CC03 UART Bootloader APPENDIX-B Table 4.
Table 4. API Summary (Continued) Function Name Bootloader Execution __api_rd_eeprom_byte no __api_wr_eeprom_byte no __api_start_bootloader no R1 DPTR0 DPTR1 Acc Datasheet Revision History 4266C - 03/08 26 1. Updated Bootloader version.
Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-enYvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel Japan 9F, Tonetsu Shinkawa Bldg.