In System Programming T89C51RD2 Bootloader

background image

Rev. A - 12-Jan-01

1

ANM095

In-System Programming - T89C51RD2 Bootloader Operating
Modes

1. Introduction

1.1. Overview

This application note describes the use of the embedded T89C51RD2 bootloader for in-system programming (ISP)
in different application environments.

The utility software to implement in-system programming with a PC or a SUN is available on the Atmel Wireless
and Microcontrollers Web Site.

1.2. Definition of Terms

API: Application Programming Interface

BLJB: Boot Loader Jump Bit

BLLB: Boot Loader Lock Bit

BSB: Boot Status Byte

SBV: Software Boot vector

HSB: Hardware Security Byte

ISP: In-system Programming

background image

2

Rev. A - 12-Jan-01

ANM095

2. Flash Memory Description

2.1. Overview

The T89C51RD2 Flash memory is a 64-Kbyte program memory organized in 512 pages of 128 bytes. This memory
is both parallel and serial in-system programmable.

Parallel programming of the Flash is carried out using a programmer device, whereas serial programming is
performed using an embedded bootloader program.

The memory is organized in two main areas:

User Flash memory:
63 Kbytes for user program, organized in page of 128 bytes,

Boot Flash memory:
1 Kbytes for Bootloader program and application program interface (API).

2.2. Flash Memory Architecture

The Flash memory is composed of two arrays. See Figure 1

Figure 1. Flash Memory Architecture

1. User Program Array

The size of this block is 63 Kbytes organized in 504 pages of 128 bytes.

2. XROW Array

The XROW is one extra page (128 bytes). This space contains data needed by the bootloader:

BSB: The boot status byte defines the programming status of the device. If the part is not programmed, the
value is FFh, else value is 00h. This status can be modified in ISP or in parallel programming mode. In
serial programming mode, this modification is either done automatically by ISP application program or with
the corresponding command.

SBV: The software boot vector byte is equal to the most significant byte of the first opcode address of the
bootloader firmware. The factory setting is FCh. This value can be modified in ISP or in parallel programming
mode to point to a customer Bootloader.

16/32 Kbytes

Flash memory

0000h

XROW

(customer program

array)

63 KBytes

Flash Memory

(User Program Array)

FFFFh

FC00h

(Bootloader program)

1 Kbyte

background image

Rev. A - 12-Jan-01

3

ANM095

2.3. Hardware Bit BLJB

The Boot Loader Jump Bit (BLJB) is a bit of the hardware byte. Its value can be modified in parallel programming
mode only. The values and uses are:

-

0: After reset, the bootlader is executed at FC03h. This mode is the most versatile and gets full benefits
of the Flash thanks to the Flash Bootloader.

-

1: After reset, the application program is executed at 0000h. The application program is loaded in parallel
mode. This mode is used when the customer application program is stable. Parallel mode is re-used to
change the program loaded in Flash.

2.4. Bootloader Flash Program

The default bootloader Flash is located in address space from FC00h to FFFFh. As it is in a Flash memory, its
value can be changed.

The boot loader lock bit (BLLB) is an hardware bit which locks the content of the bootloader Flash program. This
prevents any programming access to the upper 1-KByte in parallel mode only.

If erased, the Flash bootloader can be restored by parallel programming. The default Atmel bootloader program is
available on our website.

The Bootloader Flash program can be executed in two ways:

Hardware conditions EA=1, PSEN=0, ALE=1 or no connected. In this case the PC is forced to value FC00h.
This permits a boot from the default bootloader in all configurations and thus a return to the original device
configuration.

Hardware and software method. The boot loader jump bit (BLJB) is an another bit of the hardware byte.
Its value can be modified in parallel programming mode only. The values and uses are:

-

0: After reset, the bootlader is executed at address FC03h. This mode is the most versatile and gets full
benefits of the Flash thanks to the Flash Bootloader. Depending on the status of the device, the process
will be different. The boot modes are detailed in paragraph 4.

-

1: After reset, the application program is executed at address 0000h. The application program has been
loaded in parallel mode. This mode is used when the customer application program is stable. He will
need to reuse the parallel mode to change this configuration.

background image

4

Rev. A - 12-Jan-01

ANM095

3. Bootloader Overview

The Flash bootloader includes:

a bootloader program that controls

the serial communication protocol

the ISP command decoder

the API routines. These are the low-level functions (program byte, read byte, etc.) called from the bootloader
to perform Flash access operations.

In order to access specific functions, the user may want to load a custom bootloader. This may be necessary in case of :

another communication interface

different protocol (other data format, crypted datas, etc.)

Flash areas protection

Flash areas checks (CRC, etc.)

f a custom bootloader program is required, it is located in Flash memory at the address [SBV]00h. It calls the API
routines contained in Flash boot loader memory.

The customer bootloader can be programmed in Flash memory by two means:

Parallel mode: The procedure is explained in detail in the installation file which can be downloaded from
Atmel Wireless and Microcontrollers web site. The MSB of the bootloader start address must be programmed
in SBV. The new bootloader can be loaded in place of the default bootloader at address FC00h.

Example: If the customer bootloader begins at address 3B00h (the low nibble must be 00), SBV must be
programmed with 3Bh.

Serial mode: The procedure is explained in detail in the following sections of this document.

To restore the branch to default Atmel bootloader, three methods can be used:

-

with the default bootloader activated with hardware conditions on EA, PSEN and ALE

-

with a customer bootloader that provides features for erasing and reprogramming of SBV and BSB

-

through the parallel programming method.

The customer bootloader program simply calls the API at the common entry point in Flash bootloader with
appropriate parameters to accomplish the desired operation.

FFFFh

[SBV]00h

Bootloader entry point :

Optional:

Customer Bootloader

0000h

Flash Memory

API

FC00h

Default Bootloader

background image

Rev. A - 12-Jan-01

5

ANM095

4. Boot modes

q

Load the initial application program (See page 7)

At reset, download the application program in Flash memory user array.

q

Execute the application program (See page 8)

Run the application program in Flash from address 0000h.

q

Update the application program (See page 9)

After reset, download in Flash a new application program in place of the previous one.

q

Load a customer bootloader in a blank device (See page 10)

q

or in an already programmed device (See page 11)

Load a customer Bootloader.

q

Load the initial application program with a customer Bootloader (See page 12)

Load and update operations are handled by the customer Bootloader.

q

Update the application program with a customer Bootloader (See page 13)

After reset, download in Flash a new application program in place of the previous one.

The following figures show the different valid flows in accordance with each scenario of the overall algorithm.
This flowchart extracted from the Datasheet is summarized in appendix page14.

What is expected from the Bootloader ?

background image

6

Rev. A - 12-Jan-01

ANM095

4.1. Load the Initial Application Program

a. Initial Device Configuration

b. Final device configuration

Note1: The BSB must be reset when the Flash has been programmed in order to change the device status (included in the "program part"
function of ISP software program)

BLJB

BSB

SBV

Flash

0b

FFh

FCh

Bootloader at FC00h

Blank

BLJB

BSB

SBV

Flash

0b

00h

(Note1)

FCh

Bootloader at FC00h

Programmed with Application program

UART

Application Board

Rx

Tx

PC serial port

T89C51
RD2

ISP Software program

RESET

H

a

rd

w

a

re

ATMEL BOOT LOADER

Hardware
Condition?

No

No

FC03h address

BSB = 00h?

SBV = FCh?

No

Yes

S

o

ft

w

a

re

BLJB =1b?

FC00h

background image

Rev. A - 12-Jan-01

7

ANM095

4.2. Execute the Application Program

a. Initial Device Configuration

b. Final Device Configuration

No change

BLJB

BSB

SBV

Flash

0b

00h

status of programmed part

FCh

Bootloader at FC00h

Flash is already programmed

Application Board

Rx

Tx

T89C51
RD2

RESET

H

a

rd

w

a

re

Hardware
Condition?

BLJB =1b?

No

No

FC03h address

BSB = 00h?

S

o

ft

w

a

re

Yes

0000h

APPLICATION PROGRAM

background image

8

Rev. A - 12-Jan-01

ANM095

4.3. Update the Application Program

a. Initial Device Configuration

b. Final Device Configuration

BLJB

BSB

SBV

Flash

0b

00h

status of programmed part

FCh

Bootloader at FC00h

Flash is already programmed

BLJB

BSB

SBV

Flash

0b

00h

status of programmed part

FCh

Bootloader at FC00h

Flash is programmed with the new

application program ready to be executed

Application Board

Rx

Tx

Hardware
Conditions

PC serial port
ISP software program

T89C51
RD2

PSEN=0

EA=1

ALE=1

RESET

H

a

rd

w

a

re

ATMEL BOOT LOADER

Hardware
Condition?

S

o

ft

w

a

re

Yes

FC00h

background image

Rev. A - 12-Jan-01

9

ANM095

4.4.

Load a Customer Bootloader in a Blank Device

a. Initial Device Configuration

b. Final device configuration

Note(2): As it has been reset by ISP program automatically after program part execution, it must be rewritten to its original value to execute
the customer bootloader.

BLJB

BSB

SBV

Flash

0b

FFh

status of unprogrammed part

FCh

Bootloader at FC00h

Flash is blank

BLJB

BSB

SBV

Flash

0b

FFh

Note(2)

XXh

Customer Bootloader at XX00h

Flash has been programmed with the

customer Bootloader

UART

Application Board

Rx

Tx

PC serial port
ISP software program

T89C51
RD2

RESET

H

a

rd

w

a

re

ATMEL BOOT LOADER

Hardware
Condition?

BLJB =1b?

No

No

FC03h address

BSB = 00h?

SBV = FCh?

No

Yes

S

o

ft

w

a

re

background image

10

Rev. A - 12-Jan-01

ANM095

4.5. Load a Customer Bootloader in an Already Programmed Part

a. Initial Device Configuration

b. Final Device Configuration

Note(3): As it has been reset by ISP program automatically after program part execution, it must be written to FFh value to execute the
customer bootloader.

BLJB

BSB

SBV

Flash

0b

00h

programmed part status

FCh

Bootloader at FC00h

Flash is already programmed with an

application program

BLJB

BSB

SBV

Flash

0b

FFh

Note(3)

XXh

Customer Bootloader at XX00h

An area of the Flash has been programmed

with the customer Bootloader

Application Board

Rx

Tx

Hardware
Conditions

PC serial port
ISP software program

T89C51
RD2

PSEN=0

EA=1

ALE=1

RESET

H

a

rd

w

a

re

ATMEL BOOT LOADER

Hardware
Condition?

S

o

ft

w

a

re

Yes

FC00h address

background image

Rev. A - 12-Jan-01

11

ANM095

4.6. Load the Initial Application Program with a Customer Bootloader

a. Initial Device Configuration

b. Final Device Configuration

Note(4): The BSB must be reset when the Flash has been programmed in order to change the device status (included in the "program
part" function of ISP software program)
Note(5): The customer must load the application program in the available Flash space beside the customer Bootloader.

BLJB

BSB

SBV

Flash

0b

FFh

XXh

customer Bootloader at XX00h

Flash space except Bootloader is blank

BLJB

BSB

SBV

Flash

0b

00h

programmed part status Note(4)

XXh

Customer Bootloader at XX00h

Flash space except Bootloader is

programmed with program (Note 5)

Application Board

T89C51
RD2

Customer ISP software program

UART or another
communication
medium

RESET

H

a

rd

w

a

re

Hardware
Condition?

BLJB =1b ?

No

No

FC03h address

BSB = 00h?

SBV = FCh?

No

S

o

ft

w

a

re

No

CUSTOMER BOOTLOADER

background image

12

Rev. A - 12-Jan-01

ANM095

4.7. Update the Application Program with a Customer Bootloader

a. Initial Device Configuration

b. Final Device Configuration

BLJB

BSB

SBV

Flash

0b

00h

status of programmed part

XXh

Customer Bootloader at XX00h

Flash is already programmed

BLJB

BSB

SBV

Flash

0b

FFh

status of unprogrammed part

XXh

Customer Bootloader at XX00h

Flash program is not changed.

A Reset will execute the sequence

described paragraph 4.6 page 12.

Application Board

T89C51
RD2

Customer ISP software program

RS232 or another
communication
medium

RESET

H

a

rd

w

a

re

Hardware
Condition?

BLJB =1b?

No

No

FC03h address

BSB = 00h?

S

o

ft

w

a

re

Yes

0000h

APPLICATION PROGRAM

The Application program must program the BSB at FF (thanks to API). Then a reset will execute the sequence described
paragraph 4.6 page 12.

background image

Rev. A - 12-Jan-01

13

ANM095

Bootloader algorithm

BLJB =1b?

BSB = 00h?

SBV = FCh?

ATMEL BOOTLOADER

APPLICATION PROGRAM

CUSTOMER BOOTLOADER

PC= [SBV]00h

Hardware
Condition?

Yes

No

RESET

FC00h address

0000h address

H

a

rd

w

a

re

FC03h address

S

o

ft

w

a

re


Wyszukiwarka

Podobne podstrony:
DS066 XC95108 In System Programmable CPLD
DS063 XC95108 5V In System Programmable CPLD Family
AL2 system i programowanie pl
Botanika systematyczna program ćwiczeń 2014, biologia, Biologia I rok, Botanika systematyczna
Programming T89C51xx with Device
zaawansowane systemy programowania grafiki
System programowego oddziaływania
William Weber From miscellany to homogenity in Concert Programming
SYSTEM PROGRAMOWANEGO ODDZIAŁYWANIA W OPINIACH WIĘŹNIÓW
Static Detection of Malicious Code in Executable Programs
Flora Polski systematyka i program do cwiczen(1)
Teffaha D Relevance of Water Gymnastics in Rehabilitation Programs in
O'Reilly Programming Embedded Systems in C and C
Self Study Programme 351 Common rail fuel injection system fitted in the 3 0l V6 TDI engine
zarzadzenie nr 97 prezesa rady ministrow w sprawie utworzenia zespolu ds realizacji rzadowego progra

więcej podobnych podstron