Table of Contents |
---|
An alternative to writing applications that use the FlashPro-ARM 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 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 | ||||
---|---|---|---|---|
|
...
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
The operation can be one of the following:
GOTO label <label>
CALL label <label>
LOADCFGFILE filename <filename> - Load configuration file. Provide a full path and filename.
LOADCODEFILE filename <filename> - Load code file. Provide a full path and filename.
APPENDCODEFILE filename <filename> - Append code file. Provide a full path and file name.
LOADSNFILE filename <filename> - Load serial number file. Provide a full path and filename.
PAUSE number <number> - pause a number of milliseconds, between 1 and 100000.
VCCOFF - Turn Vcc OFF from programming adapter to target device.
VCCON - Turn Vcc ON from programming adapter to target device.
Vcc from FPA must be enabled first using configuration file.
VCCINMV <mV> - 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 <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.
OPEN_TARGET - Power-on device, initialize communication, set MCU clock frequency to default for programming.
CLOSE_TARGET - Close communication, and power-down device.
These operations can be used for debugging, control flow, and setting adapter pins:
OPEN_COMMS - Only initialize JTAG/SWD communication, does not affect power or other settings.
SOFT_RESET - Reset using AIRCR register.
HARD_RESET - Reset using hardware RST line.
OPCODE_SETBOOT0HIGH - Set BOOT0 pin high - Pin TEST/TRST (8)
OPCODE_SETBOOT0LOW - Set BOOT0 pin low - Pin TEST/TRST (8)
OPCODE_SETBOOT0FREE - Set BOOT0 pin Tri-State - Pin TEST/TRST (8)
CMP_W_TIMEOUT <timeout> <addr> <mask> <value>- A function that will check a value in a loop until pass value has be found. Useful for waiting for a flag to be set. //while((*addr & mask) != value)) break after timeout or success
The script executor has 8 (eight) uint32_t registers used for internal storage (REG_0-REG_7), and one boolean register for control flow:
SETREG <param1> <param2> - Register PARAM1 (REG_0-REG_7) set with value PARAM2 (uint32_t)
SETBOOL <param1>- bool reg = PARAM1: true/false
INVBOOL - invert bool reg value: no params
MOVEREG <param1> <param2> - move register values - PARAM1 = PARAM2: target reg, source reg
MEMTOREG <param1> <param2> - load target memory to register - PARAM1 = *((uint32_t *)(PARAM2)): address, reg
MEMTOREGGANG <param1> <param2> (GANG only) - load memory from all 6 targets to registers - read from up to 6 targets and save in 6 regs.
Call: MEMTOREGGANG <address> <first reg index (6 in total will be written in series).. REG_start, ...REG_start+5>, i.e.
MEMTOREGGANG 0x1FFF8070 REG_2 - load value at 0x1FFF8070 from each target to registers (REG_2-REG_7)
REGTOMEM <param1> <param2> - save register to address in target - *((uint32_t *)(PARAM2)) = PARAM1 (PARAM1 is register index)
VALTOMEM <param1> <param2> - save value to address in target - *((uint32_t *)(PARAM2)) = PARAM1 (PARAM1 is hex value uint32_t)
PRINTREG <param1> - print uint32_t register value given by index PARAM1 (must be between REG_0-REG_7)
PRINTBOOL - print boolean register value
Register manipulations on the 8 (eight) uint32_t registers used for internal storage (REG_0-REG_7):
ADD <param1> <param2> - Reg[PARAM1] = Reg[PARAM1] + Reg[PARAM2]
SUB <param1> <param2> - Reg[PARAM1} = Reg[PARAM1] - Reg[PARAM2]
MULT <param1> <param2> - Reg[PARAM1} = Reg[PARAM1] * Reg[PARAM2]
AND <param1> <param2> - Reg[PARAM1} = Reg[PARAM1] & Reg[PARAM2]
OR <param1> <param2> - Reg[PARAM1} = Reg[PARAM1] | Reg[PARAM2]
XOR <param1> <param2> - Reg[PARAM1} = Reg[PARAM1] XOR Reg[PARAM2]
SHIFTL <param1> <param2> - Reg[PARAM1] = Reg[PARAM1] << PARAM2 (value)
SHIFTR <param1> <param2> - Reg[PARAM1] = Reg[PARAM1] >> PARAM2 (value)
Register manipulations on boolean register used for control flow:
CMPEQ <param1> <param2> - bool reg = (Reg[PARAM1] == Reg[PARAM2])
CMPNEQ <param1> <param2> - bool reg = (Reg[PARAM1] != Reg[PARAM2])
CMPLT <param1> <param2> - bool reg = (Reg[PARAM1] < Reg[PARAM2])
CMPLTE <param1> <param2> - bool reg = (Reg[PARAM1] <= Reg[PARAM2])
Branch instructions:
BREQ <label> - Jump to label if boolean register is true
BRNEQ <label> - Jump to label if boolean register is false
Standalone instructions:
STANDALONEON - Change adapter to standalone mode (runs from internal adapter memory)
STANDALONEOFF - Change adapter to interactive mode (GUI)
SETIMAGENO <param1> - Select internal adapter image, from 1 to 96, to be used in standalone mode
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 STM-F429ZI.cfg to the FlashPro-ARM Programmer. Configuration file STM-F429ZI.cfg should be prepared before running this script using the main dialog screen.
Load code file test-STM32-64k.txt
Message box asks the user to proceed. The program will halt until OK is pressed.
The FlashPro-ARM 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 test-STM32-1M.txt to the FlashPro-ARM Programmer.
The FlashPro-ARM 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-F429ZI.cfg LOADCODEFILE E:\Elprotronic\CustomerDemos\FlashPro-ARM-STM\test-STM32-64k.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-STM32-1M.txt AUTOPROGRAM GOTO START >finishEND ;======================================================= |
...