Flasher STM8 User guide of the stand-alone SWIM programmer for STM8 Cores Manual Rev. 8 Date: May 2, 2011 Document: UM05006 A product of SEGGER Microcontroller GmbH & Co. KG www.segger.
Disclaimer Specifications written in this document are believed to be accurate, but are not guaranteed to be entirely free of error. The information in this manual is subject to change for functional or performance improvements without notice. Please make sure your manual is the latest edition. While the information herein is assumed to be accurate, SEGGER Microcontroller GmbH & Co. KG (the manufacturer) assumes no responsibility for any errors or omissions.
Revisions This manual describes the Flasher STM8 device. For further information on topics or routines not yet specified, please contact us. Revision Date By 8 110502 OO 7 110307 OO 6 101007 OO 5 100702 OO 4 100624 OO 3 100607 OO 2 100525 OO 1 100401 OO 0 091210 OO Flasher STM8 (UM05006) Explanation Chapter "Hardware": - Some minor changes. - Added more detailed information about the connection cable.
Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
About this document This document describes the Flasher STM8. It provides an overview over the major features of the Flasher STM8, gives you some background information about SWIM, STM8 general and describes Flasher STM8 related software packages available from Segger. Finally, the chapter Support and FAQs on page 65 helps to troubleshoot common problems. Typographic conventions This manual uses the following typographic conventions: Style Used for Body Body text.
SEGGER Microcontroller GmbH & Co. KG develops and distributes software development tools and ANSI C software components (middleware) for embedded systems in several industries such as telecom, medical technology, consumer electronics, automotive industry and industrial automation. SEGGER’s intention is to cut software developmenttime for embedded applications by offering compact flexible and easy to use middleware, allowing developers to concentrate on their application.
Table of Contents 1 Introduction ......................................................................................................................9 1.1 1.1.1 1.1.2 1.2 1.2.1 1.3 1.4 1.5 Flasher STM8 overview............................................................................. 10 Features of Flasher STM8.......................................................................... 10 Working environment ...............................................................................
5.3.4 5.3.5 Commands to Flasher .............................................................................. 50 Reply from Flasher STM8.......................................................................... 54 6 Hardware .......................................................................................................................57 6.1 6.1.1 6.2 6.2.1 6.3 6.4 6.4.1 6.5 10-pin connector (obsolete)......................................................................
Chapter 1 Introduction This chapter gives a short overview about the Flasher STM8. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 1 1.1 Introduction Flasher STM8 overview Flasher STM8 is a programming tool for microcontrollers with on-chip Flash memory and STM8 core. Flasher STM8 is designed for programming flash targets with a PC program or stand-alone. Flasher STM8 connects via USB, via ethernet or via RS232 interface to a PC, running Microsoft Windows 2000, Windows XP, Windows 2003, Windows Vista or Windows 7.
1.2 Specifications 1.2.1 Specifications for Flasher STM8 The following table gives an overview about the specifications (general, mechanical, electrical) for Flasher STM8.
CHAPTER 1 1.3 Introduction Flasher STM8 features • • • • • • • • • • • • USB 2.
1.4 Supported CPU cores Flasher STM8 has been designed and tested with the following cores, but should work with any STM8 core. If you experience problems with a particular core, do not hesitate to contact Segger. • • • STM8A STM8L STM8S Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 1 1.5 Introduction Download speed Flasher STM8 has been designed to allow downloading to the target as fast as the target can receive and program flash. The table below shows the measured download speed for standalone programming and for programming via PC driven software. The following testing environment has been used: • • • • • PC with 2.53 GHz Core2Duo, running WinXP USB 2.0 port USB 2.
Chapter 2 Setup This chapter describes the setup procedure required in order to work with Flasher STM8. Primarily this includes the installation of the Flasher STM8 software and documentation package. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 2 Setup 2.1 Installing the Flasher STM8 software and documentation pack Flasher STM8 is shipped with a bundle of applications, corresponding manuals and some sample projects and the kernel mode USB driver. Refer to chapter Flasher STM8 related software on page 27 for an overview about the Flasher STM8 software and documentation pack. 2.1.
2. Accept the default installation path C:\Program Files\SEGGER\FlasherSTM8_V or choose an alternative location. Confirm your choice with the Next > button. 3. The Choose options dialog is opened. The Create entry in start menu option is preselected. Accept or deselect the options and confirm the selection with the Next > button. Confirm start of installation by pressing Next > button again. 4. The installation process will be started.
CHAPTER 2 5. 6. Setup The Installation Complete dialog box appears after the copy process. Close the installation wizard with the Finish > button. The Flasher STM8 software and documentation pack is successfully installed on your PC. Connect your Flasher STM8 via USB with your PC. The Flasher STM8 will be identified and after a short period the Flasher LED stops rapidly flashing and stays on permanently. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
2.2 Setting up the USB interface After installing the Flasher STM8 software and documentation package it should not be necessary to perform any additional setup sequences in order to configure the USB interface of Flasher STM8. 2.2.1 Verifying correct driver installation To verify the correct installation of the driver, disconnect and reconnect Flasher STM8 to the USB port. During the enumeration process which takes about 2 seconds, the LED on Flasher STM8 is flashing.
CHAPTER 2 Setup Right-click on the driver to open a context menu which contains the command Properties. If you select this command, a J-Link driver Properties dialog box is opened and should report: This device is working properly. If you experience problems, refer to the chapter Support and FAQs on page 65 for help. You can select the Driver tab for detailed information about driver provider, version, date and digital signer. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
2.3 Uninstalling the J-Link USB driver If Flasher STM8 is not properly recognized by Windows and therefore does not enumerate, it makes sense to uninstall the J-Link USB driver. This might be the case when: • • The LED on the Flasher STM8 is rapidly flashing. The Flasher STM8 is recognized as Unknown Device by Windows. To have a clean system and help Windows to reinstall the J-Link driver, follow this procedure: 1. 2. Disconnect Flasher STM8 from your PC.
CHAPTER 2 2.4 Setup Setting up the IP interface Flasher STM8 has an additional Ethernet interface, to communicate with the host system. A built-in web server allows configuration of the flasher via web interface. In addition to that, you can set a default gateway for the flasher which allows using it even in large intranets. For simplicity the setup process of Flasher STM8 is described in this section. 2.4.
2.4.1.2 Connecting via Ethernet only This way of reading out the IP address of Flasher can be used for example if you do not have administrator rights on the host system in order to install the USB driver which is necessary to connect to Flasher via USB.
CHAPTER 2 Setup Assigning an IP address manually If you do not want Flasher to be configured via DHCP, you can assign an IP address and a subnet mask (optional) manually. This is done via the ipaddr command in STM8Commander.exe. This command can be used in four different ways, which are explained in the table below: Command ipaddr ipaddr ipaddr ipaddr DHCP Explanation If no additional parameter is specified, the current IP and subnet mask of Flasher are shown.
2.4.2.2 Configuring Flasher via web interface Flasher comes with a web server, which provides a web interface for configuration. This enables you to configure Flasher without additional tools, just with a simple web browser. The Home page of the web interface shows the serial number, the current IP address and the MAC address of the Flasher. The Network configuration page allows you to configure the IP address, the subnet mask and the default gateway of Flasher.
Flasher STM8 (UM05006) CHAPTER 2 Setup © 2011 SEGGER Microcontroller GmbH & Co.
Chapter 3 Flasher STM8 related software This chapter describes Segger’s Flasher STM8 related software portfolio available for use with Flasher STM8 hardware. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 3 3.1 age Flasher STM8 related software Flasher STM8 software and documentation pack- Flasher STM8 is shipped with a bundle of applications. Software JLinkSTM8.dll Description DLL for using Flasher STM8 with third-party programs. STM8Commander.e Free command-line tool with basic functionality for target analxe ysis. FlasherSTM8.exe Stand-alone flash programming application. For more information about Flasher STM8 Software please refer to Flasher STM8 Software User’s Guide (UM05007).
3.2 Flasher STM8 software and documentation package in detail The Flasher STM8 software documentation package is shipped together with Flasher STM8 and may also be downloaded from www.segger.com. 3.2.1 STM8 Commander (Command line tool) STM8 Commander (STM8Commander.exe) is a tool that can be used for verifying proper installation of the USB driver and to verify the connection to the STM8 chip, as well as for simple analysis of the target system.
CHAPTER 3 3.2.2 Flasher STM8 related software Flasher STM8 Software (Program flash memory) Flasher STM8 is a software running on Windows 2000, Windows XP, Windows 2003, Windows Vista or Windows 7 systems and enables you to program your flash EEPROM devices via the SWIM connector on your target system. Flasher STM8 works with any STM8 system and supports the programming of internal flash of STM8 microcontrollers.
3.3 Using the JLinkSTM8.dll 3.3.1 What is the JLinkSTM8.dll? The JLinkSTM8.dll is a standard Windows DLL typically used from C or C++, but also Visual Basic or Delphi projects. It makes the entire functionality of the Flasher STM8 available through the exported functions. The functionality includes things such as halting/running the STM8 core and reading/ writing memory. Therefore, it can be used in any kind of application accessing an STM8 core. 3.3.2 Determining the version of JLinkSTM8.
CHAPTER 3 3.3.3 Flasher STM8 related software Determining which DLL is used by a program To verify that the program you are working with is using the DLL you expect it to use, you can investigate which DLLs are loaded by your program with tools like Sysinternals’ Process Explorer. It shows you details about the DLLs, used by your program, such as manufacturer and version. Process Explorer is - at the time of writing - a free utility which can be downloaded from www.sysinternals.com.
Chapter 4 Working with Flasher STM8 This chapter describes functionality and how to use Flasher STM8. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 4 4.1 Working with Flasher STM8 Operating modes Flasher STM8 is able to boot in 3 different modes: • • • PC mode Stand-alone mode MSD (Mass storage device) mode If Flasher STM8 can enumerate on the USB port, Flasher STM8 boots in "PC mode". In this mode Flasher STM8 can be used as an emulator. When Flasher is powered up and Flasher STM8 cannot enumerate, the "stand-alone mode" is started. In this mode Flasher STM8 can be used as a stand-alone flash programmer.
4.1.1.2 Setting up Flasher STM8 for stand-alone mode In order to set up Flasher STM8 for the "stand-alone mode" it has to be in "PC mode". When the correct connection of Flasher STM8 to the host PC is verified start the Flasher STM8 Software. For more information about Flasher STM8 Software, refer to the Flasher STM8 Software User Guide. The Flasher STM8 related software and documentation package contains the Flasher STM8 Software.
CHAPTER 4 Working with Flasher STM8 Now, choose File->Download to programmer from the menu in order to download the target configuration as well as the data file to the Flasher STM8. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
After the download, you should see in the Flasher Log window that the Flasher.cfg and the Flasher.dat files have been successfully downloaded. From now on, Flasher STM8 can be used in "stand-alone mode" for stand-alone programming. 4.1.2 Stand-alone mode In order to use Flasher STM8 in "stand-alone mode", it has to be configured first, as described in Setting up Flasher STM8 for stand-alone mode on page 35.
CHAPTER 4 Status of LED GREEN, slow blinking (1 Hz) GREEN RED Working with Flasher STM8 Meaning Erasing/Programming/Verifying operation is in progress. Operation successful / Ready. Operation failed. Table 4.1: Flasher STM8 LEDs 4.1.3 MSD mode When pressing the Start/Stop button of Flasher STM8 while connecting it to the PC via USB, Flasher STM8 will boot in the "MSD mode".
4.2 Multiple File Support It is also possible to have multiple data files and config files on Flasher STM8, to make Flasher STM8 more easy to use in production environment. To choose the correct configuration file and data file pair, a FLASHER.INI file is used. This init file contains a [FILES] section which describes which configuration file and which data file should be used for programming. A sample content of a FLASHER.INI file is shown below: [FILES] DataFile = "Flasher1.
CHAPTER 4 4.2.1 Working with Flasher STM8 Setting up configurations and switching configurations The following steps describe the way to setup and use multiple configurations and how they can be exchanged using the STM8 Commander. Setup and exchanging configurations can be done via RS232 the same way except that the way of file access is slightly different using the ASCII command interface as described in ASCII command interface on page 50. 1.
2. Use "File->Save programmer configuration file..." and save as "Flasher1.cfg" to a temporary directory. 3. Use "File->Save programmer data file..." and save as "Flasher1.dat" to a temporary directory. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 4 Working with Flasher STM8 4. Repeat the steps 1-3 to create an other configuration and save the files as "Flasher2.cfg" and "Flasher2.dat" to the same directory you saved the first set of configuration files. 5. Create a text file named "FLASHER.ini" with the following content: [FILES] DataFile = "Flasher1.dat" ConfigFile = "Flasher1.cfg" 6.
9. Download the files from your temporary folder to the Flasher using the "fwrite" command as shown in the screenshot below: From now on the files "Flasher1.cfg" and "Flasher1.dat" will be used for standalone flashing. 10. If you wish to switch configurations please change your "FLASHER.ini" to contain the file names of the second set of configuration files. Then delete the old "FLASHER.ini" currently on your Flasher and download the new one to activate the configuration for the second set of files.
CHAPTER 4 4.3 Working with Flasher STM8 Connecting multiple Flasher to your PC You can connect up to 4 Flasher to your PC. In this case, all Flasher must have different USB-addresses. The default USB-address is 0. In order to do this, 3 Flasher must be configured as described below. Every Flasher need its own J-Link USB driver which can be downloaded from www.segger.com. Note: Flasher STM8 along with other USB featured SEGGER products use the JLink USB driver.
4.3.2 Configuring multiple Flasher STM8 1. 2. Start STM8Commander.exe Type usbaddr = 1 to set the Flasher #1. 3. 4. Unplug Flasher and then plug it back in. The system will recognize and automatically install a new Flasher using the J-Link USB driver. 5. You can verify the driver installation by consulting the Windows device manager.
CHAPTER 4 4.3.3 Working with Flasher STM8 Connecting to a Flasher with non default USB-Address Restart STM8Commander.exe and type usb 1 to connect to Flasher #1. You may connect other Flasher to your PC and connect to them as well. To connect to an unconfigured Flasher (with default address "0"), restart STM8Commander.exe or type usb 0. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
Chapter 5 Remote control This chapter describes how to control Flasher STM8 via the 9-pin serial interface connector or via TCP/IP. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 5 5.1 Remote control Overview There are 4 ways to control Flasher STM8 operation: • • • • Manual: Programming operation starts when pressing the button. The LEDs serve as visible indication. Via Handshake lines: 3 lines on the serial interface are used. 1 line is an input and can be used to start operation, 2 lines are outputs and serve as Busy and status output Terminal communication via RS232 Terminal communication via TCP/IP.
5.2 Handshake control Flasher STM8 can be remote controlled by automated testers without the need of a connection to PC and Flasher STM8’s PC program. Therefore Flasher STM8 is equipped with additional hardware control functions, which are connected to the SUBD9 male connector, normally used as RS232 interface to PC. The following diagrams show the internal remote control circuitry of Flasher STM8: 5 4 BUSY 7 OK 1 START 470 Flasher STM8 internalLogic 470 22k 4k7 START BUSY BUSY OK Pin No.
CHAPTER 5 5.3 Remote control ASCII command interface 5.3.1 Introduction Once set up using Flasher STM8 Software, Flasher STM8 can be driven by any application or just a simple terminal using ASCII commands. Every known command is acknowledged by Flasher and then executed. After command execution, Flasher sends an ASCII reply message. If an unknown command is received, Flasher responds with #NACK. 5.3.2 • • • 5.3.
#AUTO NOINFO This command may be used instead of #AUTO, if no status messages from Flasher should be sent during execution. The NOINFO extension is also available for all other commands. The command ends with #OK or #ERRxxx #ERASE This command can be sent to erase all selected target flash sectors. Flasher will reply the following sequence of messages: #ACK #STATUS:INITIALIZING #STATUS:CONNECTING #STATUS:UNLOCKING #STATUS:ERASING #OK (Total 0.893s, Erase 0.
CHAPTER 5 Remote control #BAUDRATE This command can be sent in order to change the baudrate of the UART used for the ASCII command interface communication. is expected in decimal format.
#FDELETE flasher.dat #ACK #OK Note: If deletion of the file fails for example if the file does not exist, Flasher will respond with the following sequence: #ACK #ERR255:Failed to delete file #FWRITE ,: The #FWRITE command is used to write a file. specifies the offset in the file, at which data writing is started. specifies the number of bytes which are sent and which are written into the file on Flasher. is limited to 512 bytes at once.
CHAPTER 5 Remote control If the #FSIZE command succeeds, Flasher will respond with a #OK: reply message. For more information about the Flasher reply messages, please refer to Reply from Flasher STM8 on page 54. Note: In order to use the #FREAD command, a file has to be opened before, using the #FOPEN command. Otherwise Flasher will respond with the following sequence: #ACK #ERR255:No file opened 5.3.
Message #STATUS:ERASING #STATUS:PROGRAMMING #STATUS:VERIFYING Description Flasher is erasing the flash of the target device. Flasher is programming the flash of the target device. Flasher verifies the programmed flash contents. Table 5.2: List of status messages that are currently defined Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 5 Remote control #ERRxxx If any command other than #STATUS or #RESULT was terminated with an error, Flasher cancels the command and replies with an error message instead of #OK message. Some error codes may be followed by colon and an additional error text. For example: #ERR007:CANCELED. The error code numbers are described in the following table: Message #ERR007 #ERR255 Description Flasher received #CANCEL command and has canceled the current operation. Undefined error occurred.
Chapter 6 Hardware This chapter gives an overview about Flasher STM8 specific hardware details, such as the pinouts and available adapters. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 6 6.1 Hardware 10-pin connector (obsolete) First production charge of Flasher STM8 has a 10-pin connector. The connector is a 10 way Insulation Displacement Connector (IDC) keyed box header (male) that mates with IDC sockets mounted on a ribbon cable. This 10-pin connector is obsolete and will not be available on future Flasher versions.
6.2 4-pin Connector Flasher STM8 has a 4-pin connector. The connector is a 4 way connector keyed box header (male) that mates with a connector of type ERNI 214012 mounted on a ribbon cable. 6.2.1 4-pin connector pinout 1 2 3 4 VCCT SWIM GND Reset The following table lists the Flasher STM8 4-pin connector pinout. PIN SIGNAL TYPE 1 VCCT I/O 2 SWIM I/O 4 Reset I/O Description Target voltage reference or target supply pin. Has to be connected to the target CPUs supply voltage.
6.3 CHAPTER 6 Hardware Connection cable The standard cable which is delivered with Flasher STM8 to connect a target to the Flasher is a 4 way ribbon cable of type ERNI part no. 839016 (100mm) mounted with keyed header (female) mounted on both sides (resulting in a total length of around 120mm). Flasher STM8 is tested with the delivered cable for being fully functional. Using your own cable or using a different cable length is not recommended as proper function can not be guaranteed.
6.4 Target board design for SWIM We strongly advise following the recommendations given by the chip manufacturer. These recommendations are normally in line with the recommendations given in the table 10-pin connector pinout on page 58 and 4-pin connector pinout on page 59. In case of doubt you should follow the recommendations given by the semiconductor manufacturer.
6.5 CHAPTER 6 Hardware How to determine the hardware version To determine the hardware version of your Flasher STM8, you should first look at the label at the bottom side of the unit. The hardware version is printed on the back label. If this is not the case with your Flasher STM8, you can use STM8Commander.exe to determine your hardware version (if Flasher STM8 is in PC mode). As part of the initial message, the hardware version is displayed.
Chapter 7 Background information This chapter provides background information about flash programming in general. It also provides information about how to replace the firmware of Flasher STM8 manually. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 7 7.1 Background information Flash programming Flasher STM8 comes with a DLL, which allows - amongst other functionalities - reading and writing RAM and starting and stopping the CPU. 7.1.1 How does flash programming via Flasher STM8 work ? This requires extra code. This extra code typically downloads a program into the RAM of the target system, which is able to erase and program the flash.
Chapter 8 Support and FAQs This chapter contains troubleshooting tips together with solutions for common problems which might occur when using Flasher STM8. There are several steps you can take before contacting support. Performing these steps can solve many problems and often eliminates the need for assistance. This chapter also contains a collection of frequently asked questions (FAQs) with answers. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 8 8.1 Support and FAQs Contacting support Before contacting support, make sure you tried to solve your problem by trying your Flasher STM8 with another PC and if possible with another target system to see if it works there. If the device functions correctly, the USB setup on the original machine or your target hardware is the source of the problem, not Flasher STM8. If you need to contact support, send the following information to support@segger.
8.2 Frequently Asked Questions Maximum download speed Q: A: What is the maximum download speed supported by Flasher STM8 ? Flasher STM8’s maximum supported programming speed depends on flash programming speed supported by your target chip. Programming a 128kByte device can be done in less than 9 seconds resulting in speeds of about 14-15 kByte/sec. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
Flasher STM8 (UM05006) CHAPTER 8 Support and FAQs © 2011 SEGGER Microcontroller GmbH & Co.
Chapter 9 Glossary This chapter describes important terms used throughout this manual. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 9 Glossary Big-endian Memory organization where the least significant byte of a word is at a higher address than the most significant byte. See Little-endian. Coprocessor An additional processor that is used for certain operations, for example, for floatingpoint math calculations, signal processing, or memory management. Host A computer which provides data and other services to another computer. Especially, a computer providing debugging services to a target being debugged. ID Identifier.
Chapter 10 Literature and references This chapter lists documents, which we think may be useful to gain a deeper understanding of technical details. Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
CHAPTER 10 Reference [Flasher STM8 Software] Title Literature and references Comments This document describes the Flasher STM8 Software User Flasher STM8 Software. It is pubGuide licly available from SEGGER (www.segger.com). Table 10.1: Literature and References Flasher STM8 (UM05006) © 2011 SEGGER Microcontroller GmbH & Co.
Index B Big-endian ..........................................70 C Coprocessor ........................................70 F Flasher STM8 Features ...........................................10 Specifications ....................................11 Flasher STM8 Software .........................30 H Host ...................................................70 I ID .....................................................70 Image ................................................70 P Processor Core ...........
Flasher STM8 (UM05006) Index © 2011 SEGGER Microcontroller GmbH & Co.