ST AN2430 Application note

AN2430
Application note
STR75x SystemMemory boot mode
Introduction
This application note describes the features of the SystemMemory boot mode developed for STR75x Flash microcontrollers providing all the basic functionality to support the programming of the embedded Flash. As well as the general features, this document also covers the specific features of the UART boot mode.
Note: The bootloader feature is unavailable on some devices soldered on development tools
(starter kits or evaluation boards). Please refer to Section 4 on page 22 for further information.
January 2007 Rev 3 1/24
www.st.com
Contents AN2430
Contents
1 General description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1 Entering SystemMemory boot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2 Hardware requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3 Using SystemMemory boot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.4 Command description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.1 Get command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.4.2 Read Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.4.3 Go command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4.4 Write Memory command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.4.5 Erase command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
1.4.6 Write Protection command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1.4.7 Write Unprotection command . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
1.4.8 Readout Permanent Protect command . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.4.9 Readout Temporary Unprotect command . . . . . . . . . . . . . . . . . . . . . . . 15
1.4.10 Readout Permanent Unprotect command . . . . . . . . . . . . . . . . . . . . . . . 16
1.5 Exiting SystemMemory boot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
1.6 SystemMemory code program flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2 UART SystemMemory boot mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.1 UART SystemMemory code sequence . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Choosing the UART baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.1 Minimum baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2.2 The maximum baud rate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.2.3 Higher baud rate deviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
4 Bootloader availability limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2/24
AN2430 General description

1 General description

The STR75x is usually woken up in SystemMemory boot Mode when the Flash is still not programmed in the manufacturing line environment. In this case the system boot is performed from SystemMemory sector in the Flash bank0. This mode allows initialization of the Flash programming via a serial interface and the use of the Internal Free Running Oscillator.

1.1 Entering SystemMemory boot mode

The STR75x enters the SystemMemory Boot Mode if the BOOT pins are configured as follows:
BOOT0 = 1
BOOT1= 0
The value of the BOOT pin is latched on the 4th rising edge of CK_SYS after Reset.
After Reset, the STR75x CPU begins execution of the SystemMemory code which resides in the SystemMemory sector.
Table 1. STR75x device configuration in SystemMemory Boot Mode
Feature/Peripheral State Comment
Instruction Set THUMB Save code space with 16-bit instructions
CPU Mode Supervisor Full access with IRQ Enabled and FIQs disabled
Input Clock
UART0_RX Pin Input UART0 Receive
UART0_TX Pin Output UART0 Transmit
UART0 Registers Default Only configured for UART Boot
Internal
FREEOSC

1.2 Hardware requirements

The hardware required to put the STR75x into SystemMemory boot mode consists of any circuitry, switch, or jumper capable of holding the BOOT0 pin high and the BOOT1 pin low during Reset.
To connect to the STR75x during SystemMemory boot mode, a RS232 serial interface must be directly linked to UART0 pins.
For more details, refer to the STR75x hardware development getting started application note (AN2419).
Allow a Frequency in a range of 2 to 10MHz
3/24
General description AN2430

1.3 Using SystemMemory boot mode

The SystemMemory boot mode is executed from RAM and uses the last 4K of 16K RAM, i.e. from 0x40003000 to 0x40003FFF. So when downloading code to RAM, the user has to consider only the 12K RAM (from 0x40000000 to 0x40002FFF).
After the serial link initialization sequence (see the following chapters) the SystemMemory code waits for the user to run some commands.
The supported commands are listed in the table below.
Table 2. Allowed commands
Command
Command
Code
Command Description
Get 0x01
Read Memory 0x11
Go 0x21
Write Memory 0x31
Erase 0x43 Erase from one to all the Flash sectors
Write Protection 0x63
Write Unprotection 0x71 Temporarily disable the write protection for all Flash sectors
Readout Permanent
Protect
Readout Temporary
Unprotect
Readout Permanent
Unprotect
0x82 Permanently enable the the Readout protection
0x91 Temporarily disable the Readout protection
0x92 Permanently disable the Readout protection
Get the SystemMemory version and the number of times the readout protection is disabled/enabled.
Read until 256 bytes of memory starting from an address specified by the user
Jump to an address specified by the user to execute a loaded code
Write until 256 bytes to the RAM or the Flash starting from an address specified by the user
Permanently enable the write protection for the needed sectors
4/24
AN2430 General description

1.4 Command description

1.4.1 Get command

Description:
This command allows the user to get the version of the bootloader, the number of times the Readout protection is both disabled and enabled.
When the bootloader receives the Get command, it transmits four bytes to the user: the first byte contains the version, the second contains the number of times the Readout protection is disabled, the third contains the number of times it’s enabled and finally the ACK byte.
Figure 1. Get command flowchart
Start GC
Received byte
== 0x01?
Send the version of the bootloader
Send the number of times the Readout
protection is Disabled
Send the number of times the Readout
protection is enabled
Send ACK byte
End of GC
No
Send NACK byte
5/24
General description AN2430

1.4.2 Read Memory command

Description:
This command allows the user to read the memory (RAM, Flash and registers).
When the bootloader receives the Read Memory command, it transmits the ACK byte.
After the transmission of the ACK byte, the bootloader waits for an address (4 bytes, byte 1 is the MSB and byte 4 is LSB of the address), checks this address, if the address is valid, it transmits an ACK byte otherwise it transmits a NACK byte (0x3F) and exits from the command.
When the address is valid, the bootloader waits for the number of bytes to be transmitted (N bytes) and then returns to the user the needed data ((N + 1) bytes) starting from the received address.
Figure 2. Read memory flowchart
Start RM
Received byte
== 0x11?
Send ACK byte
Receive the start address (4 bytes)
Valid Address?
Send ACK byte
Receive the number of bytes to be read
(1 byte)
Send data to the user
End of RM
No
No
Send NACK byte
6/24
AN2430 General description

1.4.3 Go command

Description:
This command allows the user to execute the downloaded code or any other code by making a branch to an address specified by the user.
When the bootloader receives the GO command, it transmits the ACK byte.
After the transmission of the ACK byte, the bootloader waits for an address (4 bytes, byte 1 is the MSB and byte 4 is LSB of the address), checks this address, if the address is valid, it transmits an ACK byte otherwise it returns a NACK byte (0x3F) and exits from the command.
When the address is valid, the program counter of the CPU jumps automatically to this address. Therefore, the SystemMemory boot mode is exited.
Note: During SystemMemory mode, the CPU is in Thumb state.
Figure 3. Go command flowchart
Start GO
Received byte
== 0x21?
Send ACK byte
Receive the start address (4 bytes)
Valid Address?
Send ACK byte
Jump to start address
Exit SystemMemory
boot mode
No
No
Send NACK byte
End of GO
7/24
General description AN2430

1.4.4 Write Memory command

Description:
This command allows the user to write data to any address memory (RAM, Flash or registers).
When the bootloader receives the Write Memory command, it transmits to the user the ACK byte.
After the transmission of the ACK byte, the bootloader waits for an address (4 bytes, byte 1 is the MSB and byte 4 is LSB of the address), checks this address, if the address is valid, it transmits an ACK byte otherwise it returns a NACK byte (0x3F) and exits from the command.
When the address is valid, the bootloader:
Gets a byte which describes the amount of data to be received (N bytes),
Receives the user data ((N + 1) bytes),
Programs the user data to memory starting from the received address,
Finally, at the end of the command, the bootloader transmits the ACK byte if the write operation is completed successfully otherwise a NACK byte (0x3F) is returned and the command is exited.
8/24
Loading...
+ 16 hidden pages