at89c5131a ATMEL Corporation, at89c5131a Datasheet



Manufacturer Part Number
Usb Microcontrollers
ATMEL Corporation

Available stocks

Part Number
Bonase Electronics (HK) Co., Limited Bonase Electronics (HK) Co., Limited
Part Number:
12 500
Bonase Electronics (HK) Co., Limited Bonase Electronics (HK) Co., Limited
Part Number:
1 200
This document describes the USB bootloader functionalities as well as the USB proto-
col to efficiently perform operations on the on-chip Flash (EEPROM) memories.
Additional information on the AT89C5131A product can be found in the AT89C5131A
datasheet and the AT89C5131A errata sheet available on the Atmel web site.
The bootloader software package (binary) currently used for production is available
from the Atmel web site.
Bootloader Revision
Revisions 1.0.2 (and above)
In-System Programming
In-Application Programming/Self Programming (IAP)
– USB Used as Physical Layer
– Device Firmware Upgrade Class Compliant
– USB Clock Auto-Configuration
– 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
– Read/Write Flash and EEPROM Memories
– Read Device ID
– Block Erase
– Read/Write Configuration Bytes
– Bootloader Start
Purpose of Modifications
First release
USB Bootloader

Related parts for at89c5131a

at89c5131a Summary of contents

Page 1

... This document describes the USB bootloader functionalities as well as the USB proto- col to efficiently perform operations on the on-chip Flash (EEPROM) memories. Additional information on the AT89C5131A product can be found in the AT89C5131A datasheet and the AT89C5131A errata sheet available on the Atmel web site. The bootloader software package (binary) currently used for production is available from the Atmel web site ...

Page 2

... Programming Capability (ISP) Block Diagram AT89C5131A USB Bootloader 2 The AT89C5131A bootloader facilitates In-System Programming and In-Application Programming. 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. ...

Page 3

... Configuration and Manufacturer Information 4287C–USB–11/04 AT89C5131A USB Bootloader The purpose of this process is to manage the communication and its protocol between the on-chip bootloader and an external device (host). The on-chip bootloader imple- ments a USB protocol (see section “Protocol”). This process translates serial communication frames (USB) into Flash memory accesses (read, write, erase ...

Page 4

... Mapping and Default Value of Hardware Security Byte Security AT89C5131A USB Bootloader 4 The 4 MSB of the Hardware Byte can be read/written by software (this area is called Fuse bits). The 4 LSB can only be read by software and written by hardware in parallel mode (with parallel programmer devices). Bit Position ...

Page 5

... There is a priority between P1_CF, P3_CF and P4_CF (see Figure 3 on page 8). Note: The BLJB must (programmed able to restart the bootloader. If the BLJB is equal to 1 (unprogrammed) only the hardware parallel programmer can change this bit (see AT89C5131A datasheet for more details). 5 ...

Page 6

... Software Boot Vector FLIP Software Program AT89C5131A USB Bootloader 6 The default value [FF]00h is used in ISP mode. The boot address is, in this mode, the lowest adress of FM1 USB bootloader. The Software Boot Vector (SBV) can be used to force the execution of a user bootloader starting at address [SBV]00h in the application area (FM0). The way to start this user bootloader is described in section “ ...

Page 7

... Figure 2. High-pin Count Regular Boot Process lica tio n 4287C–USB–11/04 AT89C5131A USB Bootloader ardw are C ondition 0000h 00h < 7Fh tlo ...

Page 8

... Figure 3. Low-pin Count Regular Boot Process Yes Start Application AT89C5131A USB Bootloader 8 RESET ENBOOT = 0 Yes PC = 0000h BLJB = 1 No P1_CF = FFh No P1_CF = P1 Yes No P3_CF = P3 BSB = SBV < 7Fh Yes Start User Bootloader Bit ENBOOT in AUXR1 Register is Initialized with BLJB Inverted ENBOOT = F400h ...

Page 9

... MHz Frequency Auto- Configuration 4287C–USB–11/04 AT89C5131A USB Bootloader The USB norm specifies all the transfers over the USB line. The USB specification also includes several CLASS and SUB-CLASS specifications. These stand-alone documents are used by the manufacturer to implement a USB link between a PC and a device sup- porting the In System Programming ...

Page 10

... AT89C5131A USB Bootloader 10 Figure 5. 48 MHz Frequency Auto-Configuration No Resume Detected? Yes USB Scheduler MAIN No USB Connected? Suspend/Resume Yes Configure PLL for Frequency X Configure Timer 0 Yes SOF Detected Timer 0 Overflow? Yes Change Frequency 4287C–USB–11/04 ...

Page 11

... Table 2. USB Parameters Parameter Vendor ID Product ID Release Number wIndex wLength Interface (4) Zero Interface (4) Length Interface (4) Length Interface (4) 6 Interface (4) Zero Interface (4) 1 Interface (4) Zero Atmel – AT89C5131A Bootloader 0x03EB 0x2FFD 0x0000 Data none Firmware Firmware Status none State none 11 ...

Page 12

... Details concern- ing other possible uses of alternate settings are beyond the scope of this document. However, their use is intentionally not restricted because the authors anticipate that implementers will devise additional creative uses for alternate settings. AT89C5131A USB Bootloader 12 Size ...

Page 13

... Offset Field 0 bLength 1 bDescriptorType 2 bmAttributes 3 wDetachTimeOut 5 wTransferSize Command Description 4287C–USB–11/04 AT89C5131A USB Bootloader Size Value 1 07h Size of this descriptor, in bytes 1 21h DFU FUNCTIONAL descriptor type DFU Attributes: bit 7..3: reserved bit 2: device is able to communicate via USB after Manifestation 1 Bit mask ...

Page 14

... AT89C5131A USB Bootloader 14 The Host employs the DFU_GETSTATUS request to facilitate synchronization with the device. This status gives information on the execution of the previous request: in progress/OK/Fail/... wValue Zero Zero The device responds to the DFU_GETSTATUS request with a payload packet contain- ing the following data: Table 6 ...

Page 15

... Clear Status 4287C–USB–11/04 AT89C5131A USB Bootloader Description iString indicates a vendor-specific error Device detected unexpected USB reset signaling Device detected unexpected power on reset Something went wrong, but the device does not know what it was Device stalled an unexpected request Table 8 ...

Page 16

... Device State DFU_ABORT request Programming the Flash or EEPROM Data AT89C5131A USB Bootloader 16 This request solicits a report about the state of the device. The state reported is the cur- rent state of the device with no change in state upon transmission of the response. The values specified in the bState field are identical to those reported in DFU_GETSTATUS. ...

Page 17

... Request From Host Write Command Firmware DFU Suffix 4287C–USB–11/04 AT89C5131A USB Bootloader Offset Field Size -12 idProduct 2 -14 bcdDevice 2 bmRequestType bRequest 0010 0001b DFU_DNLOAD (1) Command Identifier data[0] data[1] 00h Id_prog_start start_address 01h 01h The write command is 6 bytes long. In order to reach the USB specification of the Con- trol type transfers, the write command is completed with non-significant bytes ...

Page 18

... Figure 6. Example of Firmware Download Zero Length DFU_DNLOAD Request SETUP OUT OUT OUT OUT IN Answers from Bootloader AT89C5131A USB Bootloader 18 DFU_DNLOAD Prog_Start + (EP0 fifo length - 6) x 00h X offset bytes + Firmware Packet 1 Firmware Packet 2 Firmware Packet n + DFU suffix ZLP The Host sends a DFU_DNLOAD request with the wLength field cleared the device to indicate that it has completed transferring the firmware image file ...

Page 19

... OUT 4287C–USB–11/04 AT89C5131A USB Bootloader The flow described below allows the user to read data in the Flash memory or in the EEPROM data memory. A blank check command on the Flash memory is possible with this flow. This operation is performed in 2 steps: 1. DFU_DNLOAD request with the read command (6 bytes) 2 ...

Page 20

... Blank Check Command Programming Configuration Information Request from Host Answers From Bootloader AT89C5131A USB Bootloader 20 The Host controller send a GET_STATUS request to the device. Once internal blank check has been completed, the device sends its status. • If the device status is “OK”: the device memory is then blank and the device waits the next Host request. • ...

Page 21

... Information or Manufacturer Information Requests From Host 4287C–USB–11/04 AT89C5131A USB Bootloader The flow described below allows the user to read the configuration or manufacturer information. To start the programming operation, the Host sends DFU_DNLOAD request with the Read command in the data field (2 bytes). ...

Page 22

... BSB = FFh • SBV = FFh • SSB = FFh (NO_SECURITY) The Block erase command erases only a part of the Flash. Three Blocks are defined in the AT89C5131A: • block0 (From 0000h to 1FFFh) • block1 (From 2000h to 3FFFh) • block2 (From 4000h to 7FFFh) To start the erasing operation, the Host sends a DFU_DNLOAD request with a Write Command in the data field (2 bytes) ...

Page 23

... Answers from Bootloader Starting the Application Request From Host Answer from Bootloader 4287C–USB–11/04 AT89C5131A USB Bootloader The device has two possible answers to a DFU_GETSTATUS request: • If the chip is protected from program access, a “err_WRITE” status is returned to the Host. • ...

Page 24

... Interrupts must also be disabled before accessing EEPROM data then re-enabled after. The user must take care of hardware watchdog before launching a Flash operation. For more information regarding the Flash writing time see the AT89C5131A datasheet. ® Compilers 4287C–USB–11/04 ...

Page 25

... 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. For more details on these routines see the AT89C5131A datasheet sections “Pro- gram/Code Memory” and “EEPROM Data Memory” Two routines are available to program the Flash: – ...

Page 26

... Read Configuration and Manufacturer Information AT89C5131A USB Bootloader 26 • Parameter settings API Name api_command __api_rd_HSB __api_rd_BSB __api_rd_SBV __api_rd_P1_CF __api_rd_P3_CF __api_rd_P4_CF __api_rd_SSB __api_rd_EB __api_rd_manufacturer __api_rd_device_id1 __api_rd_device_id2 __api_rd_device_id3 __api_rd_bootloader_version • Instruction: LCALL FFC0h. • At the complete API execution by the bootloader, the value to read is in the api_value variable ...

Page 27

... LCALL FFC0h. Notes: 1. See the AT89C5131A datasheet for the time that a write operation takes and this time must multiply by the number of pages special resources are used by the bootloader during these operations. api_dph api_dpl 07h 07h ...

Page 28

... Starting the Bootloader AT89C5131A USB Bootloader 28 This routine allows to start at the beginning of the bootloader as after a reset. After call- ing this routine the regular boot process is performed and the communication must be opened before any action. • No special parameter setting • Set bit ENBOOT in AUXR1 register • ...

Page 29

... Command Identifier data[0] 00h Id_prog_start 01h 01h 00h Id_display_data 01h 03h 02h 00h Id_write_command 04h 01h 02h 03h 4287C–USB–11/04 AT89C5131A USB Bootloader data[1] data[2] data[3] start_address end_address start_address end_address 00h 20h 40h FFh 00h 01h 02h 03h Value 04h ...

Page 30

... Table 10. Summary of Frames from Host (Continued) Command Identifier data[0] 00h Id_read_command 05h 01h 02h AT89C5131A USB Bootloader 30 data[1] data[2] data[3] 00h 01h 02h 00h 01h 02h 03h 04h 05h 06h 30h 31h 60h 61h 00h Table 11. DFU Class-specific Requests bmRequestType bRequest ...

Page 31

... AT89C5131A USB Bootloader Bootloader Execution api_command no yes 0Dh yes 0Dh yes 00h yes 00h yes 00h yes 08h yes 07h ...

Page 32

... Table 14. API Summary (Continued) Function Name __api_rd_device_id2 __api_rd_device_id3 __api_rd_bootloader_version __api_eeprom_busy __api_rd_eeprom_byte __api_wr_eeprom_byte __api_start_bootloader __api_start_isp AT89C5131A USB Bootloader 32 Bootloader Execution api_command yes 05h yes 05h yes 0Eh api_dph api_dpl api_value 60h return value 61h return value 00h return value 4287C–USB–11/04 ...

Page 33

... Fax: (81) 3-3523-7581 Disclaimer: Atmel Corporation makes no warranty for the use of its products, other than those expressly contained in the Company’s standard warranty which is detailed in Atmel’s Terms and Conditions located on the Company’s web site. The Company assumes no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed herein at any time without notice, and does not make any commitment to update the information contained herein ...

Related keywords