13.8 About getting data to the flash algorithm

Data is passed to the program() function by the data parameter.

A data parameter is an object that provides the following functions:
  • getSize() returns the amount of data available in bytes.
  • getData(sz) returns a buffer of up to sz data bytes. This may be less, for example, at the end of the data. The read position is advanced.
  • seek(pos) move the read position.
  • getUnderlyingFile() gets the file containing the data. (None, if not backed by a file). This allows the method to pass the file to an external tool.
The method can process the data with:
def program(self, regionID, offset, data): 
    data.seek(0) 
    bytesWritten = 0 
    while bytesWritten < data.getSize(): 
        # get next block of data 
        buf = data.getData(self.pageSize) 
 
                  # write buf to flash
                  bytesWritten += len(buf)
Non-ConfidentialPDF file icon PDF versionARM DUI0446W
Copyright © 2010-2015 ARM. All rights reserved.