Flashfile App Own Algorithm
Flashfile App Own Algorithm
Flashfile App Own Algorithm
TRACE32 Directory
TRACE32 Index
Version 25-Oct-2019
FLASHFILE Programming
• You need to write a programming routine that runs on the target processor.
• RAM for data buffer, argument buffer, and stack is required on the target.
1. Develop the “GETID/SAVE/LOAD/ERASE” functions which will run on the target processor.
FLASHFILE.CONFIG … and
FLASHFILE.TARGET …
These commands will call the flash algorithm file routine with the appropriate parameters.
There are two commands which inform the debugger about the flash configuration and the prepared
programming routine: FLASHFILE.CONFIG and FLASHFILE.TARGET
FLASHFILE.TARGET: This command informs the debugger about the start address range
(0x3000000++0x1FFF) of the flash algorithm file (./own_flash.bin), about the data range
(0x30002000++0x1FFF) for the parameter block (size: 64bytes) plus the data buffer (size: 0x2000 -
parameter block).
The data range must be bigger than the flash size of “64byte (param.) + 1page + 256byte (stack)”. The data
buffer size can be selected by the user. It determines the maximum number of bytes which are handled on
one programming routine call. If the command is executed, then the debugger loads the
“own_algorithm_file” to the start address and internally sets the software breakpoint code at the end of the
code.
GETID:
If the command FLASHFILE.GETID is entered, then the debugger loads the parameter data (parameter
block), sets the program counter to the start address of the routine and starts the program execution.
If the execution has reached the end of the code which is the software breakpoint code, and if the return
information is OK, then the host TRACE32 takes the flash ID / type / page size / block size information, i.e.
the values from the algorithm file.
If the command FLASHFILE.SAVE is entered, then the debugger loads the parameter data (parameter
block), sets the program counter to the start address of the routine and starts the program execution.
If the execution has reached the end of the code which is the software breakpoint code, then the host
TRACE32 checks the return information (see parameter block), and if the return information is OK, then the
host TRACE32 takes data buffer contents as flash data.
If the command FLASHFILE.LOAD is entered, the debugger loads the data buffer with (part of) the
programming data, initializes the parameter block, sets the program counter to the start address of the
routine and starts the program execution.
If the execution has reached the end of the code, then the host TRACE32 checks the return information (see
parameter block) and if the return information is OK, then the host TRACE32 repeats the same load
procedure for the remaining data.
ERASE:
If the command FLASHFILE.Erase is entered, the host TRACE32 loads the parameter block with the
defined erasing address range and executes the erase function in the flash algorithm file. Then the host
TRACE32 checks the return information.
The parameter block consists of 8 unsigned long long (8x64Bit; target byte order) and is used to pass
information to/from the target programming routine. The debugger is informed about the start address by
these commands:
When the above commands are being executed, then this parameter block is set on the target controller:
FLASHFILE.ERASE <start_address>++<size>
4 reserv -
7 command When executed, the command (refer to the table below) will
set the value from the column to the right.
Command Value
FLASHFILE.SAVE(FLASHFILE.DUMP) 0x11
FLASHFILE.ERASE 0x13
FLASHFILE.UNLOCK 0x14
FLASHFILE.LOAD 0x18
FLASHFILE.GETID 0x20
After the algorithm file has finished, the parameter block below returns this information to the debugger:
0 - not valid
1 - reserved
2 - not valid
3 - reserved
5 - not valid
6 - reserved
Situation:
We have a NAND flash (page size 0x800, block size 0x20000) on the target processor. It is controlled only
by the Nand Flash Controller Registers:
We have prepared the flash programming routine named “flashprog.bin” (size: 0x1450H bytes; format
binary). So we can use half of the memory for the code (0x2000_0000++0x1FFF), and the other half for the
data (0x2000_2000++0x1FFF).
This function expects the parameter block in SRAM at address 0x2000_2000H followed by the data buffer
for programming and reading data.
We want to load our application program “application.bin” (size 1.0 MByte; format binary; located 0x1000- ...)
into the flash.
Required actions:
It is recommended to do the following steps in a PRACTICE script file (*.cmm) to automate these settings:
1. Make the required settings. Especially configure the flash controller and S(D)RAM.
2. Inform the debugger about the flash controller register, and location of the algorithm file routine,
parameter block and data buffer:
FLASHFILE.RESet
// <cmd_reg> <addr_reg> <data_reg>
FLASHFILE.CONFIG 0x61400000 0x61200000 0x61000000
3. Get the ID values, page size, block size, and the NAND Flash ID from the flash device:
AREA.view
FLASHFILE.GETID
FLASHFILE.GETID
When FLASHFILE.GETID is executed, the programming routine will be started without valid content in the
data buffer and with the following data in the parameter block:
0x2000_2000
0 -
1 0x61400000 H
2 0x61200000 H
3 0x61000000 H
4 -
5 0x40 (size of data to read)
6 0
7 0x20 command: FLASHFILE.GETID
The programming routine returns the control to the debugger and sets the following parameter in the
parameter block and data buffer for use by the host TRACE32:
0x2000_2000 H
0 -
1 -
2 -
3 -
4 -
5 -
6 -
7 <status> status: 0: no error; >10: error
FLASHFILE.SAVE
When FLASHFILE.SAVE aaa.bin 0x1000++0xFFFF is executed, the programming routine will be started
without valid content in the data buffer and with the following data in the parameter block:
The programming routine returns the control to the debugger and sets the following parameter in the
parameter block and data buffer:
0x2000_0000 H
0 -
1 -
2 -
3 -
4 -
5 -
6 -
7 <status> status: 0: no error; >10: error
data buffer
0x2000_0040--0x2000_17FF the flash memory contents
FLASHFILE.Erase
When FLASHFILE.Erase 0x1000++0xFFFFF is executed, the programming routine will be started without
valid content in the data buffer and with the following data in the parameter block:
0 0x1000
1 0x61400000 H
2 0x61200000 H
3 0x61000000 H
4 -
5 0x100000 ( size of data to read )
6 0
7 0x19 command: FLASHFILE.Erase /EraseBadBlocks
The programming routine returns the control to the debugger and sets the following parameter in the
parameter block and data buffer:
0x2000_0000 H
0 -
1 -
2 -
3 -
4 -
5 -
6 -
7 <status> status: 0: no error; >10: error
data buffer
0x2000_0040--0x2000_17FF (the application.bin contents)
The programming routine returns the control to the debugger and sets the following parameter in the
parameter block and data buffer:
0x2000_0000
0 -
1 -
2 -
3 -
4 -
5 -
6 -
7 <status> status: 0: no error; >10: error
Then the flash algorithm file repeats these steps until all data is programmed (example: 0x1000++0xFFFFF
or 0x1000--0x100FFF) or an error occurred.