Flasher - Remote control: Difference between revisions

From SEGGER Knowledge Base
Jump to navigation Jump to search
(→‎Handshake control: Improved description of Handshake interface. (Open-drain outputs))
Line 38: Line 38:
| 1        || START    || A positive pulse of any voltage between 5 and 30V with duration of min. 30 ms starts "Auto" function (Clear / Program / Verify) on falling edge of pulse. The behavior of the "Auto" function depends on the project settings, chosen in J-Flash at the '''Production''' tab.
| 1        || START    || A positive pulse of any voltage between 5 and 30V with duration of min. 30 ms starts "Auto" function (Clear / Program / Verify) on falling edge of pulse. The behavior of the "Auto" function depends on the project settings, chosen in J-Flash at the '''Production''' tab.
|-
|-
| 4        || BUSY      || Open-drain output: As soon as the "Auto" function is started, BUSY becomes active, which means that transistor is switched OFF. <br>It is recommended to connect an external high impedance pull up (5K) to measure the state.
| 4        || BUSY      || Open-drain output: As soon as the "Auto" function is started, BUSY becomes active, which means that transistor is switched OFF. <br>It is recommended to connect an external high-impedance pull-up (e.g. 5K) to measure the state.
|-
|-
| 5        || GND      || Common Signal ground.
| 5        || GND      || Common Signal ground.
|-
|-
| 7        || OK        || Open-drain output: This output reflects result of last action. It is valid after BUSY turned back to passive state. The output transistor is switched ON (OK is pulled to GND) to reflect OK state. <br> It is recommended to connect an external high impedance pull up (5K) to measure the state.
| 7        || OK        || Open-drain output: This output reflects result of last action. It is valid after BUSY turned back to passive state. The output transistor is switched ON (OK is pulled to GND) to reflect OK state. <br> It is recommended to connect an external high-impedance pull-up (e.g. 5K) to measure the state.
|-
|-
|}
|}

Revision as of 13:07, 31 July 2024

This chapter describes how to control the Flasher in standalone mode.

There are 3 ways to control Flasher operation:

Type of control Description
Button Programming operation starts when pressing the PROG-button. The LEDs serve as visible indicators.
Handshake 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 signals.
Terminal Terminal communication via TELNET, RS232 or VCOM with the #ASCII command interface


Note:
All ways to control Flasher operation are working only if Flasher is in standalone mode. In PC-based mode or file access mode they have no effect.

Handshake control

Some Flasher models are equipped with additional hardware control functions that are connected to the SUBD9 male connector, normally used as an RS232 interface to the PC. These Flasher models can therefore be controlled remotely by automated testers without the need for a connection to a PC.

The handshake control is available for the following Flashers:

  • Flasher ARM
  • Flasher PRO
  • Flasher Compact (via Flasher Hub and Flasher Hub-12 only)

The following diagrams show the internal remote control circuitry of Flasher:

FlasherRemotecontrol.png

Pin No. Function Description
1 START A positive pulse of any voltage between 5 and 30V with duration of min. 30 ms starts "Auto" function (Clear / Program / Verify) on falling edge of pulse. The behavior of the "Auto" function depends on the project settings, chosen in J-Flash at the Production tab.
4 BUSY Open-drain output: As soon as the "Auto" function is started, BUSY becomes active, which means that transistor is switched OFF.
It is recommended to connect an external high-impedance pull-up (e.g. 5K) to measure the state.
5 GND Common Signal ground.
7 OK Open-drain output: This output reflects result of last action. It is valid after BUSY turned back to passive state. The output transistor is switched ON (OK is pulled to GND) to reflect OK state.
It is recommended to connect an external high-impedance pull-up (e.g. 5K) to measure the state.

FlasherRemoteSignal.png

ASCII command interface

Introduction

Once set up using J-Flash or U-Flash, the Flasher can be driven by any application or just a simple terminal using ASCII commands.

Every known command is acknowledged by the Flasher and then executed. After command execution, Flasher sends an ASCII reply message.


Note:
There are situations where the execution of a known command is rejected with #NACK:ERRxxx if Flasher is currently busy and the received command is not allowed to be sent while Flasher is busy

General command and reply message format

  • Any ASCII command has to start with the start delimiter #.
  • Any ASCII command has to end with simple carriage return ('\r', ASCII code 13).
  • Commands can be sent upper or lower case

General usage

Reply messages must be considered in each case. In general, a new command must not be sent before a reply for the last one has been received.

When a flash programming function (#AUTO, #CANCEL, #ERASE, #PROGRAM, #VERIFY) has finished, the debug logic of the MCU is disabled (power down) and the target interface of the module is switched off (tristated).

Settings for ASCII interface via RS232

Flasher is driven via a RS-232 serial port with the following interface settings:

  • 9600 baud
  • 8 data bits
  • no parity
  • 1 stop bit

The baud rate can be changed by using the #BAUDRATE command.

Supported baud rates

Current Flasher models support baud rates of up to 115200 Bd on their RS-232 interface.

Depending on the environment (i.e. cable length, signal quality, drive strength and voltage threshold levels of the other end, ...), greater baud rates may work, but SEGGER does not guarantee it. As such, no technical support is provided in case of issues with baud rates exceeding the officially supported maximum.

Settings for ASCII interface via Telnet

A client application can connect to Flasher via Telnet on port 23. Find below a screenshot of Flasher which is remote controlled via Telnet:

telnet connection.gif

Settings for ASCII interface via VCOM

The same settings can be used for VCOM as for RS232.


Note:
The performance also depends on the terminal application used on the PC.

Commands and replies

The table below gives an overview about the commands which are supported by the current version of Flasher firmware. Click on the names for a detailed description:

Commands to the Flasher
#BAUDRATE <Baudrate>
#AUTO
#AUTO PATCH
#AUTO NOINFO
#CANCEL
#ERASE
#PROGRAM
#RESULT
#SELECT <Filename>
#START
#STATUS
#VERIFY
#READ
#QUIT
#VERBOSE <Level>
File I/O commands
#FCLOSE
#FCRC
#FDELETE <Filename>
#FFORMAT
#FOPEN <Filename>
#FREAD <Offset>,<NumBytes>
#FSIZE
#FWRITE <Offset>,<NumBytes>:<Data>
#FLIST
#MKDIR <Dirname>
SecureArea commands
#HASSECUREAREA
#SECUREAREA <action>
Replies from the Flasher
#ACK
#NACK
#OK
#OK:<NumBytes>:<Data>
#OK:<Size>
#STATUS:
#DONE
#ERRxxx

Commands to the Flasher

#AUTO
The #AUTO command behaves exactly as the start button or external remote control input.

Usually, the following command sequence will be performed when receiving the #AUTO command:

  • The Flasher erases the target CPU (if not blank)
  • The Flasher programs the target CPU
  • The Flasher verifies the target CPU

Depending on the settings chosen in the Production tab in J-Flash, this sequence can differ from the one shown above.

Finally, Flasher responds with

  • #OK if no error occurred
  • #ERRxxx if any error occurred during operation. xxx represents the error code, normally replied to Flasher PC program. The #ERRxxx message may be followed by an additional error text.

During execution of the #AUTO command, Flasher automatically sends "status" messages via RS232 to reflect the state of execution. Typically during execution of #AUTO command, Flasher will reply the following sequence of messages:

#ACK
#STATUS:INITIALIZING
#STATUS:CONNECTING
#STATUS:UNLOCKING
#STATUS:ERASING
#STATUS:PROGRAMMING
#STATUS:VERIFYING
#OK (Total 13.993s, Erase 0.483s, Prog 9.183s, Verify 2.514s)

#AUTO PATCH
The #AUTO PATCH command allows patching of the content of the data to be programmed.

Flasher responds with

  • #OK if no error occurred
  • #ERRxxx if any error occurred during operation. xxx represents the error code, normally replied to Flasher PC program. The #ERRxxx message may be followed by an additional error text.

For further information about the usage of the #AUTO PATCH command please refer to Patch file support.

#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

#BAUDRATE <Baudrate>
This command can be sent in order to change the baud rate of the Flasher's RS232 interface used for communication. <Baudrate> is expected in decimal format.

If this command succeeds, Flasher responds with:

#ACK
#OK

Otherwise it will respond with one of the following error messages:

#ERR255: Invalid parameters
or
#ERR255: Baudrate is not supported


Note:

After sending the #BAUDRATE command you will first have to wait until the Flasher responds with the #OK message.

It is recommended wait 5ms before sending the next command with the new baudrate in order to give the Flasher the time to change the baudrate.

#CANCEL
This command can be sent to abort a running program. It may take a while until the current program is actually canceled.

Flasher will respond with:

#ERR007:CANCELED.

#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.483s)

#PROGRAM
This command can be used instead of #AUTO to program a target without erasing the target before programming and without performing a final verification.

#RESULT
This command can be sent any time, even during other command execution. Flasher responds with the last result of the previously executed command.

#SELECT <Filename>
The #SELECT command is used to select a specific config and data file pair which should be used by Flasher to program the target. <Filename> specifies the name of file pair without extensions (.CFG and .DAT) on the Flasher which should be selected. If you are using the universal flash programming mode, <Filename> specifies the full name of the .UNI file including the extension. Flasher saves the selected config and data file in the FLASHER.INI file. So this selection is remembered even between power-cycling Flasher.

This may be verfy helpful in cases where several config and data files are stored on Flasher. The user can easily switch between these config and data files without connecting Flasher to a host.

If this command succeeds, Flasher responds with:

#ACK
#OK

Find below a sample sequence which shows how to use the #SELECT command:

#SELECT ATSAM7_1 // ATSAM7_1.CFG and ATSAM7_1.DAT is selected
#ACK
#OK
#AUTO // Start auto programming
#ACK
#STATUS:INITIALIZING
#STATUS:CONNECTING
#STATUS:UNLOCKING
#STATUS:ERASING
#STATUS:PROGRAMMING
#STATUS:VERIFYING
#OK (Total 8.416s, Erase 0.005s, Prog 6.845s, Verify 0.959s)
#SELECT ATSAM7_2 // ATSAM7_2.CFG and ATSAM7_2.DAT is selected
#ACK
#OK
#AUTO // Start auto programming
#ACK
#STATUS:INITIALIZING
#STATUS:CONNECTING
#STATUS:UNLOCKING
#STATUS:ERASING
#STATUS:PROGRAMMING
#STATUS:VERIFYING
#OK (Total 8.632s, Erase 0.005s, Prog 7.051s, Verify 0.969s)

#START
This command can be sent to start the application using the method configured in the J-Flash project.
For U-Flash projects, however, the target application is not necessarily started.
There is often a "start application" checkbox in the U-Flash settings which have to be set for this.

Flasher will reply with the following sequence of messages:

#ACK
#STATUS:INITIALIZING
#STATUS:CONNECTING
#OK (Total 1.148s)

#STATUS
This command can be sent any time, even during other command execution. Flasher responds with its current state. All defined state messages are described under Replies from Flasher.

#VERIFY
This command can used to verify the target flash content against the data stored in Flasher.

#READ
Only available for devices supported by U-Flash.
This command can used to read out flash data.
More information: How to read data using U-Flash

#QUIT
This command can be used to terminate the active telnet connection from the server side (Flasher). The command provides an easy way to terminate the session from an automated script. It is not necessary to parse stdout and switch to local command mode to disconnect. Not implemented in the Flasher ATE or Flasher Hub.

#VERBOSE <Level>
This command can be used to change the verbosity level.

  • Verbosity level 0: Default.
  • Verbosity level 1: Provides some additional messages during the programming process.

File I/O commands

The ASCII interface of the Flasher also supports file I/O operations.


Note:
For information on restrictions for file and directory names, refer to: File system.

The following file I/O commands are supported:

#FCLOSE
The #FCLOSE command closes the file on Flasher which was opened via #FOPEN. After this command has been issued further file I/O operations except #FDELETE are not allowed until the #FOPEN command is send again.

A typical sequence when using the #FCLOSE command does look like as follows:

#FCLOSE
#ACK
#OK


Note:

When using the #FCLOSE command a file has to be open (previously opened by #FOPEN). Otherwise Flasher will respond with the following if no file has been opened:
#ACK

#ERR255:No file opened

#FCRC
The #FCRC command calculates a 32-bit CRC of the given file. This CRC can be used to verify file integrity. This command should not be used while a file has been opened via #FOPEN. The CRC will be also reported by J-Flash when downloading or saving files via J-Flash.

A typical sequence when using the #FCRC command does look like as follows:

#FCRC flasher.dat
#ACK
#OK:0x75BC855A

#FDELETE <Filename>
The #FDELETE command is used to delete a file on Flasher where <Filename> specifies the name of the file.

A typical sequence when using the #FDELETE command does look like as follows:

#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

#FFORMAT
The #FFORMAT command is used to delete all files located in the public area of the Flasher's internal memory.


Note:

Please note that this command deletes all projects located in the public area. Deleted projects cannot be restored again.

This command does not delete the Flasher firmware, neither does it delete files in the secure area.

A typical sequence using the #FFORMAT command does look like as follows:

#FFORMAT
#ACK
#DONE

#FOPEN <Filename>
The #FOPEN command is used to open a file on Flasher for further file I/O operations. <Filename> specifies the file on the Flasher which should be opened. If <Filename> can not be found on Flasher a new one will be created.

A typical sequence using the #FOPEN command does look like as follows:

#FOPEN flasher.dat
#ACK
#OK


Note:

Currently only one file can be open at the same time. If #FOPEN is send and another file is already open, Flasher will respond with:
#ACK

#ERR255:A file has already been opened

#FREAD <Offset>,<NumBytes>
The #FREAD command is used to read data from a file on Flasher. <Offset> specifies the offset in the file, at which data reading is started. <NumBytes> specifies the number of bytes which should be read.

A typical sequence when using the #FREAD command does look like as follows:

#FREAD 0,4
#ACK
#OK:04:466c6173

If the #FREAD command succeeds, Flasher will finally respond with a #OK:<NumBytes>:<Data> reply message. For more information about the Flasher reply messages, please refer to Replies from Flasher.


Note:

In order to use the #FREAD command. A file has to be opened before, via the #FOPEN command. Otherwise Flasher will respond with the following sequence:
#ACK

#ERR255:No file opened

#FSIZE
The #FSIZE command is used to get the size of the currently opened file on Flasher.

A typical sequence when using the #FSIZE command does look like as follows:

#FSIZE
#ACK
#OK:10 // file on flasher which is currently open, has a size of 16 bytes

If the #FSIZE command succeeds, Flasher will respond with a #OK:<Size> reply message. For more information about the Flasher reply messages, please refer to Replies from Flasher.


Note:

In order to use the #FREAD command. A file has to be opened before, via the #FOPEN command. Otherwise Flasher will respond with the following sequence:
#ACK

#ERR255:No file opened

#FWRITE <Offset>,<NumBytes>:<Data>
The #FWRITE command is used to write to a file on Flasher. <Offset> specifies the offset in the file, at which data writing is started. <NumBytes> specifies the number of bytes which are send with this command and which are written into the file on Flasher. <NumBytes> is limited to 512 bytes at once. This means, if you want to write e.g. 1024 bytes, you have to send the #FWRITE command twice, using an appropriate offset when sending it the second time.

<Offset> and <NumBytes> are expected in hexadecimal format.

#FWRITE 0,200:<Data>
#FWRITE 200,200:<Data>

The data is expected in hexadecimal format (two hexadecimal characters per byte). The following example illustrates the use of #FWRITE:

Data to be send: Hello !
ASCII values: 0x48, 0x65, 0x6C, 0x6C, 0x6F, 0x20, 0x21

#FWRITE 0,7:48656C6C6F2021


Note:

In order to use the #FWRITE command a file has to be opened via the #FOPEN command, first. Otherwise Flasher will respond with the following sequence:
#ACK

#ERR255:No file opened

#FLIST
The #LIST command is used to list all files stored on the Flasher.

A typical sequence using the #FLIST command does look like as follows:

#FLIST
#ACK
FLASHER.INI Size: 60
SERIAL.TXT Size: 3
FLASHER.LOG Size: 207
FOLDER (DIR)
FOLDER\\TEST1.CFG Size: 2048
FOLDER\\TEST1.DAT Size: 12288
#OK

#MKDIR <Dirname>
The #MKDIR command is used to create a directory on Flasher. <Dirname> specifies the name of the new directory. <Dirname> may also specify a path to create a subdirectory.

A typical sequence using the #MKDIR command does look like as follows:

#MKDIR folder
#ACK
#OK


Note:

If the directory can not be created because of a bad <Dirname> argument, Flasher will respond with:
#ACK

#ERR255:Failed to create directory

Secure Area Commands

#HASSECUREAREA
The #HASSECUREAREA command checks if the Flasher is configured with a secure area.

#RESULT:YES indicates the secure area is present, #RESULT:NO indicates no secure area is present.

#SECUREAREA
The #SECUREAREA <action> command allows to create or remove the secure area on the Flasher.

  • the action CREATE creates the secure area.
  • the action REMOVE will remove the secure area.

A typical sequence using the #SECUREAREA command does look like as follows:

#SECUREAREA CREATE
#ACK
#DONE


Note:

When creating or removing the secure area, all configuration and data files being stored on the Flasher, are lost.

Please make sure that they are not needed anymore, before adding / removing the security area.


Replies from Flasher

The reply messages from Flasher follow the same data format as commands. Any reply message starts with ASCII start delimiter #, ends with simple carriage return (ASCII code 13) and is sent in uppercase. In contrast to commands, replies can be followed by a descriptive message, which gives more detailed information about the reply. This description is sent in mixed case. The #OK reply, for example, is such a reply. It is followed by a string containing information about the performance time needed for the operations:

#OK (Total 13.993s, Erase 0.483s, Prog 9.183s, Verify 2.514s)

The following reply messages from Flasher are defined:

#ACK
Flasher replies with #ACK message on reception of any defined command before the command itself is executed.

#NACK
Flasher replies with #NACK, if an undefined command was received.

#OK
Flasher replies with #OK, if a command other than #STATUS or #RESULT was executed and ended with no error.

#OK:<NumBytes>:<Data>
Flasher replies with #OK:<Len>:<Data> if a #FREAD command was executed. <NumBytes> is the number of bytes which could be read. This value may differ from the number of requested bytes, for example if more bytes than available, were requested. <NumBytes> and <Data> are send in hexadecimal format (for <Data>: two hexadecimal characters per byte).

#OK:<Size>
Flasher replies if #OK:<Size> if a #FSIZE command has been executed. <Size> is the size (in bytes) of the currently opened file. <Size> is send in hexadecimal format.

#STATUS:
The Flasher replies with its current state.

The following status messages are currently defined:

Message Description
#STATUS:READY Flasher is ready to receive a new command.
#STATUS:CONNECTING Flasher initializes connection to target CPU.
#STATUS:INITIALIZING Flasher performs self check and internal init.
#STATUS:UNLOCKING Unlocking flash sectors.
#STATUS:ERASING Flasher is erasing the flash of the target device.
#STATUS:PROGRAMMING Flasher is programming the flash of the target device.
#STATUS:VERIFYING Flasher verifies the programmed flash contents.

#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 Description
#ERR007 Flasher received #CANCEL command and has canceled the current operation.
#ERR008 Flasher is already busy with execution of previous command.
#ERR009 Failed to allocate memory.
#ERR010 Failed to open file.
#ERR011 Failed to read file.
#ERR012 Failed to write file.
#ERR013 Failed to delete file.
#ERR255 Undefined error occurred. This reply is followed by an error string.

UM08022 Chapters