Table of Contents |
---|
An alternative to writing applications that use the FlashPro-ARM M DLL, some programming sequences can be written using a script file. A script file is a text file with basic syntax that can execute all buttons available, and has rudimentary flow control such as IFs and GOTOs. Generally, buttons available on the main dialog can be used in the script file; however, other options available on screens like memory options, serialization etc., can only be changed by loading a different configuration file. A typical script file will start by loading a configuration file and code file, followed by Auto Program and an IF statement to test Auto Program result to decide what happens afterwards.
The script file can be selected in the GUI, or appended as a parameter for the FlashPro-ARM M executable (usually used to create shortcuts that call a specified script file right away):
press the "Script" button in the main dialog, and
append the option -rf <script file> to the executable.
Anchor | ||||
---|---|---|---|---|
|
...
10.1 Script button
The "Script" button is the dynamically programmable device action button that takes a selected script file and executes it. The Script button has a name "Script – none" (Figure 1110.1) if the script file is not defined or Script: <script file> when the script file is selected (Figure 1110.2). When the Script button is pressed and the script file not defined, the Open File dialog will be used to select a script file. When the Script file button is pressed and the script file is defined, the script till be executed. After that, a new script file can only be loaded using the pull down menu File→Open Script File.
The Script button is very useful for implementing a short programming sequence not present directly in the Device Action group buttons. Below is a sample script used for downloading two different code files to a target device - first code used for hardware test, and second code is the final user code. The same sequence
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
Code Block | ||
---|---|---|
| ||
;-------------------------------------------------------------------------- ; easy script file; ;-------------------------------------------------------------------------- LOADCFGFILE C:\Program Files (x86)\Elprotronic\ARM8-32b-MCU\FlashPro-ARMM\test.cfg LOADCODEFILE C:\Program Files (x86)\Elprotronic\ARM8-32b-MCU\FlashPro-ARMM\code.txt AUTOPROGRAM IF FAILED GOTO finish ; now the hardware is tested according to downloaded firmware MESSAGEBOX YESNO "Press YES when the test finished successfully." "Press NO when the test failed." IF BUTTONNO GOTO finish LOADCFGFILE C:\Program Files (x86)\Elprotronic\ARM8-32b-MCU\FlashPro-ARMM\final.cfg LOADCODEFILE C:\Program Files (x86)\Elprotronic\ARM\FlashPro-ARM8-32b-MCU\FlashPro-M\code.txt AUTOPROGRAM >finish END ;-------------------------------------------------------------------------- |
The script file above loads the first configuration file and the first code file into the programmer's data structures. The Auto Program function will flash the selected code file into the selected MCU based on given configuration settings. If the wrong MCU is selected, Vcc too low, or any of the Auto Program features fail, then the function will not succeed. The user can insert an "IF DONE" or "IF FAILED" line to interpret the Auto Program result. The script file then follows with a message box that lets the user decide if the final code should be programmed. If NO is clicked, the GOTO statement will jump to the "finish" label denoted by the special character ">". Some users add protection settings to disable debug access in the final Auto Program configuration to protect their code from end-user access, the specifics of which depend on the target MCU.
Before running the script file the configuration files named test.cfg and final.cfg required in the setup should be created using the GUI software first. To do that connect target devices to programming adapter, select desired configuration and save the configuration file as test.cfg and create final configuration file in a similar way.
Anchor | ||||
---|---|---|---|---|
|
...
10.2 Script file option
The script file can be automatically loaded by appending the option -rf <script file> to the executable file (described in the "Setup and Image Load and Save" chapter in more detail).
Briefly, when the executable FlashPro-ARMM.exe is called with a script file as an option,
FlashPro-ARMM.exe – rf C:\Program Files (x86)\Elprotronic\ARM8-32b-MCU\FlashPro-ARMM\script.txt
access to other buttons is blocked. When the selected script file sequence is finished then the FlashPro-ARM M GUI will close. There is not option to modify the running sequence when script sequence is used. This option can be useful in production since operators will not be able to modify prepared sequences.
Anchor | ||||
---|---|---|---|---|
|
...
10.2.1 Script Limitations
Up to a total of 1000 command lines can be used. Empty lines and comments are ignored.
The stack supports a call depth of up to 50 CALLs (CALL inside CALL inside CALL...).
Anchor | ||||
---|---|---|---|---|
|
...
10.2.2 Command Syntax
White spaces before instructions, labels, and comments are ignored.
; - start of a comment. All characters in the same line after the start of a comment are ignored.
...
A line with a label cannot also contain a command or another label.
For example, this would be illegal >START VCCOFF
Anchor | ||||
---|---|---|---|---|
|
...
10.2.3 Instructions
MESSAGE - message declaration. Contents must be placed between quotes below message declaration. Maximum of 50 content lines. Example:
...
VCCINMV - Set Vcc in mV, from 1800 to 4000, in steps of 100.
RESET - Perform hard RESET function from main dialog screen, requires connected RST line.
AUTOPROGRAM - Perform "AUTO PROG." function from main dialog screen.
VERIFYACCESS - Perform "VERIFY ACCESS" function from main dialog screen.
ERASEFLASH - Perform "ERASE FLASH" function from main dialog screen.
BLANKCHECK - Perform "BLANK CHECK" function from main dialog screen.
WRITEFLASH - Perform "WRITE FLASH" function from main dialog screen.
VERIFYFLASH - Perform "VERIFY FLASH" function from main dialog screen.
READFLASH - Perform "READ FLASH" function from main dialog screen.
READSN – Read serial number and label only.
LOCK - Perform "Lock Device" function from main dialog screen.
UNLOCK - Perform "Clear Locked Device" function from main dialog screen.
TRACEON filename - Enable tracing and log to the selected filename. This option is useful for debugging. The trace file will contain the sequence of all executed commands ran from the script file annotated with line numbers. Line numbers are counted without empty lines and without lines only containing comments.
TRACEOFF - Disable tracing.
END - End of script.
Below is an example of a script that executes the following sequence of commands:
Label START is created.
Vcc from programmer to target device is turned OFF.
Message box notifies the user of Vcc setting and asks for permission to proceed with buttons OK and CANCEL. The program will halt here until a button is pressed.
If CANCEL was pressed then GOTO finish label (ends the script).
If OK was pressed then load configuration file
...
MX25L51245G-
...
128k.cfg to the FlashPro-
...
M Programmer. Configuration file STM-F429ZI.cfg should be prepared before running this script using the main dialog screen.
Load code file
...
0base-128k.sflash.txt
Message box asks the user to proceed. The program will halt until OK is pressed.
The FlashPro-
...
M Programmer will program the target device using the "AUTO PROG." function.
Message box asks the user if the test succeeded giving a YES or NO choice. This demo assumes that the first code file is test code that can evaluate the target board for proper functionality.
If NO was pressed then GOTO START label (start of script).
If YES was then load code file
...
0base-
...
1M.sflash.txt to the FlashPro-
...
M Programmer.
The FlashPro-
...
M Programmer will program the target device using the "AUTO PROG." function.
Script jumps to the beginning using GOTO START. This can be used to wait for the next target device to be connected.
Label finish is created.
Script ends.
Code Block | ||
---|---|---|
| ||
;===================================================== ; Script file - demo program ;----------------------------------------------------- >START VCCOFF MESSAGEBOX OKCANCEL "VCC if OFF now. Connect the test board." "When ready press the button:" " " "OK - to test the board" "CANCEL - to exit from program" IF BUTTONCANCEL GOTO finish LOADCFGFILE E:\Elprotronic\CustomerDemos\FlashPro-ARM-STM\STM-F429ZIMX25L51245G-128k.cfg LOADCODEFILE E:\Elprotronic\CustomerDemos\FlashPro-ARM-STM\test-STM32-64k0base-128k.sflash.txt MESSAGEBOX OK "Press OK to download the test program." AUTOPROGRAM MESSAGEBOX YESNO "Press YES when the test finished successfully." "Press NO when the test failed." IF BUTTONNO GOTO START LOADCODEFILE E:\Elprotronic\CustomerDemos\FlashPro-ARM-STM\test-STM320base-1M.sflash.txt AUTOPROGRAM GOTO START >finishEND ;======================================================= |
...