def test_access_flash_erase_region(self, bl):
     #get sector size and the last sector start address of flash
     startAddress, length = common_util.get_start_address_and_length(bl, 1, 'Sectors', 'flash', 'EndOfMemory') 
     # erase the sector
     status, result = bl.flash_erase_region(startAddress, length)
     assert status == bootloader.status.kStatus_Success
     #fill 0x00 to one sector    
     status, result = bl.fill_memory(startAddress, length, 0x00)
     assert status == bootloader.status.kStatus_Success 
     # use FTFx module to reliaze erase one sector
     flash_erase_one_sector(bl, startAddress) 
     # verify the sector has been erased successfully
     time.sleep(1)
     verify_memory(bl, startAddress, length, 0xFF)
   def test_access_flash_fill(self, bl):
       file = file_path(bl);
       #get sector size and the last sector start address of flash
       startAddress, length = common_util.get_start_address_and_length(bl, 1, 'Sectors', 'flash', 'EndOfMemory')   
       # erase the sector
       status, result = bl.flash_erase_region(startAddress, length)
       assert status == bootloader.status.kStatus_Success
               
       length = 0x20
       pattern = 0x30
       #use FTFX to fill data length 0x20 , content 0x20 to the memory
       flash_fill(bl, startAddress, pattern, length)
       # verify         
       time.sleep(1)
       verify_memory(bl, startAddress, length, pattern)
 
 
         
示例#3
0
def flash_erase_region_according_to_parameters(bl, length, lengthType,
                                               locationType):
    # Get actual start address and byte count to be filled
    startAddress, actualLength = common_util.get_start_address_and_length(
        bl, length, lengthType, 'flash', locationType)
    status, results = bl.flash_erase_region(startAddress, actualLength)
    # Get the location of a given block
    locationStatus = common_util.block_location(bl, startAddress, actualLength,
                                                'flash')
    if locationStatus == common_util.kInvalidParameter:
        assert status != bootloader.status.kStatus_Success
    elif locationStatus == common_util.kZeroSizeBlock:
        assert status == bootloader.status.kStatus_Success
    elif locationStatus == common_util.kInvalidMemoryRange:
        assert status == bootloader.status.kStatusMemoryRangeInvalid
    elif locationStatus == common_util.kValidMemoryRange:
        if startAddress % bl.target.eraseAlignmentSize == 0 and actualLength % bl.target.eraseAlignmentSize == 0:
            assert status == bootloader.status.kStatus_Success
        elif startAddress % bl.target.eraseAlignmentSize > 0 or actualLength % bl.target.eraseAlignmentSize > 0:
            assert status == bootloader.status.kStatus_FlashAlignmentError
def read_memory_according_to_parameters(bl, length, lengthType, memType,
                                        locationType):
    # 1. Get actual start address and byte count to be read
    startAddress, actualLength = common_util.get_start_address_and_length(
        bl, length, lengthType, memType, locationType)
    # 2. Read data from memory by read-memory command.
    command_read_data_file = os.path.join(bl.vectorsDir,
                                          'read_data_from_memory.bin')
    status, results = bl.read_memory(startAddress, actualLength,
                                     command_read_data_file)
    # 3. Give the return value according to parameters.
    memoryStartAddress, memoryEndAddress = common_util.get_memory_start_end_address(
        bl, memType)
    endAddress = startAddress + actualLength - 1
    if actualLength == 0:
        assert status == bootloader.status.kStatus_Success
    elif ((startAddress >= memoryStartAddress)
          and (endAddress <= memoryEndAddress)):
        assert status == bootloader.status.kStatus_Success
    else:
        assert status == bootloader.status.kStatusMemoryRangeInvalid
def fill_memory_according_to_parameters(bl, length, lengthType, memType,
                                        locationType):
    # Get actual start address and byte count to be filled
    startAddress, actualLength = common_util.get_start_address_and_length(
        bl, length, lengthType, memType, locationType)
    status, results = bl.fill_memory(startAddress, actualLength, kFilledValue,
                                     'word')
    # Get the location of a given block
    locationStatus = common_util.block_location(bl, startAddress, actualLength,
                                                memType)
    if locationStatus == common_util.kInvalidParameter:
        assert status != bootloader.status.kStatus_Success
    elif locationStatus == common_util.kZeroSizeBlock:
        assert status == bootloader.status.kStatus_Success
    elif locationStatus == common_util.kInvalidMemoryRange:
        assert status == bootloader.status.kStatusMemoryRangeInvalid
    elif locationStatus == common_util.kValidMemoryRange:
        if startAddress % bl.target.programAlignmentSize == 0 or memType == 'ram':
            assert status == bootloader.status.kStatus_Success
        elif startAddress % bl.target.programAlignmentSize > 0:
            assert status == bootloader.status.kStatus_FlashAlignmentError
def write_memory_according_to_parameters(bl, length, lengthType, memType,
                                         locationType):
    # Get actual start address and byte count to be written.
    startAddress, actualLength = common_util.get_start_address_and_length(
        bl, length, lengthType, memType, locationType)
    # Create a random file which contains actualLength bytes.
    randomFile = common_util.generate_random_data_file(bl, startAddress,
                                                       actualLength)
    # Write file to memory
    status, results = bl.write_memory(startAddress, randomFile)
    # Get the location of a given block.
    locationStatus = common_util.block_location(bl, startAddress, actualLength,
                                                memType)
    if locationStatus == common_util.kInvalidParameter:
        assert status != bootloader.status.kStatus_Success
    elif locationStatus == common_util.kZeroSizeBlock:
        assert status == bootloader.status.kStatus_Success
    elif locationStatus == common_util.kInvalidMemoryRange:
        assert status == bootloader.status.kStatusMemoryRangeInvalid
    elif locationStatus == common_util.kValidMemoryRange:
        if startAddress % bl.target.programAlignmentSize == 0 or memType == 'ram':
            assert status == bootloader.status.kStatus_Success
        elif startAddress % bl.target.programAlignmentSize > 0:
            assert status == bootloader.status.kStatus_FlashAlignmentError
def get_backup_address(bl):
    startAddress, length = common_util.get_start_address_and_length(
        bl, 1, 'AllMemory', 'flash', 'StartOfMemory')
    backUpAddress = length / 2 + bl.target.BL_APP_VECTOR_TABLE_ADDRESS
    print 'backUpAddress:', hex(backUpAddress)
    return backUpAddress