Ejemplo n.º 1
0
 def writeBootDeviceMemory(self):
     status, memStart, memBinFile = self._getUserComMemParameters(True)
     if status:
         memStart = self._convertComMemStart(memStart)
         if memStart % self.comMemWriteUnit:
             self.popupMsgBox(
                 'Start Address should be aligned with 0x%x !' %
                 (self.comMemWriteUnit))
             return
         eraseMemStart = misc.align_down(memStart, self.comMemEraseUnit)
         eraseMemEnd = misc.align_up(memStart + os.path.getsize(memBinFile),
                                     self.comMemEraseUnit)
         status, results, cmdStr = self.blhost.flashEraseRegion(
             eraseMemStart, eraseMemEnd - eraseMemStart,
             self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             self.popupMsgBox(
                 'Failed to erase boot device, error code is %d !' %
                 (status))
             return
         shutil.copy(memBinFile, self.userFilename)
         status, results, cmdStr = self.blhost.writeMemory(
             memStart, self.userFilename, self.bootDeviceMemId)
         try:
             os.remove(self.userFilename)
         except:
             pass
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             self.popupMsgBox(
                 'Failed to write boot device, error code is %d, You may forget to erase boot device first!'
                 % (status))
Ejemplo n.º 2
0
 def readBootDeviceMemory( self ):
     status, memStart, memLength = self._getUserComMemParameters(False)
     if status:
         memStart = self._convertComMemStart(memStart)
         alignedMemStart = misc.align_down(memStart, self.comMemReadUnit)
         alignedMemLength = misc.align_up(memLength, self.comMemReadUnit) + self.comMemReadUnit
         if memLength + memStart > alignedMemStart + self.comMemReadUnit:
             alignedMemLength += self.comMemReadUnit
         memFilename = 'comMemRead.dat'
         memFilepath = os.path.join(self.blhostVectorsDir, memFilename)
         status, results, cmdStr = self.blhost.readMemory(alignedMemStart, alignedMemLength, memFilename, self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status == boot.status.kStatus_Success:
             self.clearMem()
             memLeft = memLength
             addr = memStart
             with open(memFilepath, 'rb') as fileObj:
                 fileObj.seek(memStart - alignedMemStart)
                 while memLeft > 0:
                     contentToShow, memContent = self._getOneLineContentToShow(addr, memLeft, fileObj)
                     memLeft -= len(memContent)
                     addr += len(memContent)
                     self.printMem(contentToShow)
         else:
             self.popupMsgBox('Failed to read boot device, error code is %d !' %(status))
Ejemplo n.º 3
0
 def readBootDeviceMemory( self ):
     status, memStart, memLength = self._getUserComMemParameters(False)
     if status:
         memStart = self._convertComMemStart(memStart)
         alignedMemStart = misc.align_down(memStart, self.comMemReadUnit)
         alignedMemLength = misc.align_up(memLength, self.comMemReadUnit)
         if memLength + memStart > alignedMemStart + alignedMemLength:
             alignedMemLength += self.comMemReadUnit
         memFilename = 'commonDataFromBootDevice.dat'
         memFilepath = os.path.join(self.blhostVectorsDir, memFilename)
         status, results, cmdStr = self.blhost.readMemory(alignedMemStart, alignedMemLength, memFilename, self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status == boot.status.kStatus_Success:
             self.clearMem()
             if not self.needToSaveReadbackImageData():
                 memLeft = memLength
                 addr = memStart
                 with open(memFilepath, 'rb') as fileObj:
                     fileObj.seek(memStart - alignedMemStart)
                     while memLeft > 0:
                         contentToShow, memContent = self.getOneLineContentToShow(addr, memLeft, fileObj)
                         memLeft -= len(memContent)
                         addr += len(memContent)
                         self.printMem(contentToShow)
             else:
                 self.tryToSaveImageDataFile(memFilepath)
         else:
             if self.languageIndex == uilang.kLanguageIndex_English:
                 self.popupMsgBox('Failed to read boot device, error code is %d !' %(status))
             elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                 self.popupMsgBox(u"读取启动设备失败,错误的代码是 %d !" %(status))
             else:
                 pass
Ejemplo n.º 4
0
 def eraseBootDeviceMemory( self ):
     status, memStart, memLength = self._getUserComMemParameters(False)
     if status:
         memStart = self._convertComMemStart(memStart)
         alignedMemStart = misc.align_down(memStart, self.comMemEraseUnit)
         alignedMemLength = misc.align_up(memLength, self.comMemEraseUnit)
         if memLength + memStart > alignedMemStart + self.comMemEraseUnit:
             alignedMemLength += self.comMemEraseUnit
         status, results, cmdStr = self.blhost.flashEraseRegion(alignedMemStart, alignedMemLength, self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             self.popupMsgBox('Failed to erase boot device, error code is %d !' %(status))
Ejemplo n.º 5
0
 def writeBootDeviceMemory(self):
     status, memStart, memBinFile = self._getUserComMemParameters(True)
     if status:
         memStart = self._convertComMemStart(memStart)
         if memStart % self.comMemWriteUnit:
             if self.languageIndex == uilang.kLanguageIndex_English:
                 self.popupMsgBox(
                     'Start Address should be aligned with 0x%x !' %
                     (self.comMemWriteUnit))
             elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                 self.popupMsgBox(u"起始地址应该以 0x%x 对齐!" %
                                  (self.comMemWriteUnit))
             else:
                 pass
             return
         eraseMemStart = misc.align_down(memStart, self.comMemEraseUnit)
         eraseMemEnd = misc.align_up(memStart + os.path.getsize(memBinFile),
                                     self.comMemEraseUnit)
         status, results, cmdStr = self.blhost.flashEraseRegion(
             eraseMemStart, eraseMemEnd - eraseMemStart,
             self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             if self.languageIndex == uilang.kLanguageIndex_English:
                 self.popupMsgBox(
                     'Failed to erase boot device, error code is %d !' %
                     (status))
             elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                 self.popupMsgBox(u"擦除启动设备失败,错误的代码是 %d !" % (status))
             else:
                 pass
             return
         shutil.copy(memBinFile, self.userFilename)
         status, results, cmdStr = self.blhost.writeMemory(
             memStart, self.userFilename, self.bootDeviceMemId)
         try:
             os.remove(self.userFilename)
         except:
             pass
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             if self.languageIndex == uilang.kLanguageIndex_English:
                 self.popupMsgBox(
                     'Failed to write boot device, error code is %d, You may forget to erase boot device first!'
                     % (status))
             elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                 self.popupMsgBox(u"写入启动设备失败,错误的代码是 %d ,请确认是否先擦除了启动设备!" %
                                  (status))
             else:
                 pass
Ejemplo n.º 6
0
 def eraseBootDeviceMemory( self ):
     status, memStart, memLength = self._getUserComMemParameters(False)
     if status:
         memStart = self._convertComMemStart(memStart)
         alignedMemStart = misc.align_down(memStart, self.comMemEraseUnit)
         alignedMemLength = misc.align_up(memLength, self.comMemEraseUnit)
         if memLength + memStart > alignedMemStart + alignedMemLength:
             alignedMemLength += self.comMemEraseUnit
         status, results, cmdStr = self.blhost.flashEraseRegion(alignedMemStart, alignedMemLength, self.bootDeviceMemId)
         self.printLog(cmdStr)
         if status != boot.status.kStatus_Success:
             if self.languageIndex == uilang.kLanguageIndex_English:
                 self.popupMsgBox('Failed to erase boot device, error code is %d !' %(status))
             elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                 self.popupMsgBox(u"擦除启动设备失败,错误的代码是 %d !" %(status))
             else:
                 pass
Ejemplo n.º 7
0
 def readRamMemory(self):
     status, memStart, memLength, dummyArg = self._getUserComMemParameters(
         False)
     if status:
         if (self.mcuSeries in uidef.kMcuSeries_iMXRTyyyy and self.isInTheRangeOfFlexram(memStart, memLength)) or \
             (self.mcuSeries == uidef.kMcuSeries_iMXRTxxx and self.isInTheRangeOfSram(memStart, memLength)) or \
             (self.mcuSeries == uidef.kMcuSeries_LPC and self.isInTheRangeOfSramx(memStart, memLength)) or \
             (self.mcuSeries == uidef.kMcuSeries_Kinetis and self.isInTheRangeOfSram(memStart, memLength)):
             alignedMemStart = misc.align_down(memStart, 0x10)
             alignedMemLength = misc.align_up(memLength, 0x10)
             if memLength + memStart > alignedMemStart + alignedMemLength:
                 alignedMemLength += 0x10
             memFilename = 'commonDataFromRam.dat'
             memFilepath = os.path.join(self.blhostVectorsDir, memFilename)
             status, results, cmdStr = self.blhost.readMemory(
                 alignedMemStart, alignedMemLength, memFilename)
             self.printLog(cmdStr)
             if status == boot.status.kStatus_Success:
                 self.clearMem()
                 memLeft = memLength
                 addr = memStart
                 with open(memFilepath, 'rb') as fileObj:
                     fileObj.seek(memStart - alignedMemStart)
                     while memLeft > 0:
                         contentToShow, memContent = self.getOneLineContentToShow(
                             addr, memLeft, fileObj)
                         memLeft -= len(memContent)
                         addr += len(memContent)
                         self.printMem(contentToShow)
                 self.tryToSaveImageDataFile(memFilepath)
             else:
                 if self.languageIndex == uilang.kLanguageIndex_English:
                     self.popupMsgBox(
                         'Failed to read RAM, error code is %d .' %
                         (status))
                 elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                     self.popupMsgBox(u"读取FlexRAM失败,错误的代码是 %d 。" % (status))
                 else:
                     pass
         else:
             self.popupMsgBox(
                 uilang.kMsgLanguageContentDict['operImgError_notInRam'][
                     self.languageIndex])
Ejemplo n.º 8
0
    def eccWriteBootDeviceMemory(self):
        if self.bootDeviceMemId != rundef.kBootDeviceMemId_FlexspiNor:
            if self.languageIndex == uilang.kLanguageIndex_English:
                self.popupMsgBox('ECC-write is only for FlexSPI NOR device!')
            elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                self.popupMsgBox(u"ECC方式写入仅支持 FlexSPI NOR 设备!")
            else:
                pass
            return

        if self.tgt.hasFlexspiNorEcc == None or self.tgt.hasFlexspiNorEcc != True:
            if self.languageIndex == uilang.kLanguageIndex_English:
                self.popupMsgBox(
                    'ECC-write is not supported by this MCU device!')
            elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                self.popupMsgBox(u"ECC方式写入在当前 MCU 型号上不被支持!")
            else:
                pass
            return

        status, memStart, memBinFile, useFlashImageCmd = self._getUserComMemParameters(
            True)
        if status:
            if useFlashImageCmd:
                if self.languageIndex == uilang.kLanguageIndex_English:
                    self.popupMsgBox(
                        'Image file format can only be binary(.bin) for ECC write!'
                    )
                elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                    self.popupMsgBox(u"ECC方式写入时,程序镜像文件格式仅支持 .bin 格式!")
                else:
                    pass
            else:
                memStart = self._convertComMemStart(memStart)
                if memStart % memdef.kXeccRegionAlignmentUnit:
                    if self.languageIndex == uilang.kLanguageIndex_English:
                        self.popupMsgBox(
                            'ECC Start Address should be aligned with 0x%x !' %
                            (memdef.kXeccRegionAlignmentUnit))
                    elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                        self.popupMsgBox(u"ECC写入起始地址应该以 0x%x 对齐!" %
                                         (memdef.kXeccRegionAlignmentUnit))
                    else:
                        pass
                    return
                eraseMemStart = misc.align_down(
                    memStart, memdef.kXeccRegionAlignmentUnit)
                eraseMemEnd = misc.align_up(
                    memStart + os.path.getsize(memBinFile),
                    memdef.kXeccRegionAlignmentUnit)
                status, results, cmdStr = self.blhost.flashEraseRegion(
                    eraseMemStart, (eraseMemEnd - eraseMemStart) * 2,
                    self.bootDeviceMemId)
                self.printLog(cmdStr)
                if status != boot.status.kStatus_Success:
                    if self.languageIndex == uilang.kLanguageIndex_English:
                        self.popupMsgBox(
                            'Failed to erase boot device, error code is %d !' %
                            (status))
                    elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                        self.popupMsgBox(u"擦除启动设备失败,错误的代码是 %d !" % (status))
                    else:
                        pass
                    return
                status, results, cmdStr = self.blhost.setProperty(
                    boot.properties.kPropertyTag_FlashXeccWriteState, 1)
                self.printLog(cmdStr)
                if (status == boot.status.kStatus_Success):
                    shutil.copy(memBinFile, self.userFilename)
                    status, results, cmdStr = self.blhost.writeMemory(
                        memStart, self.userFilename, self.bootDeviceMemId)
                    try:
                        os.remove(self.userFilename)
                    except:
                        pass
                    self.printLog(cmdStr)
                    if status != boot.status.kStatus_Success:
                        if self.languageIndex == uilang.kLanguageIndex_English:
                            self.popupMsgBox(
                                'Failed to write boot device, error code is %d, You may forget to erase boot device first!'
                                % (status))
                        elif self.languageIndex == uilang.kLanguageIndex_Chinese:
                            self.popupMsgBox(
                                u"ECC方式写入启动设备失败,错误的代码是 %d ,请确认是否先擦除了启动设备!" %
                                (status))
                        else:
                            pass
                status, results, cmdStr = self.blhost.setProperty(
                    boot.properties.kPropertyTag_FlashXeccWriteState, 0)
                self.printLog(cmdStr)