ST AN1575 Application note

AN1575
APPLICATION NOTE
ON-BOARD PROGRAMMING METHODS
FOR XFLASH AND HDFLASH ST7 MCUs
by Microcontroller Division Applications
INTRODUCTION
This application note presents various ways of programming a Microcontroller (MCU) that has already been s oldered on a P CB. This “ on-bo ard” prog ram ming pr oces s c an be u sed to up­date either the whole fi rmware or only a set of d ata. The techn iques descri bed are f ully sup­ported features of the STMicroelectronics range of MCUs with embedded non-volatile memo­ries (OTP, then FLAS H) design ed to m eet the nee ds of eq uipment manufa cturers and cu s­tomers. The ever-growing importance of Surface Mounted Devices (SMD) with high pin count makes it more and more complex and costly to program with standard programming tools, while the constraints of time-to-market and flexibility make it necessary to be able to program or reprogra m t he prod uc ts a s la te as pos sib le in the pro duc tion cyc le, even a t t he final cu s­tomer site. Aside from these manufacturing considerations, the capability of an MCU to be re­programmed in-situ opens new applicatio n fields: customiza tion, performan ce upgrades, re­mote maintenance, etc, are features that are valued by the end-customer.
Two main contexts have to be considered: – Programming a MCU in the framework of a production line or when the application is not run-
ning (see Section 1).
– Programming the MCU ‘on the fly’ while it is running in the application, generally at the cus-
tomer site (see Section 2).
AN1575/1002 1/11
1
ON-BOARD PROGRAMMING METHODS FOR XFLASH AND HDFLASH ST7 MCUs
1 APPLICATION NOT RUNNING DURING PROGRAMMING
This case covers applic ations that c an b e stopped during the programm ing ope ration: either because there is no need to keep the app lication running, or because the programming process does not require any special fi rmware to be run by the MCU. This last point means the application design is compatible with the programming method and tools used.
For this purpose, STMicroelectronics has defined an In Circuit Programming (ICP) method with a minimum of constraints on the application design.
1.1 ICP OVERVIEW
With this method, the MCU is switched by the programming tool into a special operating mode, called In Circuit Communication (ICC) mode, by an event sequence on the RESET, VPP/ TEST, ICCCLK and ICCDATA pins: Throughout the entire programming operation, it remains under control of the programming tool and all transactions go through the ICCCLK and ICCDATA lines.
In order to be compa tible with the IC P me thod , the ap plication must therefo re be eq uipp ed with a special c onnector for t he RESET, VPP/TEST, I CCCLK and ICC DATA signal s, whil e r e­specting some guidelines in order not to interfere with other parts of the application.
Note that th is con nect or featu res a V PP/TE ST li ne to allow to su pply 12 V exter nally on the VPP pin for HDFLASH-based devices.
When using the ICP method, the user has exactly the same features as on any programming tool: the whole program memory range, as well as the option bytes can be accessed.
1.2 ICP PRACTICAL IMPLEMENTATION
The ICP implementation is purely a hardware issue as shown in Figure 1. No embedded firmware needs to be developed. On the other words, the ICP method can be used to program a blank MCU.
The only sensitive point is sometimes to correctly isolate the RESET, ICCCLK and ICCDATA in order to avoid any conflict with the devices connected to these pins for purposes of the final applicati on. Thi s is gene rally en sured by simp le resis tors (mo re deta ils can be found in the MCU datasheets or in the ST7 ICC Reference Manual).
During the ICP process, the MCU’s embedded peripherals remain in reset state since no soft­ware is running t o ac tivate th em . It s hould be n oted howev er tha t th e hard ware w atchdog i s disabled.
2/11
2
ON-BOARD PROGRAMMING METHODS FOR XFLASH AND HDFLASH ST7 MCUs
1.2.1 Application power supply
The application does n ot need to use its own power s upply if the programm ing t ool supplies power th rough pin 7 of the ICC connec tor. Th is is the c ase wh en usin g STMicr oelec tronic s programming tools (Refer to the Programming Tool manual).
1.2.2 Application clock
In case the ap plication does n ot ha ve its ow n clock durin g the IC P process (O ption byte not programmed yet,..), the ICC connecti on can be us ed to input an external clock from the pro­gramming tool.
Figure 1. ICP Hardware Design
PROGRAMMING TOOL
ICC CONNECTOR
APPLICATION POWER SUPPLY
OPTI ONAL (See tex t)
C
L2
DD
V
OSC2
OPTIONAL (See tex t)
C
L1
OSC1
ST7
975 3
10k
SS
V
ICCSEL/VPP
ICC Cabl e
RESET
ICCCLK
1 246810
ICCDATA
APPLICATION BOARD
ICC CONNECTOR
APPLICATION RESET SOURCE
Isolation
Isolation
Isolation
APPLICATION
I/O
3/11
ON-BOARD PROGRAMMING METHODS FOR XFLASH AND HDFLASH ST7 MCUs
2 APPLICATION RUNNING DURING P ROGRAMMING
This method is primarily for applications that cannot be stopped and which have to keep some kind of software kernel running all the time (generally for security or safety reasons).
It also covers, and this is the most common reason for not using ICP, applications where the application designer ch ooses alternat ive means of implementing th e programm ing process, specifically:
– The hardware connection to the programming tool, where the new firmware is stored – The software protocol that defines the commands, status and data format.
A typica l case is w hen a com mu nicatio n port alre ady us ed in th e appli cation i s availa ble: It avoids implementing an additional connector just for the ICP process: this approach is widely used for devices with a CAN or USB interface.
Using your own protocol for on-board programming has the advantage of allowing flexibility in terms of hardware implementation. However, some firmware must already be present on the MCU in orde r to run the com munica tion pr otocol: T his metho d can thus be used on ly fo r re­progra mming , wh ich imp lies th e MC U has been progra mm ed at le ast onc e be fore wi th an­other method. Another constraint is that it is not possible to reprogram the whole program memory of the MCU: nor can the reprogramming firmware itself be altered.
ST7 STMicroel ectron ics MCUs wit h HDFLAS H and XFLAS H have thi s capability of running user-specific firmware to perform In-Application Programming (IAP) of the MCU program memory.
This feature not only allows the application to keep some background tasks running, but also to allows you to use any type of communication protocol for the reprogramming process.
2.1 IAP OVERVIEW
The ST7 progra m mem ory i s divid ed into several (up to 3) s ectors. O nly S ector 0 c annot be programmed or eras ed in n orm al (user m ode) op eration. So this sector can be used to exe­cute the firmware handling the reprogramming process, without being altered.
Reprogramming any of the other sec tors is possible, and is based on the execution of a spe­cific software sequence, for which a software library, the IAP driver, is provided by STMicroe­lectronics.
The Sector 0 firmware handles the complete protocol and sequencing of the operations, and some tasks that cannot be stopped during the programming process.
In contrast to th e ICP proc ess, the e mbedde d ha rdwa re perip herals can be activa ted by the Sector 0 firmware to carry out some background tasks. The only limitation is that the Interrupt Requests coming from these peripherals (Reception on UART, Timer overflow, ..) can be processed only after the IAP driver has completed the requested operations. A notable excep-
4/11
Loading...
+ 7 hidden pages