FreeMASTER Flash Programmer Interface The current version of the FreeMASTER Tool implements a graphical front-end for a custom Flash programming routines. The communication protocol is built solely on top of simple memory-read memory-write access available in any FreeMASTER-enabled project. Two static (global) variables need to be allocated in the embedded application. One is a command-status word (at least one byte in size) used to signal data-ready and operation-completed status of FreeMASTER or embedded side respectively. The next variable is a data buffer used to exchange command parameters and data. See Freescale Application Note AN4860 for an example implementation of the Flash routines with FreeMASTER interface. ///////////////////////////////////////////////////// // Flash Programmer commands / status bytes MSB is // the "COMMAND" bit which forces embedded side operation #define MCB_FPROG_CMD_PENDING #define MCB_FPROG_CMD_32ADDR 0x80 0x08 #define #define #define #define #define (0x00 (0x01 (0x02 (0x03 (0x04 MCB_FPROG_CMD_READ MCB_FPROG_CMD_BCHECK MCB_FPROG_CMD_ERASE MCB_FPROG_CMD_WRITE MCB_FPROG_CMD_BLKINFO // command/status exchange bit // using 32bit address flag | | | | | MCB_FPROG_CMD_PENDING) MCB_FPROG_CMD_PENDING) MCB_FPROG_CMD_PENDING) MCB_FPROG_CMD_PENDING) MCB_FPROG_CMD_PENDING) // flags to be combined with FPROG_CMD_ to specify Flash type #define MCB_FPROG_CMD_FTYPE0 0x00 #define MCB_FPROG_CMD_FTYPE1 0x10 #define MCB_FPROG_CMD_FTYPE2 0x20 #define MCB_FPROG_CMD_FTYPE3 0x30 #define MCB_FPROG_CMD_FTYPE4 0x40 #define MCB_FPROG_CMD_FTYPE5 0x50 #define MCB_FPROG_CMD_FTYPE6 0x60 #define MCB_FPROG_CMD_FTYPE7 0x70 #define MCB_FPROG_CMD_FTYPE(n) (((n)<<4)&0x70) // return status codes (MSB cleared to signal "done" state) #define MCB_FPROG_STS_MASK 0x0f // bits[6:4] in status byte are reserved #define MCB_FPROG_STS_SUCC 0x00 // operation finished successfuly #define MCB_FPROG_STS_FAIL 0x01 // fail: generic fail #define MCB_FPROG_STS_NOACC 0x02 // fail: access denied #define MCB_FPROG_STS_INVPRM 0x03 // fail: invalid parameters passed Command-Status Word Communication 1. The FreeMASTER prepares the data in the statically allocated data buffer in the format outlined below. Size of the “Address” field depends on the MCB_FPROG_CMD_32ADDR bits which will be written below in step 2. “Data Size” specifies the size of “Data Chunk” for WRITE operation. It also specifies the required data size for READ operation or memory block size for ERASE and BCHECK (blank-check) operations. BLKINFO operation is not defined in the current version. Address (2/4 bytes) 2. 3. 4. 5. 6. Data size (2 bytes) Data Chunk (WRITE operation only) The FreeMASTER writes the statically allocated control-status variable. The value byte contains the command number (FPROG_CMD_xxx) and memory type (FPROG_CMD_FTYPE_xxx). Memory type is purely implementation-specific (may identify different kinds of RAM or Flash in the application). The FreeMASTER then starts polling (reading) the control byte and waits until the bit 7 is cleared by the embedded-side. When bit 7 is found cleared, the bits 3:0 contain the success/error status code. On success, when “READ” operation was executed, the FreeMASTER finds the return data in place of the “Data Chunk” in the data buffer. The steps 1-5 are repeated until the whole higher-level operation finishes (e.g. S-Record write operation).