def get_smartcard_type(ksdkPath, partName): """ Returns smartcard type from feature file : param ksdkPath: Path to KSDK parent directory : param partName: Family name of part """ # FIXME Radka refactor code to avoid circular depedencies another way import ksdkObj directoryStructureHelper = ksdkObj.kinetisSDK(ksdkPath).getDirectoryStructureHelper() featureFile = ksdkPath + directoryStructureHelper.getFeature_hFileLocation(partName, True) smartCardDirect = 0 smartCardUart = 0 with open(featureFile, "rb") as f: for newLine in f: if "FSL_FEATURE_SOC_EMVSIM_COUNT" in newLine: countEndIndex = newLine.rfind(")") smartCardDirect = (int(newLine[countEndIndex - 1 : countEndIndex])) << 8 if "FSL_FEATURE_UART_HAS_SMART_CARD_SUPPORT" in newLine: countEndIndex = newLine.rfind(")") smartCardUart = int(newLine[countEndIndex - 1 : countEndIndex]) f.close() smartType = smartCardDirect | smartCardUart # print 'Smart Type' + str(smartType) return smartType
if __name__ == '__main__': # add SDK path configuration for SDK 2.0 KEx packages batch invoke global SDK_PATH # SDK_PATH need adjust according to your PC environment SDK_PATH = 'D:\\Release\\SDK2.0_Release1\\RC2\\FRDM-K22F_PKG_sdk_2_0_windows_all' #SDK_PATH = '/home/ubuntu09/PartNumber_build_test/KSDK_1.3.0_RC3_Linux' arg_list = sys.argv[1:] if len(arg_list) > 0: SDK_PATH = arg_list[0] # replace the folder path SDK_PATH = kT.string_replace(SDK_PATH, '\\', '/') global sdk_info sdk_info = kSdk.kinetisSDK(SDK_PATH) print 'sdk_info.isNewVersion():' print sdk_info.isNewVersion() base_name = os.path.basename(SDK_PATH) global g_failure_file g_failure_file = open(base_name+FAILURE_LOG_FILE, 'w') g_failure_file.truncate() clean_env() if AUTO_VERIFICATION: load_manifest() # restore the argv, otherwise it will impact the unit test framework sys.argv=[sys.argv[0]] unittest.main()
def mask_features(self, ksdkPath, ksdkVersion, featureList, partName, packName): """ Mask off features based on what is available for this part :param ksdkPath: Absolute path of KSDK installation being used :param ksdkVersion: version of the KSDK being used :param featureList: List of features to be modified :param partName: Name of target part """ # FIXME Radka refactor code to avoid circular depedencies another way import ksdkObj directoryHelper = ksdkObj.kinetisSDK(ksdkPath).getDirectoryStructureHelper() featureFile = ksdkPath + directoryHelper.getFeature_hFileLocation(partName, True) preProc = ["#if", "#elif", "#endif"] portCount = 0 dmaCount = 0 tsiVersion = 0 partFeatures = [] featIndex = 0 lineIndex = 0 preProcType = 4 index = 0 featLine = "/* SOC module features */" defLine = "defined(CPU_" + packName + ")" # Get line where SOC module features begin with open(featureFile, "rb") as f: for index, newLine in enumerate(f): if featLine in newLine: featIndex = index lineIndex = featIndex break f.close() # self.debug_log('Feature start: ' + str(featIndex)) # Get line where the package is defined, if defined with open(featureFile, "rb") as f: for i in xrange(featIndex): f.next() for index, newLine in enumerate(f): if "#if" in newLine: preProcType = preProc.index("#if") elif "#elif" in newLine: preProcType = preProc.index("#elif") if defLine in newLine: if preProcType == preProc.index("#if"): if index > featIndex + 100: lineIndex = featIndex break if preProcType == preProc.index("#elif"): if index > featIndex + 300: lineIndex = featIndex break else: lineIndex = index break f.close() # self.debug_log('Index start: ' + str(lineIndex)) # Begin feature checking from package check to end of section with open(featureFile, "rb") as f: for i in xrange(lineIndex): f.next() for newLine in f: if preProcType < 2: if preProc[preProcType + 1] in newLine: break if "#define FSL_FEATURE_SOC" in newLine: partFeatures.append(newLine) # print newLine f.close() smartCardCnt = 0 smartCardUart = 0 index = 0 while index < len(featureList): isValid = False if featureList[index] == "sai": temp = "_I2S_" elif featureList[index] == "rnga": temp = "_RNG_" elif featureList[index] == "flexbus": temp = "_FB_" elif featureList[index] == "quadtmr": temp = "_TMR_" elif featureList[index] == "qspi": temp = "_QuadSPIO_" elif featureList[index] == "sdramc": temp = "_SDRAM_" elif featureList[index] == "smartcard": temp = "_ENVSIM_" elif featureList[index] == "lmem_cache": temp = "_LMEM_" else: temp = "_" + featureList[index].upper() + "_" # print 'List: ' + temp self.debug_log("List: " + temp) for p in partFeatures: # self.debug_log('File: ' + p) if temp in p: # self.debug_log(p) countEndIndex = p.rfind(")") # self.debug_log(p[countEndIndex - 1:countEndIndex]) insCount = int(p[countEndIndex - 1 : countEndIndex]) if insCount < 1: # self.debug_log('Zero instance') isValid = False else: isValid = True if isValid == False: # self.debug_log('Zero instance') featureList[index] = "N/A" index += 1 isValid = True while isValid: try: featureList.remove("N/A") except ValueError: isValid = False # Check for special features copCount = 0 isIrtc = 0 with open(featureFile, "rb") as f: for newLine in f: if "FSL_FEATURE_SIM_HAS_COP_WATCHDOG" in newLine: countEndIndex = newLine.rfind(")") # self.debug_log(newLine[countEndIndex - 1:countEndIndex]) copCount = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_SOC_PORT_COUNT" in newLine: countEndIndex = newLine.rfind(")") # self.debug_log(p[countEndIndex - 1:countEndIndex]) portCount = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_SOC_DMA_COUNT" in newLine: countEndIndex = newLine.rfind(")") # self.debug_log(p[countEndIndex - 1:countEndIndex]) dmaCount = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_TSI_VERSION" in newLine: countEndIndex = newLine.rfind(")") tsiVersion = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_RTC_IS_IRTC" in newLine: countEndIndex = newLine.rfind(")") isIrtc = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_SOC_EMVSIM_COUNT" in newLine: countEndIndex = newLine.rfind(")") smartCardCnt = int(newLine[countEndIndex - 1 : countEndIndex]) if "FSL_FEATURE_UART_HAS_SMART_CARD_SUPPORT" in newLine: countEndIndex = newLine.rfind(")") smartCardUart = int(newLine[countEndIndex - 1 : countEndIndex]) f.close() if copCount > 0: featureList.append("cop") if isIrtc > 0: tempI = featureList.index("rtc") featureList[tempI] = "irtc" if smartCardCnt > 0: featureList.append("smartcard") if smartCardUart > 0: featureList.append("smartcard") return [portCount, dmaCount, tsiVersion]