def gen_debug(self, ksdkProj): """ Generate debug launch files """ # Get relative path kdsPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/kds' if not 'MKL' in self.device[2]: tree = ET.ElementTree(ET.fromstring(kF.project_board_debug_cmsisdap_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' debug cmsisdap.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) tree = ET.ElementTree(ET.fromstring(kF.project_board_release_cmsisdap_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' release cmsisdap.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) tree = ET.ElementTree(ET.fromstring(kF.project_board_debug_jlink_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' debug jlink.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) kT.replace_name_in_file(launchPath, 'jlinkDEVICE', self.device[0]) tree = ET.ElementTree(ET.fromstring(kF.project_board_release_jlink_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' release jlink.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) kT.replace_name_in_file(launchPath, 'jlinkDEVICE', self.device[0]) tree = ET.ElementTree(ET.fromstring(kF.project_board_debug_pne_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' debug pne.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) kT.replace_name_in_file(launchPath, 'pneDEVICE', kT.string_replace(self.device[0][1:], 'xxx', 'M')) tree = ET.ElementTree(ET.fromstring(kF.project_board_release_pne_launch)) launchPath = kdsPath + '/' + self.name + '_' + self.device[2] + ' release pne.launch' tree.write(launchPath, "UTF-8") newStr = self.name + '_' + self.device[2] oldStr = 'project_board' kT.replace_name_in_file(launchPath, oldStr, newStr) kT.replace_name_in_file(launchPath, 'pneDEVICE', kT.string_replace(self.device[0][1:], 'xxx', 'M')) return
def verify_project_file(self, toolchain, file_name_reg, search_key, folder_root): folder_root = os.path.join(folder_root, toolchain) folder_root = kT.string_replace(folder_root, '\\', '/') msg = "Didn't generate " + toolchain + " project folder: " + folder_root if os.path.exists(folder_root) != True: self.record_failure(msg) if ASSERT: self.assertEqual(os.path.exists(folder_root), True, msg) else: return is_found = False for item in os.listdir(folder_root): if DEBUG: print item if re.match(file_name_reg, item): is_found = True is_match_key = self.verify_file_content(os.path.join(folder_root, item), search_key) msg = "Wrong project file generated, the platform name does not match " \ + search_key + " in " + os.path.join(folder_root, item) if False == is_match_key: self.record_failure(msg) if ASSERT: self.assertNotEqual(is_match_key, False, msg) break msg = "Didn't find the project file in: " + folder_root if False == is_found: self.record_failure(msg) if ASSERT: self.assertNotEqual(is_found, False, msg)
def gen_wkspace(self, ksdkProj): """ Generate the uvmpw files for Keil project :param ksdkProj: Instance of a KSDK project """ # Get relative path mdkPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/mdk' relPath = '' if self.isLinked: tempStr = ksdkProj.sdkPath + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' self.projRelPath = relPath # tree = ET.ElementTree(ET.fromstring(mF.mdk_formatted_uvmpw)) # root = tree.getroot() prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(mdkPath): os.makedirs(mdkPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(mdkPath + '/' + self.name + '.uvmpw', "UTF-8") return
def get_advance_projects_root_folder(self, project_name, index, parent_key): global SDK_PATH user_board = self.app.localSDK.brdList[index] if parent_key != None: # it's device chip, use manifest first evaluation_board global evaluation_board_name # fix bug that the key is not found exception if dict_board_folder.has_key(evaluation_board_name): user_board = evaluation_board_name board_folder_name = dict_board_folder[user_board] folder_root = os.path.join(os.path.join(os.path.join(os.path.join(\ SDK_PATH, get_quick_folder_root()), board_folder_name), TEMP_QUICK_FOLDER), project_name) return kT.string_replace(folder_root, '\\', '/')
def verify_file_content(self, file_path, search_key): file_path = kT.string_replace(file_path, '\\', '/') if not os.path.exists(file_path): return False f = open(file_path) if DEBUG: print "file to search content: " + file_path + ", key: " + search_key content = f.readlines() f.close() is_match_key = False for line in content: #if DEBUG: print line if re.search(search_key, line): is_match_key = True break return is_match_key
def gen_settings(self, ksdkProj): """ Generate settings files for ATL project """ atlPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/atl/.settings' # Write data to file if not os.path.isdir(atlPath): os.mkdir(atlPath) tree = ET.ElementTree(ET.fromstring(aF.language_settings_xml)) launchPath = atlPath + '/language.settings.xml' tree.write(launchPath, "UTF-8") setPath = atlPath + '/com.atollic.truestudio.debug.hardware_device.prefs' setContent = aF.com_atollic_truestudio_debug_hardware_device_prefs setContent = kT.string_replace(setContent, 'settingDevice', self.device[0]) with open(setPath, 'wb+') as f: f.write(setContent) f.close() return
failure_count_after_test = g_failure_count self.assertEqual(failure_count_before_test, failure_count_after_test, "test_quick_generate") 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()
def gen_project(self, ksdkProj): """ Generate the eww files for KDS project :param ksdkProj: Instance of a KSDK project """ # Get relative path atlPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/atl' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(atlPath, ksdkProj.sdkPath) + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' tree = ET.ElementTree(ET.fromstring(aF.formatted_project)) root = tree.getroot() for child in root: if child.tag == 'name': child.text = str(self.name + '_' + ksdkProj.device[2]) if child.tag == 'linkedResources': #Add linked resources if ksdkProj.useBSP == True: #Add board file links for b in self.projBoard: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = b['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = b['type'] link.append(linkType) linkURI = ET.Element('locationURI') linkURI.text = b['locationURI'] link.append(linkURI) if ksdkProj.libList[0] != 'hal': #Add utilities folder link for u in self.projUtilities: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = u['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = u['type'] link.append(linkType) linkURI = ET.Element('locationURI') if ksdkProj.isLinked: linkURI.text = u['locationURI'] else: tempURI = kT.string_replace(u['locationURI'], 'PROJECT_KSDK', 'PARENT-1-PROJECT_LOC') linkURI.text = tempURI link.append(linkURI) if ksdkProj.rtos != 'mqx': for s in self.projStartup: link = ET.Element('link') child.append(link) linkName = ET.Element('name') tempName = kT.string_replace(s['name'], 'xxx', ksdkProj.device[1]) linkName.text = tempName link.append(linkName) linkType = ET.Element('type') linkType.text = s['type'] link.append(linkType) linkURI = ET.Element('locationURI') tempURI = kT.string_replace(s['locationURI'], 'xxx', ksdkProj.device[1]) if ksdkProj.isLinked == False: tempURI = kT.string_replace(tempURI, 'PROJECT_KSDK', 'PARENT-1-PROJECT_LOC') #print tempURI linkURI.text = tempURI link.append(linkURI) if ksdkProj.rtos != 'bm': for r in self.projRtos: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = r['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = r['type'] link.append(linkType) linkURI = ET.Element('locationURI') if ksdkProj.rtos == 'freertos': tempURI = kT.string_replace(r['locationURI'], 'xxx', ksdkProj.device[1][1:]) elif ksdkProj.rtos == 'mqx': tempURI = kT.string_replace(r['locationURI'], 'xxx', ksdkProj.device[1]) tempURI = kT.string_replace(r['locationURI'], 'bbb', ksdkProj.board[1]) elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' tempURI = kT.string_replace(r['locationURI'], 'ccc', archType) elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' tempURI = kT.string_replace(r['locationURI'], 'ccc', archType) if ksdkProj.isLinked == False: tempURI = kT.string_replace(tempURI, 'PROJECT_KSDK', 'PARENT-1-PROJECT_LOC') #print tempURI linkURI.text = tempURI link.append(linkURI) for c in self.projSources: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = c['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = c['type'] link.append(linkType) linkURI = ET.Element('locationURI') linkURI.text = c['locationURI'] link.append(linkURI) # Add variable to project for KSDK path if ksdkProj.isLinked: projVarList = ET.SubElement(root, 'variableList') root.append(projVarList) projVar = ET.Element('variable') projVarList.append(projVar) varName = ET.Element('name') varName.text = "PROJECT_KSDK" projVar.append(varName) varVal = ET.Element('value') if ksdkProj.osType == 'Windows': varVal.text = "file:/" + kT.string_replace(ksdkProj.sdkPath, '\\', '/') else: varVal.text = "file:" + ksdkProj.sdkPath projVar.append(varVal) # Format data to make it more readable prettyRoot = kT.pretty_xml(root, "UTF-8") #print prettyRoot # Write data to file if not os.path.isdir(atlPath): os.mkdir(atlPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(atlPath + '/.project', "UTF-8") return
def gen_cproject(self, ksdkProj): """ Generate the cproject file for KDS project :param ksdkProj: Instance of a KSDK project """ kdsPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/atl' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(kdsPath, ksdkProj.sdkPath) + '/../' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../../' self.projRelPath = relPath # Populate ksdkProj specifics to dictionaries ## Configure linker option self.linkLd['listOptionValue'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/linker/gcc/' +\ ksdkProj.device[0] + '_flash.ld') ## Set a define for the device self.cDefines['listOptionValue'].append('CPU_' + ksdkProj.device[2]) ## Added to fix K80 application build issues ## #if (ksdkProj.device[1] == 'MK80F25615') or (ksdkProj.device[1] == 'MK82F25615'): # self.cDefines['listOptionValue'].append('USING_DIRECT_INTERFACE=1') ## Added to fix UART smartcard application build issues ## if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: if d[0] == 'smartcard': if kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == (1 << 8): self.cDefines['listOptionValue'].append('USING_DIRECT_INTERFACE=1') elif kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == 1: self.cDefines['listOptionValue'].append('USING_NCN8025_INTERFACE=1') ################################################################################ if ksdkProj.useBSP: boardType = ksdkProj.board[0][:ksdkProj.board[0].find('_')] self.cDefines['listOptionValue'].append(ksdkProj.board[0]) if boardType == 'FRDM': self.cDefines['listOptionValue'].append('FREEDOM') elif boardType == 'TWR': self.cDefines['listOptionValue'].append('TOWER') elif boardType == 'USB': self.cDefines['listOptionValue'].append('BOARD_USE_VIRTUALCOM') self.cDefines['listOptionValue'].append('DONGLE') elif boardType == 'MRB': self.cDefines['listOptionValue'].append('MRB_KW01') if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cDefines['listOptionValue'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'mqx': self.cDefines['listOptionValue'].append('FSL_RTOS_MQX') elif ksdkProj.rtos == 'ucosii': self.cDefines['listOptionValue'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['listOptionValue'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project if ksdkProj.libList[0] != 'hal': self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/osa/inc') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/utilities/inc') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/CMSIS/Include') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/devices') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/include') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/startup') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/hal/inc') if ksdkProj.libList[0] != 'hal': self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/drivers/inc') self.cIncludes['listOptionValue'].append(self.projRelPath + 'platform/system/inc') self.cIncludes['listOptionValue'].append("../../") if ksdkProj.useBSP: self.cIncludes['listOptionValue'].append("../../board") ## Add device specific driver include paths if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['listOptionValue']: self.cIncludes['listOptionValue'].append(self.projRelPath + p) else: for d in ksdkProj.halList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['listOptionValue']: self.cIncludes['listOptionValue'].append(self.projRelPath + p) # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/gcc') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/FreeRTOS/port/gcc') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/FreeRTOS/include') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/FreeRTOS/src') self.asmIncludes['listOptionValue'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/gcc') #print self.asmIncludes #print self.asmIncludes['listOptionValue'] #print self.asmIncludes['listOptionValue'][0] elif ksdkProj.rtos == 'mqx': archType = 'M4' if (self.device[4] == 'cm4') else 'M0' self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug/config') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug/mqx') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug/mqx_stdlib') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/config/mcu/' + self.device[1]) self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/config/board/' + ksdkProj.board[1]) self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/bsp') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/compiler/gcc_arm') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/core/' + archType) self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/cpu') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/include') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/config/common') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_dummy') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_mem') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_null') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_pipe') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_serial') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tfs') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tty') elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Ports/' + archType + '/Generic/GNU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU/' + archType + '/GNU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/config') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Source') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSII/src/uC-LIB') elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Ports/' + archType + '/Generic/GNU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU/' + archType + '/GNU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/config') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Source') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU') self.cIncludes['listOptionValue'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-LIB') if ksdkProj.rtos == 'bm': self.linkLibs['libName'][0] = kT.string_replace(self.linkLibs['libName'][0],\ 'xxx', ksdkProj.libList[0]) else: self.linkLibs['libName'][0] = 'ksdk_platform_' + ksdkProj.libList[0] self.linkLibs['libName'].append('m') self.linkLibs['libPath'][0] = self.projRelPath + self.linkLibs['libPath'][0] self.linkLibs['libPath'][0] = kT.string_replace(self.linkLibs['libPath'][0],\ 'xxx', ksdkProj.libList[0]) if ksdkProj.rtos != 'bm': self.linkLibs['libPath'][0] = kT.string_replace(self.linkLibs['libPath'][0], \ 'libksdk_' + ksdkProj.libList[0] + '.a', \ 'libksdk_platform_' + ksdkProj.libList[0] + '.a') self.linkLibs['libPath'][0] = kT.string_replace(self.linkLibs['libPath'][0], \ 'ddd', ksdkProj.device[1][1:]) if ksdkProj.rtos == 'mqx': mqxLib = '_mqx' self.linkLibs['libName'].append(mqxLib) mqxPath = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug/mqx' self.linkLibs['libPath'].append(mqxPath) mqxStdLib = '_mqx_stdlib' self.linkLibs['libName'].append(mqxStdLib) mqxStdPath = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.atl/debug/mqx_stdlib' self.linkLibs['libPath'].append(mqxStdPath) # l = kT.string_replace(l, 'zzz', ksdkProj.rtos) # kT.debug_log(l) # if self.projType == 'usb': # l = kT.string_replace(l, 'yyy', ksdkProj.board[1]) # b = l kT.debug_log(self.linkLibs['libName']) kT.debug_log(self.linkLibs['libPath']) # Configure linker stack and heap if self.projType == 'usb': if ksdkProj.rtos == 'bm': if 'kl' in ksdkProj.board[1]: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x400' else: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x1000' else: if 'kl' in ksdkProj.board[1]: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x400' else: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x1000' tree = ET.ElementTree(ET.fromstring(aF.formatted_cproject)) root = tree.getroot() for child in root.findall('storageModule'): for config in child.findall('cconfiguration'): for module in config.findall('storageModule'): if module.get('moduleId') == "cdtBuildSystem": for configure in module.findall('configuration'): buildVer = configure.get('name') for folder in configure.findall('folderInfo'): for toolC in folder.findall('toolChain'): #for option in toolC.findall('option'): # if option.get('superClass') == "com.atollic.truestudio.as.general.otherflags": # option.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) # if option.get('superClass') == "com.atollic.truestudio.gcc.misc.otherflags": # option.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) # if option.get('superClass') == "com.atollic.truestudio.common_options.target.fpu": # optionVal = "hard" if ksdkProj.device[3] else "soft" # print optionVal # option.set('value', "com.atollic.truestudio.common_options.target.fpu." + optionVal) for tool in toolC.findall('tool'): #Add assembler options if tool.get('name') == "Assembler": for label in tool.findall('option'): if label.get('superClass') == "com.atollic.truestudio.common_options.target.fpu": optionVal = "hard" if ksdkProj.device[3] else "soft" #print optionVal label.set('value', "com.atollic.truestudio.common_options.target.fpu." + optionVal) if label.get('superClass') == "com.atollic.truestudio.as.general.otherflags": label.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) if label.get('superClass') == "com.atollic.truestudio.as.general.incpath": if ksdkProj.rtos == 'freertos': for a in self.asmIncludes['listOptionValue']: path = ET.Element('listOptionValue', {'builtIn': 'false', 'value': a}) label.append(path) #Add compiler options if tool.get('name') == "C Compiler": for label in tool.findall('option'): #Add include paths if label.get('superClass') == "com.atollic.truestudio.gcc.directories.select": #Add New Include paths for i in self.cIncludes['listOptionValue']: path = ET.Element('listOptionValue', {'builtIn': 'false', 'value': i}) label.append(path) #Add compiler defines if label.get('superClass') == "com.atollic.truestudio.gcc.symbols.defined": # Add new project defines for d in self.cDefines['listOptionValue']: define = ET.Element('listOptionValue', {'builtIn': 'false', 'value': d}) label.append(define) if label.get('superClass') == "com.atollic.truestudio.common_options.target.fpu": optionVal = "hard" if ksdkProj.device[3] else "soft" #print optionVal label.set('value', "com.atollic.truestudio.common_options.target.fpu." + optionVal) if label.get('superClass') == "com.atollic.truestudio.gcc.misc.otherflags": label.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) #Add linker options if tool.get('name') == "C Linker": for label in tool.findall('option'): #Add linker script if label.get('superClass') == "com.atollic.truestudio.ld.general.scriptfile": for l in self.linkLd['listOptionValue']: label.set('value', l) #Add other objects (.a files such as libksdk_platform.a) if label.get('superClass') == "com.atollic.truestudio.ld.libraries.list": for l in self.linkLibs['libName']: lib = ET.Element('listOptionValue', {'builtIn': 'false', 'value': l}) label.append(lib) if label.get('superClass') == "com.atollic.truestudio.ld.libraries.searchpath": #Add necessary linker objects if buildVer == 'debug': for l in self.linkLibs['libPath']: lib = ET.Element('listOptionValue', {'builtIn': 'false', 'value': l}) label.append(lib) else: for l in self.linkLibs['libPath']: temp = kT.string_replace(l, 'debug', 'release') lib = ET.Element('listOptionValue', {'builtIn': 'false', 'value': temp}) label.append(lib) if label.get('superClass') == "com.atollic.truestudio.ld.misc.linkerflags": temp = label.get('value') if ksdkProj.device[4][1:] != 'm4': temp = kT.string_replace(temp, 'm4', ksdkProj.device[4][1:]) if ksdkProj.rtos != 'bm': temp += ' -Xlinker --defsym=__ram_vector_table__=1' if ksdkProj.rtos == 'mqx': temp += ' -Xlinker --undefined=__isr_vector' label.set('value', temp) prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(kdsPath): os.makedirs(kdsPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(kdsPath + '/.cproject', "UTF-8") kT.cdt_fix_post_xml(kdsPath) return
def gen_project(self, ksdkProj): """ Generate the eww files for KDS project :param ksdkProj: Instance of a KSDK project """ # Get relative path atlPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/atl' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(atlPath, ksdkProj.sdkPath) + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' tree = ET.ElementTree(ET.fromstring(aF.formatted_project)) root = tree.getroot() for child in root: if child.tag == 'name': child.text = str(self.name + '_' + ksdkProj.device[2]) if child.tag == 'linkedResources': #Add linked resources if ksdkProj.useBSP == True: #Add board file links for b in self.projBoard: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = b['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = b['type'] link.append(linkType) linkURI = ET.Element('locationURI') linkURI.text = b['locationURI'] link.append(linkURI) for s in self.projStartup: link = ET.Element('link') child.append(link) linkName = ET.Element('name') tempName = kT.string_replace(s['name'], ksdkKdsNew.DEVICE_NAME_CONSTANT, ksdkProj.device[1]) tempName = kT.string_replace(tempName, ksdkKdsNew.LINKER_NAME_CONSTANT, ksdkProj.device[0] + "_flash.ld") linkName.text = tempName link.append(linkName) linkType = ET.Element('type') linkType.text = s['type'] link.append(linkType) linkURI = ET.Element('locationURI') tempURI = kT.string_replace(s['locationURI'], ksdkKdsNew.DEVICE_NAME_CONSTANT, ksdkProj.device[1]) tempURI = kT.string_replace(tempURI, ksdkKdsNew.LINKER_NAME_CONSTANT, ksdkProj.device[0] + "_flash.ld") if ksdkProj.isLinked == False: tempURI = kT.string_replace(tempURI, 'PROJECT_KSDK', 'PARENT-1-PROJECT_LOC') #print tempURI linkURI.text = tempURI link.append(linkURI) if ksdkProj.rtos != 'bm': for r in self.projRtos: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = r['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = r['type'] link.append(linkType) linkURI = ET.Element('locationURI') tempURI = r[ksdkObj.LOCATION_URI_KEY] if ksdkProj.isLinked == False: tempURI = kT.string_replace(r[ksdkObj.LOCATION_URI_KEY], 'PROJECT_KSDK', 'PARENT-1-PROJECT_LOC') #print tempURI linkURI.text = tempURI link.append(linkURI) for c in self.projSources + self.projTemplates: link = ET.Element('link') child.append(link) linkName = ET.Element('name') linkName.text = c['name'] link.append(linkName) linkType = ET.Element('type') linkType.text = c['type'] link.append(linkType) linkURI = ET.Element('locationURI') linkURI.text = c['locationURI'] link.append(linkURI) # Add variable to project for KSDK path if ksdkProj.isLinked: projVarList = ET.SubElement(root, 'variableList') root.append(projVarList) projVar = ET.Element('variable') projVarList.append(projVar) varName = ET.Element('name') varName.text = "PROJECT_KSDK" projVar.append(varName) varVal = ET.Element('value') if ksdkProj.osType == 'Windows': varVal.text = "file:/" + kT.string_replace(ksdkProj.sdkPath, '\\', '/') else: varVal.text = "file:" + ksdkProj.sdkPath projVar.append(varVal) # Format data to make it more readable prettyRoot = kT.pretty_xml(root, "UTF-8") #print prettyRoot # Write data to file if not os.path.isdir(atlPath): os.mkdir(atlPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(atlPath + '/.project', "UTF-8") return
def gen_cproject(self, ksdkProj): """ Generate the cproject file for KDS project :param ksdkProj: Instance of a KSDK project """ kdsPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/atl' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(kdsPath, ksdkProj.sdkPath) + '/../' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../../' self.projRelPath = relPath # Populate ksdkProj specifics to dictionaries ## Configure linker option ## Configure linker option self.linkLd['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getLinkerPath(ksdkProj.device, 'gcc', False)) ## Set a define for the device self.cDefines['listOptionValue'].append('CPU_' + ksdkProj.device[2]) if ksdkProj.rtos != 'bm': param = self.parentProject.parent.getSmartcardParam(ksdkProj.device[1]) if param is not None: self.cDefines['listOptionValue'].append(param) if ksdkProj.rtos == 'freertos': self.cDefines['listOptionValue'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'ucosii': self.cDefines['listOptionValue'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['listOptionValue'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project self.cIncludes['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getCMSISIncludeDirectory(False)) self.cIncludes['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory()) self.cIncludes['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1]) self.cIncludes['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.DRIVERS_FOLDER) self.cIncludes['listOptionValue'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.UTILITIES_FOLDER) self.cIncludes['listOptionValue'].append("../../") # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['listOptionValue'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getFreertosDirectoriesPaths(self.archType, ToolchainType.KinetisDesignStudio, self.parentProject.board[1])) elif ksdkProj.rtos == 'ucosii': self.cIncludes['listOptionValue'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIDirectoriesPaths(self.archType, ToolchainType.KinetisDesignStudio, self.parentProject.board[1])) elif ksdkProj.rtos == 'ucosiii': self.cIncludes['listOptionValue'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIIDirectoriesPaths(self.archType, ToolchainType.KinetisDesignStudio, self.parentProject.board[1])) # l = kT.string_replace(l, 'zzz', ksdkProj.rtos) # kT.debug_log(l) # if self.projType == 'usb': # l = kT.string_replace(l, 'yyy', ksdkProj.board[1]) # b = l # Configure linker stack and heap if self.projType == 'usb': if ksdkProj.rtos == 'bm': if 'kl' in ksdkProj.board[1]: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x400' else: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x1000' else: if 'kl' in ksdkProj.board[1]: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x400' else: self.linkDefines['listOptionValue'][1] = '__stack_size__=0x1000' tree = ET.ElementTree(ET.fromstring(aF.formatted_cproject)) root = tree.getroot() #exclude drivers from build excludedDriversText = '' driverPaths = [(Constants.DRIVERS_FOLDER if d[ksdkObj.LOCATION_URI_KEY].find(Constants.DRIVERS_FOLDER) != -1 else Constants.UTILITIES_FOLDER) + '/' + d[ksdkObj.NAME_KEY] for d in self.parentProject.parent.getDriversExcludedFromBuild(ksdkProj.device[1])] for f in driverPaths: if f.endswith('.c'): excludedDriversText += f if not driverPaths.index(f) == len(driverPaths): excludedDriversText += '|' for excludeEntry in root.findall('.//sourceEntries'): elem = ET.Element('entry', {'excluding': excludedDriversText, 'flags':'VALUE_WORKSPACE_PATH', 'kind':'sourcePath', 'name':''}) excludeEntry.insert(0, elem) for child in root.findall('storageModule'): for config in child.findall('cconfiguration'): for module in config.findall('storageModule'): if module.get('moduleId') == "cdtBuildSystem": for configure in module.findall('configuration'): buildVer = configure.get('name') for folder in configure.findall('folderInfo'): for toolC in folder.findall('toolChain'): for tool in toolC.findall('tool'): #Add assembler options if tool.get('name') == "Assembler": for label in tool.findall('option'): if label.get('superClass') == "com.atollic.truestudio.common_options.target.fpu": optionVal = "hard" if ksdkProj.device[3] else "soft" #print optionVal label.set('value', "com.atollic.truestudio.common_options.target.fpu." + optionVal) if label.get('superClass') == "com.atollic.truestudio.as.general.otherflags": label.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) if label.get('superClass') == "com.atollic.truestudio.as.general.incpath": if ksdkProj.rtos == 'freertos': for a in self.asmIncludes['listOptionValue']: path = ET.Element('listOptionValue', {'builtIn': 'false', 'value': a}) label.append(path) #Add compiler options if tool.get('name') == "C Compiler": for label in tool.findall('option'): #Add include paths if label.get('superClass') == "com.atollic.truestudio.gcc.directories.select": #Add New Include paths for i in self.cIncludes['listOptionValue']: path = ET.Element('listOptionValue', {'builtIn': 'false', 'value': i}) label.append(path) #Add compiler defines if label.get('superClass') == "com.atollic.truestudio.gcc.symbols.defined": # Add new project defines for d in self.cDefines['listOptionValue']: define = ET.Element('listOptionValue', {'builtIn': 'false', 'value': d}) label.append(define) if label.get('superClass') == "com.atollic.truestudio.common_options.target.fpu": optionVal = "hard" if ksdkProj.device[3] else "soft" #print optionVal label.set('value', "com.atollic.truestudio.common_options.target.fpu." + optionVal) if label.get('superClass') == "com.atollic.truestudio.gcc.misc.otherflags": label.set('value', " -mcpu=cortex-" + ksdkProj.device[4][1:]) #Add linker options if tool.get('name') == "C Linker": for label in tool.findall('option'): #Add linker script if label.get('superClass') == "com.atollic.truestudio.ld.general.scriptfile": for l in self.linkLd['listOptionValue']: label.set('value', l) if label.get('superClass') == "com.atollic.truestudio.ld.misc.linkerflags": temp = label.get('value') if ksdkProj.device[4][1:] != 'm4': temp = kT.string_replace(temp, 'm4', ksdkProj.device[4][1:]) if ksdkProj.rtos != 'bm': temp += ' -Xlinker --defsym=__ram_vector_table__=1' if ksdkProj.rtos == 'mqx': temp += ' -Xlinker --undefined=__isr_vector' label.set('value', temp) prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(kdsPath): os.makedirs(kdsPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(kdsPath + '/.cproject', "UTF-8") kT.cdt_fix_post_xml(kdsPath) return
def gen_proj(self, ksdkProj): """ Generate the uvprojx files for Keil project :param ksdkProj: Instance of a KSDK project """ # Get relative path mdkPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/mdk' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(mdkPath, ksdkProj.sdkPath) + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' self.projRelPath = relPath ## Configure linker option self.linkScf['state'] = self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getLinkerPath(ksdkProj.device, 'arm', False) ## Set a define for the device self.cDefines['state'].append('CPU_' + ksdkProj.device[2]) if ksdkProj.rtos != 'bm': param = self.parentProject.parent.getSmartcardParam(ksdkProj.device[1]) if param is not None: self.cDefines['state'].append(param) if ksdkProj.rtos == 'freertos': self.cDefines['state'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'ucosii': self.cDefines['state'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['state'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getCMSISIncludeDirectory(False)) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory()) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1]) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.DRIVERS_FOLDER) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.UTILITIES_FOLDER) self.cIncludes['state'].append("../../") # in project root, there are application files in case of rtos, so it has to be added to cIncludes self.cIncludes['state'].append("../") # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getFreertosDirectoriesPaths(self.archType, ToolchainType.KeilMDK, self.parentProject.board[1])) #FIXME Radka find out why self.asmIncludes['state'].append('..') elif ksdkProj.rtos == 'ucosii': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIDirectoriesPaths(self.archType, ToolchainType.KeilMDK, self.parentProject.board[1])) elif ksdkProj.rtos == 'ucosiii': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIIDirectoriesPaths(self.archType, ToolchainType.KeilMDK, self.parentProject.board[1])) # Add relative paths to files prePend = self.projRelPath + '{0}' self.projStartup['FileName'] = [f.replace('xxx', ksdkProj.device[1]) for f in self.projStartup['FileName']] self.projStartup['FilePath'] = [f.replace('xxx', ksdkProj.device[1]) for f in self.projStartup['FilePath']] self.projStartup['FileName'] = [f.replace(ksdkKdsNew.LINKER_NAME_CONSTANT, ksdkProj.device[0] + '_flash.scf') for f in self.projStartup['FileName']] self.projStartup['FilePath'] = [f.replace(ksdkKdsNew.LINKER_NAME_CONSTANT, ksdkProj.device[0] + '_flash.scf') for f in self.projStartup['FilePath']] for d in [self.projCMSISFiles, self.projStartup, self.drivers, self.utilities]: d[FILEPATH] = [prePend.format(f) for f in d[FILEPATH]] if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'xxx',\ ksdkProj.device[1][1:]) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'ccc',\ archType) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'ccc',\ archType) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 kT.debug_log(self.projStartup['FileName']) kT.debug_log(self.projStartup['FilePath']) projMem = self.get_memory_loc(ksdkProj) #print 'Memory loc/size: ' + str(projMem) peDebug = "PEMicro\\Pemicro_ArmCortexInterface.dll" cmDebug = "BIN\\CMSIS_AGDI.dll" tree = ET.ElementTree(ET.fromstring(mF.mdk_formatted_uvprojx)) for elem in tree.iter(tag='TargetName'): if 'Debug' in elem.text: elem.text = self.name + ' Debug' else: elem.text = self.name + ' Release' for elem in tree.iter(tag='Device'): elem.text = self.device[0] for elem in tree.iter(tag='OutputName'): elem.text = self.name + '.out' for elem in tree.iter(tag='Driver'): elem.text = cmDebug if (self.device[4] == 'cm4') else peDebug for elem in tree.iter(tag='AdsCpuType'): elem.text = "\"Cortex-M4\"" if (self.device[4] == 'cm4') else "\"Cortex-M0+\"" for elem in tree.iter(tag='RvdsVP'): elem.text = '2' if self.device[3] else '1' for elem in tree.iter(tag='Ir1Chk'): elem.text = '1' for elem in tree.iter(tag='Im1Chk'): elem.text = '1' for elem in tree.iter(tag='Im2Chk'): elem.text = '0' if (projMem[4] == '') else '1' for elem in tree.iter(tag='IRAM'): for child in elem.findall('StartAddress'): child.text = projMem[2] for child in elem.findall('Size'): child.text = projMem[3] for elem in tree.iter(tag='IROM'): for child in elem.findall('StartAddress'): child.text = projMem[0] for child in elem.findall('Size'): child.text = projMem[1] for elem in tree.iter(tag='OCR_RVCT4'): for child in elem.findall('StartAddress'): child.text = projMem[0] for child in elem.findall('Size'): child.text = projMem[1] for elem in tree.iter(tag='OCR_RVCT9'): for child in elem.findall('StartAddress'): child.text = projMem[2] for child in elem.findall('Size'): child.text = projMem[3] for elem in tree.iter(tag='OCR_RVCT10'): for child in elem.findall('StartAddress'): child.text = '0x0' if (projMem[4] == '') else projMem[4] for child in elem.findall('Size'): child.text = '0x0' if (projMem[5] == '') else projMem[5] for elem in tree.iter(tag='Cads'): for child in elem.findall('VariousControls'): for defs in child.findall('Define'): temp = defs.text for d in self.cDefines['state']: temp += ', ' + d defs.text = temp for incl in child.findall('IncludePath'): temp = incl.text for i in self.cIncludes['state']: temp += '; ' + i incl.text = temp for elem in tree.iter(tag='Aads'): if ksdkProj.rtos == 'freertos': for child in elem.findall('VariousControls'): for incl in child.findall('IncludePath'): incl.text = self.asmIncludes['state'][0] for elem in tree.iter(tag='ScatterFile'): elem.text = self.linkScf['state'] for elem in tree.iter(tag='Groups'): listOfDicts = [self.projStartup, self.projCMSISFiles, self.drivers, self.utilities, self.templates, self.projSources] if ksdkProj.rtos != 'bm': listOfDicts.append(self.projRtos) for d in listOfDicts: group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = d['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(d['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileNameText = d['FileName'][index] fileName.text = fileNameText fileType.text = d['FileType'][index] filePath.text = d['FilePath'][index] #add flag to drivers which should be excluded if (d == self.drivers) or (d == self.utilities): if fileNameText.endswith('.c'): dictToFindExcludedDrivers = self.drivers if d == self.drivers else self.utilities if fileNameText in dictToFindExcludedDrivers[ksdkIarNew.EXCLUDED_LIST]: fileOption = ET.SubElement(newFile, 'FileOption') commonProperty = ET.SubElement(fileOption, 'CommonProperty') includeInBuild = ET.SubElement(commonProperty, 'IncludeInBuild') alwaysBuild = ET.SubElement(commonProperty, 'AlwaysBuild') includeInBuild.text = 0 alwaysBuild.text =0 index += 1 root = tree.getroot() prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(mdkPath): os.makedirs(mdkPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(mdkPath + '/' + self.name + '.uvprojx', "UTF-8") if 'MKL' in self.device[0]: setPath = mdkPath + '/pemicro_connection_settings.ini' setContent = mF.pemicro_connection_settings_ini setContent = kT.string_replace(setContent, 'dev_name', self.device[0][1:].replace('xxx', 'M')) with open(setPath, 'wb+') as f: f.write(setContent) f.close() return
def gen_wkspace(self, ksdkProj): """ Generate the uvmpw files for Keil project :param ksdkProj: Instance of a KSDK project """ # Get relative path mdkPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/mdk' relPath = '' if self.isLinked: tempStr = ksdkProj.sdkPath + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' self.projRelPath = relPath self.wsProjects['PathAndName'][0] = self.projRelPath + self.wsProjects['PathAndName'][0] self.wsProjects['PathAndName'][0] = kT.string_replace(self.wsProjects['PathAndName'][0], \ 'xxx', ksdkProj.libList[0]) if ksdkProj.rtos != 'bm': self.wsProjects['PathAndName'][0] = kT.string_replace(self.wsProjects['PathAndName'][0], \ 'libksdk_' + ksdkProj.libList[0] + '.lib', \ 'libksdk_platform_' + ksdkProj.libList[0] + '.lib') self.wsProjects['PathAndName'][0] = kT.string_replace(self.wsProjects['PathAndName'][0], \ 'ddd', ksdkProj.device[1][1:]) self.wsProjects['PathAndName'][1] = self.name + '.uvprojx' if ksdkProj.rtos == 'mqx': mqxLib = self.projRelPath + 'rtos/mqx/mqx/build/mdk/mqx_' + ksdkProj.board[1] + '/mqx_' + ksdkProj.board[1] + '.uvprojx' self.wsProjects['PathAndName'].insert(1, mqxLib) self.wsProjects['NodeIsActive'].insert(1, '0') mqxStdLib = self.projRelPath + 'rtos/mqx/mqx_stdlib/build/mdk/mqx_stdlib_' + ksdkProj.board[1] + '/mqx_stdlib_' + ksdkProj.board[1] + '.uvprojx' self.wsProjects['PathAndName'].insert(2, mqxStdLib) self.wsProjects['NodeIsActive'].insert(2, '0') tree = ET.ElementTree(ET.fromstring(mF.mdk_formatted_uvmpw)) root = tree.getroot() index = 0 while index < len(self.wsProjects['PathAndName']): project = ET.Element('project') root.append(project) pathName = ET.SubElement(project, 'PathAndName') pathName.text = self.wsProjects['PathAndName'][index] isActive = ET.SubElement(project, 'NodeIsActive') isActive.text = self.wsProjects['NodeIsActive'][index] index += 1 #print 'Project count: ' + str(index) prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(mdkPath): os.makedirs(mdkPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(mdkPath + '/' + self.name + '.uvmpw', "UTF-8") return
def gen_proj(self, ksdkProj): """ Generate the uvprojx files for Keil project :param ksdkProj: Instance of a KSDK project """ # Get relative path mdkPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/mdk' relPath = '' if self.isLinked: tempStr = kT.get_rel_path(mdkPath, ksdkProj.sdkPath) + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' self.projRelPath = relPath ## Configure linker option self.linkScf['state'] = self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/linker/arm/' +\ ksdkProj.device[0] + '_flash.scf' ## Set a define for the device self.cDefines['state'].append('CPU_' + ksdkProj.device[2]) ## Added to fix K80 application build issues ## #if (ksdkProj.device[1] == 'MK80F25615') or (ksdkProj.device[1] == 'MK82F25615'): # self.cDefines['state'].append('USING_DIRECT_INTERFACE=1') ## Added to fix UART smartcard application build issues ## if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: if d[0] == 'smartcard': if kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == (1 << 8): self.cDefines['state'].append('USING_DIRECT_INTERFACE=1') elif kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == 1: self.cDefines['state'].append('USING_NCN8025_INTERFACE=1') ################################################################################ if ksdkProj.useBSP: boardType = ksdkProj.board[0][:ksdkProj.board[0].find('_')] self.cDefines['state'].append(ksdkProj.board[0]) if boardType == 'FRDM': self.cDefines['state'].append('FREEDOM') elif boardType == 'TWR': self.cDefines['state'].append('TOWER') elif boardType == 'USB': self.cDefines['state'].append('BOARD_USE_VIRTUALCOM') self.cDefines['state'].append('DONGLE') elif boardType == 'MRB': self.cDefines['state'].append('MRB_KW01') if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cDefines['state'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'mqx': self.cDefines['state'].append('FSL_RTOS_MQX') elif ksdkProj.rtos == 'ucosii': self.cDefines['state'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['state'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project if ksdkProj.libList[0] != 'hal': self.cIncludes['state'].append(self.projRelPath + 'platform/osa/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/utilities/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/CMSIS/Include') self.cIncludes['state'].append(self.projRelPath + 'platform/devices') self.cIncludes['state'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/include') self.cIncludes['state'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/startup') self.cIncludes['state'].append(self.projRelPath + 'platform/hal/inc') if ksdkProj.libList[0] != 'hal': self.cIncludes['state'].append(self.projRelPath + 'platform/drivers/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/system/inc') self.cIncludes['state'].append("../../") if ksdkProj.useBSP: self.cIncludes['state'].append("../board") ## Add device specific driver include paths if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['state']: self.cIncludes['state'].append(self.projRelPath + p) else: for d in ksdkProj.halList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['state']: self.cIncludes['state'].append(self.projRelPath + p) # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/mdk') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/port/mdk') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/include') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/src') self.asmIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/mdk') #print self.asmIncludes #print self.asmIncludes['state'] #print self.asmIncludes['state'][0] elif ksdkProj.rtos == 'mqx': archType = 'M4' if (self.device[4] == 'cm4') else 'M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug/mqx') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug/mqx_stdlib') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/mcu/' + self.device[1]) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/board/' + ksdkProj.board[1]) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/bsp') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/compiler/rv_mdk') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/core/' + archType) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/cpu') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/include') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/common') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_dummy') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_mem') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_null') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_pipe') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_serial') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tfs') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tty') elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Ports/' + archType + '/Generic/RealView') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU/' + archType + '/RealView') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Source') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-LIB') elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Ports/' + archType + '/Generic/RealView') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU/' + archType + '/RealView') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Source') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-LIB') # Add relative paths to files prePend = self.projRelPath + '{0}' self.projStartup['FileName'] = [f.replace('xxx', ksdkProj.device[1]) for f in self.projStartup['FileName']] self.projStartup['FilePath'] = [f.replace('xxx', ksdkProj.device[1]) for f in self.projStartup['FilePath']] self.projStartup['FilePath'] = [prePend.format(f) for f in self.projStartup['FilePath']] if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'xxx',\ ksdkProj.device[1][1:]) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 elif ksdkProj.rtos == 'mqx': index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'xxx',\ ksdkProj.device[1]) self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'bbb',\ ksdkProj.board[1]) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'ccc',\ archType) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.projRtos['FilePath']): self.projRtos['FilePath'][index] = kT.string_replace(self.projRtos['FilePath'][index],\ 'ccc',\ archType) self.projRtos['FilePath'][index] = self.projRelPath + self.projRtos['FilePath'][index] index += 1 kT.debug_log(self.projStartup['FileName']) kT.debug_log(self.projStartup['FilePath']) if ksdkProj.libList[0] != 'hal': self.projUtilities['FilePath'] = [prePend.format(f) for f in self.projUtilities['FilePath']] self.linkLibs['state'][0] = self.projRelPath + self.linkLibs['state'][0] self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], \ 'xxx', ksdkProj.libList[0]) if ksdkProj.rtos != 'bm': self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], \ 'libksdk_' + ksdkProj.libList[0] + '.lib', \ 'libksdk_platform_' + ksdkProj.libList[0] + '.lib') self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], \ 'ddd', ksdkProj.device[1][1:]) if ksdkProj.rtos == 'mqx': mqxLib = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug/mqx/lib_mqx.lib' self.linkLibs['state'].append(mqxLib) mqxStdLib = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.mdk/debug/mqx_stdlib/lib_mqx_stdlib.lib' self.linkLibs['state'].append(mqxStdLib) projMem = self.get_memory_loc(ksdkProj) #print 'Memory loc/size: ' + str(projMem) peDebug = "PEMicro\\Pemicro_ArmCortexInterface.dll" cmDebug = "BIN\\CMSIS_AGDI.dll" tree = ET.ElementTree(ET.fromstring(mF.mdk_formatted_uvprojx)) for elem in tree.iter(tag='TargetName'): if 'Debug' in elem.text: elem.text = self.name + ' Debug' else: elem.text = self.name + ' Release' for elem in tree.iter(tag='Device'): elem.text = self.device[0] for elem in tree.iter(tag='OutputName'): elem.text = self.name + '.out' for elem in tree.iter(tag='Driver'): elem.text = cmDebug if (self.device[4] == 'cm4') else peDebug for elem in tree.iter(tag='AdsCpuType'): elem.text = "\"Cortex-M4\"" if (self.device[4] == 'cm4') else "\"Cortex-M0+\"" for elem in tree.iter(tag='RvdsVP'): elem.text = '2' if self.device[3] else '1' for elem in tree.iter(tag='Ir1Chk'): elem.text = '1' for elem in tree.iter(tag='Im1Chk'): elem.text = '1' for elem in tree.iter(tag='Im2Chk'): elem.text = '0' if (projMem[4] == '') else '1' for elem in tree.iter(tag='IRAM'): for child in elem.findall('StartAddress'): child.text = projMem[2] for child in elem.findall('Size'): child.text = projMem[3] for elem in tree.iter(tag='IROM'): for child in elem.findall('StartAddress'): child.text = projMem[0] for child in elem.findall('Size'): child.text = projMem[1] for elem in tree.iter(tag='OCR_RVCT4'): for child in elem.findall('StartAddress'): child.text = projMem[0] for child in elem.findall('Size'): child.text = projMem[1] for elem in tree.iter(tag='OCR_RVCT9'): for child in elem.findall('StartAddress'): child.text = projMem[2] for child in elem.findall('Size'): child.text = projMem[3] for elem in tree.iter(tag='OCR_RVCT10'): for child in elem.findall('StartAddress'): child.text = '0x0' if (projMem[4] == '') else projMem[4] for child in elem.findall('Size'): child.text = '0x0' if (projMem[5] == '') else projMem[5] for elem in tree.iter(tag='Cads'): for child in elem.findall('VariousControls'): for defs in child.findall('Define'): temp = defs.text for d in self.cDefines['state']: temp += ', ' + d defs.text = temp for incl in child.findall('IncludePath'): temp = incl.text for i in self.cIncludes['state']: temp += '; ' + i incl.text = temp for elem in tree.iter(tag='Aads'): if ksdkProj.rtos == 'freertos': for child in elem.findall('VariousControls'): for incl in child.findall('IncludePath'): incl.text = self.asmIncludes['state'][0] for elem in tree.iter(tag='ScatterFile'): elem.text = self.linkScf['state'] for elem in tree.iter(tag='Misc'): temp = self.linkLibs['state'][0] + ' ' if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'mqx': temp += self.linkLibs['state'][1] + ' ' temp += self.linkLibs['state'][2] + ' ' temp += self.linkLibs['state'][1] + '(boot.o)' + ' ' temp += self.linkLibs['state'][1] + '(startup_*.o)' + ' ' temp += ' --remove ' temp += ' --predefine="-D__stack_size__=0x1000" ' temp += ' --predefine="-D__heap_size__=0x1000" ' temp += '--predefine="-D__ram_vector_table__=1" ' elem.text = temp for elem in tree.iter(tag='Groups'): if ksdkProj.rtos != 'mqx': # Add startup files group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = self.projStartup['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(self.projStartup['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileName.text = self.projStartup['FileName'][index] fileType.text = self.projStartup['FileType'][index] filePath.text = self.projStartup['FilePath'][index] index += 1 # Add source files group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = self.projSources['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(self.projSources['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileName.text = self.projSources['FileName'][index] fileType.text = self.projSources['FileType'][index] filePath.text = self.projSources['FilePath'][index] index += 1 # Add board files if needed if ksdkProj.useBSP: group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = self.projBoard['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(self.projBoard['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileName.text = self.projBoard['FileName'][index] fileType.text = self.projBoard['FileType'][index] filePath.text = self.projBoard['FilePath'][index] index += 1 # Add utilities in needed if ksdkProj.libList[0] != 'hal': group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = self.projUtilities['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(self.projUtilities['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileName.text = self.projUtilities['FileName'][index] fileType.text = self.projUtilities['FileType'][index] filePath.text = self.projUtilities['FilePath'][index] index += 1 # Add RTOS files if needed if ksdkProj.rtos != 'bm': group = ET.SubElement(elem, 'Group') name = ET.SubElement(group, 'GroupName') name.text = self.projRtos['GroupName'] files = ET.SubElement(group, 'Files') index = 0 while index < len(self.projRtos['FileName']): newFile = ET.SubElement(files, 'File') fileName = ET.SubElement(newFile, 'FileName') fileType = ET.SubElement(newFile, 'FileType') filePath = ET.SubElement(newFile, 'FilePath') fileName.text = self.projRtos['FileName'][index] fileType.text = self.projRtos['FileType'][index] filePath.text = self.projRtos['FilePath'][index] index += 1 root = tree.getroot() prettyRoot = kT.pretty_xml(root, "UTF-8") # Write data to file if not os.path.isdir(mdkPath): os.makedirs(mdkPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(mdkPath + '/' + self.name + '.uvprojx', "UTF-8") if 'MKL' in self.device[0]: setPath = mdkPath + '/pemicro_connection_settings.ini' setContent = mF.pemicro_connection_settings_ini setContent = kT.string_replace(setContent, 'dev_name', self.device[0][1:].replace('xxx', 'M')) with open(setPath, 'wb+') as f: f.write(setContent) f.close() return
def gen_ewp(self, ksdkProj): """ Generate the ewp files for IAR project :param ksdkProj: Instance of a KSDK project """ iarPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/iar' if self.isLinked: self.projRelPath = '$PROJ_DIR$/' + kT.get_rel_path(iarPath, ksdkProj.sdkPath) + '/' else: self.projRelPath = '$PROJ_DIR$/../' # Populate ksdkProj specifics to dictionaries ## Set name of out file self.linkOut['state'] = self.name + '.out' ## Configure linker option self.linkIcf['state'] = self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/linker/iar/' +\ ksdkProj.device[0] + '_flash.icf' ## Set a define for the device self.cDefines['state'].append('CPU_' + ksdkProj.device[2]) ## Added to fix K80 application build issues ## #if (ksdkProj.device[1] == 'MK80F25615') or (ksdkProj.device[1] == 'MK82F25615'): # self.cDefines['state'].append('USING_DIRECT_INTERFACE=1') ## Added to fix UART smartcard application build issues ## if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: if d[0] == 'smartcard': if kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == (1 << 8): self.cDefines['state'].append('USING_DIRECT_INTERFACE=1') elif kT.get_smartcard_type(ksdkProj.sdkPath, ksdkProj.device[1]) == 1: self.cDefines['state'].append('USING_NCN8025_INTERFACE=1') ################################################################################ if ksdkProj.useBSP: boardType = ksdkProj.board[0][:ksdkProj.board[0].find('_')] self.cDefines['state'].append(ksdkProj.board[0]) if boardType == 'FRDM': self.cDefines['state'].append('FREEDOM') elif boardType == 'TWR': self.cDefines['state'].append('TOWER') elif boardType == 'USB': self.cDefines['state'].append('BOARD_USE_VIRTUALCOM') self.cDefines['state'].append('DONGLE') elif boardType == 'MRB': self.cDefines['state'].append('MRB_KW01') if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cDefines['state'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'mqx': self.cDefines['state'].append('FSL_RTOS_MQX') elif ksdkProj.rtos == 'ucosii': self.cDefines['state'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['state'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project if ksdkProj.libList[0] != 'hal': self.cIncludes['state'].append(self.projRelPath + 'platform/osa/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/utilities/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/CMSIS/Include') self.cIncludes['state'].append(self.projRelPath + 'platform/devices') self.cIncludes['state'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/include') self.cIncludes['state'].append(self.projRelPath + 'platform/devices/' +\ ksdkProj.device[1] + '/startup') self.cIncludes['state'].append(self.projRelPath + 'platform/hal/inc') if ksdkProj.libList[0] != 'hal': self.cIncludes['state'].append(self.projRelPath + 'platform/drivers/inc') self.cIncludes['state'].append(self.projRelPath + 'platform/system/inc') self.cIncludes['state'].append("$PROJ_DIR$/../../..") if ksdkProj.useBSP: self.cIncludes['state'].append("$PROJ_DIR$/../board") ## Add device specific driver include paths if ksdkProj.libList[0] != 'hal': for d in ksdkProj.drvList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['state']: self.cIncludes['state'].append(self.projRelPath + p) else: for d in ksdkProj.halList: for p in d[1]: if not self.projRelPath + p in self.cIncludes['state']: self.cIncludes['state'].append(self.projRelPath + p) # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/iar') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/port/iar') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/include') self.cIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/src') self.asmIncludes['state'].append(self.projRelPath + 'rtos/FreeRTOS/config/' + self.device[1][1:] + '/iar') #print self.asmIncludes #print self.asmIncludes['state'] #print self.asmIncludes['state'][0] elif ksdkProj.rtos == 'mqx': archType = 'M4' if (self.device[4] == 'cm4') else 'M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug/mqx') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug/mqx_stdlib') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/mcu/' + self.device[1]) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/board/' + ksdkProj.board[1]) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/bsp') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/compiler/iar') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/core/' + archType) self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/psp/cortex_m/cpu') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/include') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/config/common') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_dummy') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_mem') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_null') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_pipe') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_serial') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tfs') self.cIncludes['state'].append(self.projRelPath + 'rtos/mqx/mqx/source/nio/drivers/nio_tty') elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Ports/' + archType + '/Generic/IAR') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU/' + archType + '/IAR') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uCOS-II/Source') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-CPU') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSII/src/uC-LIB') elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Ports/' + archType + '/Generic/IAR') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU/' + archType + '/IAR') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/config') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uCOS-III/Source') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-CPU') self.cIncludes['state'].append(self.projRelPath + 'rtos/uCOSIII/src/uC-LIB') # Add relative paths to files index = 0 while index < len(self.ewpStartup['file']): self.ewpStartup['file'][index] = kT.string_replace(self.ewpStartup['file'][index],\ 'xxx', \ ksdkProj.device[1]) self.ewpStartup['file'][index] = self.projRelPath + self.ewpStartup['file'][index] index += 1 if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'xxx',\ ksdkProj.device[1][1:]) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 elif ksdkProj.rtos == 'mqx': index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'xxx',\ ksdkProj.device[1]) self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'bbb',\ ksdkProj.board[1]) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'ccc',\ archType) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'ccc',\ archType) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 kT.debug_log(self.ewpStartup['file']) if ksdkProj.libList[0] != 'hal': index = 0 while index < len(self.ewpUtilities['file']): self.ewpUtilities['file'][index] = self.projRelPath + self.ewpUtilities['file'][index] index += 1 self.linkLibs['state'][0] = self.projRelPath + self.linkLibs['state'][0] self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], 'xxx', ksdkProj.libList[0]) if ksdkProj.rtos != 'bm': self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], \ 'libksdk_' + ksdkProj.libList[0] + '.a', \ 'libksdk_platform_' + ksdkProj.libList[0] + '.a') self.linkLibs['state'][0] = kT.string_replace(self.linkLibs['state'][0], 'ddd', ksdkProj.device[1][1:]) if ksdkProj.rtos == 'mqx': mqxLib = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug/mqx/lib_mqx.a' self.linkLibs['state'].append(mqxLib) mqxStdLib = self.projRelPath + 'rtos/mqx/lib/' + ksdkProj.board[1] + '.iar/debug/mqx_stdlib/lib_mqx_stdlib.a' self.linkLibs['state'].append(mqxStdLib) # l = kT.string_replace(l, 'zzz', ksdkProj.rtos) # kT.debug_log(l) # if self.projType == 'usb': # l = kT.string_replace(l, 'yyy', ksdkProj.board[1]) # b = l kT.debug_log(self.linkLibs['state']) # Configure linker stack and heap if self.projType == 'usb': if ksdkProj.rtos == 'bm': if 'kl' in ksdkProj.board[1]: self.linkDefines['state'][1] = '__stack_size__=0x400' else: self.linkDefines['state'][1] = '__stack_size__=0x1000' else: if 'kl' in ksdkProj.board[1]: self.linkDefines['state'][1] = '__stack_size__=0x400' else: self.linkDefines['state'][1] = '__stack_size__=0x1000' if ksdkProj.rtos == 'mqx': self.linkDefines['state'][0] = '__stack_size__=0x400' self.linkDefines['state'][1] = '__heap_size__=0x400' self.linkDefines['state'].append('__ram_vector_table__=1') elif ksdkProj.rtos == 'freertos': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') elif ksdkProj.rtos == 'ucosii': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') elif ksdkProj.rtos == 'ucosiii': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') tree = ET.ElementTree(ET.fromstring(iF.iar_formatted_ewp)) for elem in tree.iter(tag='option'): for child in elem.findall('name'): if child.text == 'OGChipSelectEditMenu': projDev = ET.Element('state') projDev.text = ksdkProj.device[0] + '\tFreescale ' + ksdkProj.device[0] elem.append(projDev) if child.text == 'FPU': projFPU = ET.Element('state') projFPU.text = '5' if self.device[3] else '0' elem.append(projFPU) if child.text == 'GFPUCoreSlave': projFPU = ET.Element('state') projFPU.text = '39' if self.device[3] else '35' elem.append(projFPU) if child.text == 'GBECoreSlave': projBE = ET.Element('state') projBE.text = '39' if self.device[3] else '35' elem.append(projBE) if child.text == 'CCDefines': for d in self.cDefines['state']: projCDef = ET.Element('state') projCDef.text = d elem.append(projCDef) if child.text == 'IlinkConfigDefines': if ksdkProj.rtos != 'bm': for d in self.linkDefines['state']: projLDef = ET.Element('state') projLDef.text = d elem.append(projLDef) if child.text == 'IlinkOverrideProgramEntryLabel': if ksdkProj.rtos == 'mqx': for s in elem.findall('state'): s.text = '1' #print s.text if child.text == 'IlinkProgramEntryLabel': if ksdkProj.rtos == 'mqx': for s in elem.findall('state'): s.text = 'Reset_Handler' #print s.text if child.text == 'IlinkOutputFile': projOut = ET.Element('state') projOut.text = self.linkOut['state'] elem.append(projOut) if child.text == 'IlinkIcfFile': projIcf = ET.Element('state') projIcf.text = self.linkIcf['state'] elem.append(projIcf) if child.text == 'IlinkAdditionalLibs': for l in self.linkLibs['state']: projLib = ET.Element('state') projLib.text = l elem.append(projLib) if child.text == 'CCIncludePath2': for i in self.cIncludes['state']: projInc = ET.Element('state') projInc.text = i elem.append(projInc) if child.text == 'AUserIncludes': #print "ASM Inlcudes" if ksdkProj.rtos == 'freertos': asmInc = ET.Element('state') asmInc.text = self.asmIncludes['state'][0] elem.append(asmInc) # Add file groups to ewp file root = tree.getroot() if ksdkProj.rtos != 'mqx': startGrp = ET.SubElement(root, 'group') startName = ET.SubElement(startGrp, 'name') startName.text = self.ewpStartup['name'] for f in self.ewpStartup['file']: startFile = ET.SubElement(startGrp, 'file') startFName = ET.SubElement(startFile, 'name') startFName.text = f sourceGrp = ET.SubElement(root, 'group') sourceName = ET.SubElement(sourceGrp, 'name') sourceName.text = self.ewpSources['name'] for f in self.ewpSources['file']: sourceFile = ET.SubElement(sourceGrp, 'file') sourceFName = ET.SubElement(sourceFile, 'name') sourceFName.text = f if ksdkProj.useBSP: boardGrp = ET.SubElement(root, 'group') boardName = ET.SubElement(boardGrp, 'name') boardName.text = self.ewpBoard['name'] for f in self.ewpBoard['file']: boardFile = ET.SubElement(boardGrp, 'file') boardFName = ET.SubElement(boardFile, 'name') boardFName.text = f if ksdkProj.libList[0] != 'hal': utilsGrp = ET.SubElement(root, 'group') utilsName = ET.SubElement(utilsGrp, 'name') utilsName.text = self.ewpUtilities['name'] for f in self.ewpUtilities['file']: utilsFile = ET.SubElement(utilsGrp, 'file') utilsFName = ET.SubElement(utilsFile, 'name') utilsFName.text = f if ksdkProj.rtos != 'bm': rtosGrp = ET.SubElement(root, 'group') rtosName = ET.SubElement(rtosGrp, 'name') rtosName.text = self.ewpRtos['name'] for f in self.ewpRtos['file']: rtosFile = ET.SubElement(rtosGrp, 'file') rtosFName = ET.SubElement(rtosFile, 'name') rtosFName.text = f prettyRoot = kT.pretty_xml(root, "iso-8859-1") # Write data to file if not os.path.isdir(iarPath): os.makedirs(iarPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(iarPath + '/' + self.name + '.ewp', "iso-8859-1") # Gen ewd while we are here tree = ET.ElementTree(ET.fromstring(iF.iar_formatted_ewd)) for elem in tree.iter(tag='option'): for child in elem.findall('name'): if child.text == 'OCDynDriverList': for state in elem.findall('state'): state.text = 'CMSISDAP_ID' if (self.device[4] == 'cm4') else 'PEMICRO_ID' if child.text == 'CMSISDAPResetList': for state in elem.findall('state'): state.text = '5' if (self.device[4] == 'cm4') else '10' if child.text == 'CMSISDAPInterfaceRadio': for state in elem.findall('state'): state.text = '1' if (self.device[4] == 'cm4') else '0' if child.text == 'CMSISDAPSelectedCPUBehaviour': for state in elem.findall('state'): state.text = '' if (self.device[4] == 'cm4') else '0' tree.write(iarPath + '/' + self.name + '.ewd', "iso-8859-1") return
def gen_ewp(self, ksdkProj): """ Generate the ewp files for IAR project :param ksdkProj: Instance of a KSDK project """ iarPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/iar' if self.isLinked: self.projRelPath = '$PROJ_DIR$/' + kT.get_rel_path(iarPath, ksdkProj.sdkPath) + '/' else: self.projRelPath = '$PROJ_DIR$/../' # Populate ksdkProj specifics to dictionaries ## Set name of out file self.linkOut['state'] = self.name + '.out' ## Configure linker option self.linkIcf['state'] = self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getLinkerPath(ksdkProj.device, 'iar', False) ## Set a define for the device self.cDefines['state'].append('CPU_' + ksdkProj.device[2]) if ksdkProj.rtos != 'bm': param = self.parentProject.parent.getSmartcardParam(ksdkProj.device[1]) if param is not None: self.cDefines['state'].append(param) if ksdkProj.rtos == 'freertos': self.cDefines['state'].append('FSL_RTOS_FREE_RTOS') elif ksdkProj.rtos == 'ucosii': self.cDefines['state'].append('FSL_RTOS_UCOSII') elif ksdkProj.rtos == 'ucosiii': self.cDefines['state'].append('FSL_RTOS_UCOSIII') ## Add C include paths necessary for project self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getCMSISIncludeDirectory(False)) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory()) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1]) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.UTILITIES_FOLDER) self.cIncludes['state'].append(self.projRelPath + self.parentProject.parent.getDirectoryStructureHelper().getDevicesDirectory() + os.sep + ksdkProj.device[1] + os.sep + Constants.DRIVERS_FOLDER) self.cIncludes['state'].append("$PROJ_DIR$/../../..") # in project root, there are application files in case of rtos, so it has to be added to cIncludes self.cIncludes['state'].append("$PROJ_DIR$/../") # Add rtos paths if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getFreertosDirectoriesPaths(self.archType, ToolchainType.IARname, self.parentProject.board[1])) #FIXME Radka find out why self.asmIncludes['state'].append('$PROJ_DIR$/..') elif ksdkProj.rtos == 'ucosii': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIDirectoriesPaths(self.archType, ToolchainType.IARname, self.parentProject.board[1])) elif ksdkProj.rtos == 'ucosiii': self.cIncludes['state'].extend(self.projRelPath + directoryPath for directoryPath in self.parentProject.parent.getuCOSIIIDirectoriesPaths(self.archType, ToolchainType.IARname, self.parentProject.board[1])) # Add relative paths to files index = 0 while index < len(self.ewpStartup['file']): self.ewpStartup['file'][index] = kT.string_replace(self.ewpStartup['file'][index], ksdkKdsNew.DEVICE_NAME_CONSTANT, ksdkProj.device[1]) self.ewpStartup['file'][index] = self.projRelPath + self.ewpStartup['file'][index] index += 1 for d in [self.projCMSISFiles, self.drivers, self.utilities]: d[FILE_KEY_IN_DICT] = [self.projRelPath + f for f in d[FILE_KEY_IN_DICT]] #add relative path to linker file self.linkerFile = self.projRelPath + self.linkerFile if ksdkProj.rtos != 'bm': if ksdkProj.rtos == 'freertos': index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'xxx',\ ksdkProj.device[1][1:]) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 elif ksdkProj.rtos == 'ucosii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'ccc',\ archType) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 elif ksdkProj.rtos == 'ucosiii': archType = 'ARM-Cortex-M4' if (self.device[4] == 'cm4') else 'ARM-Cortex-M0' index = 0 while index < len(self.ewpRtos['file']): self.ewpRtos['file'][index] = kT.string_replace(self.ewpRtos['file'][index],\ 'ccc',\ archType) self.ewpRtos['file'][index] = self.projRelPath + self.ewpRtos['file'][index] index += 1 kT.debug_log(self.ewpStartup['file']) # Configure linker stack and heap if self.projType == 'usb': if ksdkProj.rtos == 'bm': if 'kl' in ksdkProj.board[1]: self.linkDefines['state'][1] = '__stack_size__=0x400' else: self.linkDefines['state'][1] = '__stack_size__=0x1000' else: if 'kl' in ksdkProj.board[1]: self.linkDefines['state'][1] = '__stack_size__=0x400' else: self.linkDefines['state'][1] = '__stack_size__=0x1000' if ksdkProj.rtos == 'freertos': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') elif ksdkProj.rtos == 'ucosii': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') elif ksdkProj.rtos == 'ucosiii': self.linkDefines['state'][0] = '__stack_size__=0x1000' self.linkDefines['state'][1] = '__heap_size__=0x1000' self.linkDefines['state'].append('__ram_vector_table__=1') tree = ET.ElementTree(ET.fromstring(iF.iar_formatted_ewp)) for elem in tree.iter(tag='option'): for child in elem.findall('name'): if child.text == 'OGChipSelectEditMenu': projDev = ET.Element('state') projDev.text = ksdkProj.device[0] + '\tFreescale ' + ksdkProj.device[0] elem.append(projDev) if child.text == 'FPU': projFPU = ET.Element('state') projFPU.text = '5' if self.device[3] else '0' elem.append(projFPU) if child.text == 'GFPUCoreSlave': projFPU = ET.Element('state') projFPU.text = '39' if self.device[3] else '35' elem.append(projFPU) if child.text == 'GBECoreSlave': projBE = ET.Element('state') projBE.text = '39' if self.device[3] else '35' elem.append(projBE) if child.text == 'CCDefines': for d in self.cDefines['state']: projCDef = ET.Element('state') projCDef.text = d elem.append(projCDef) if child.text == 'IlinkConfigDefines': if ksdkProj.rtos != 'bm': for d in self.linkDefines['state']: projLDef = ET.Element('state') projLDef.text = d elem.append(projLDef) if child.text == 'IlinkOverrideProgramEntryLabel': if ksdkProj.rtos == 'mqx': for s in elem.findall('state'): s.text = '1' #print s.text if child.text == 'IlinkOutputFile': projOut = ET.Element('state') projOut.text = self.linkOut['state'] elem.append(projOut) if child.text == 'IlinkIcfFile': projIcf = ET.Element('state') projIcf.text = self.linkIcf['state'] elem.append(projIcf) if child.text == 'CCIncludePath2': for i in self.cIncludes['state']: projInc = ET.Element('state') projInc.text = i elem.append(projInc) if child.text == 'AUserIncludes': #print "ASM Inlcudes" if ksdkProj.rtos == 'freertos': asmInc = ET.Element('state') asmInc.text = self.asmIncludes['state'][0] elem.append(asmInc) # Add file groups to ewp file root = tree.getroot() #add linker file to the root of project linkerFile = ET.SubElement(root, 'file') linkerFileName = ET.SubElement(linkerFile, 'name') linkerFileName.text = self.linkerFile for d in [self.ewpStartup, self.projCMSISFiles, self.templates, self.drivers, self.utilities, self.ewpSources]: group = ET.SubElement(root, 'group') groupName = ET.SubElement(group, 'name') groupName.text = d[NAME_KEY_IN_DICT] for f in d[FILE_KEY_IN_DICT]: file = ET.SubElement(group, 'file') fileFName = ET.SubElement(file, 'name') fileFName.text = f #exclude some drivers and utilities if (d == self.drivers) or (d == self.utilities): if f.endswith('.c'): dictToFindExcluded = self.drivers if d == self.drivers else self.utilities if dictToFindExcluded[EXCLUDED_LIST][d[FILE_KEY_IN_DICT].index(f)]: exc = ET.SubElement(file, 'excluded') conf = ET.SubElement(exc, 'configuration') conf.text = 'Debug' if ksdkProj.rtos != 'bm': rtosGrp = ET.SubElement(root, 'group') rtosName = ET.SubElement(rtosGrp, 'name') rtosName.text = self.ewpRtos['name'] for f in self.ewpRtos['file']: rtosFile = ET.SubElement(rtosGrp, 'file') rtosFName = ET.SubElement(rtosFile, 'name') rtosFName.text = f prettyRoot = kT.pretty_xml(root, "iso-8859-1") # Write data to file if not os.path.isdir(iarPath): os.makedirs(iarPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(iarPath + '/' + self.name + '.ewp', "iso-8859-1") # Gen ewd while we are here tree = ET.ElementTree(ET.fromstring(iF.iar_formatted_ewd)) for elem in tree.iter(tag='option'): for child in elem.findall('name'): if child.text == 'OCDynDriverList': for state in elem.findall('state'): state.text = 'CMSISDAP_ID' if (self.device[4] == 'cm4') else 'PEMICRO_ID' if child.text == 'CMSISDAPResetList': for state in elem.findall('state'): state.text = '5' if (self.device[4] == 'cm4') else '10' if child.text == 'CMSISDAPInterfaceRadio': for state in elem.findall('state'): state.text = '1' if (self.device[4] == 'cm4') else '0' if child.text == 'CMSISDAPSelectedCPUBehaviour': for state in elem.findall('state'): state.text = '' if (self.device[4] == 'cm4') else '0' tree.write(iarPath + '/' + self.name + '.ewd', "iso-8859-1") return
def gen_working_set(self, ksdkProj): """ Generate KDS working set for project """ # Get relative path kdsPath = self.parent + ('' if self.parent[-1:] == '/' else '/') + self.name + '/kds' relPath = '' if self.isLinked: tempStr = ksdkProj.sdkPath + '/' if ksdkProj.osType == 'Windows': relPath = kT.string_replace(tempStr, '\\', '/') else: relPath = tempStr[:] else: relPath = '../' tree = ET.ElementTree(ET.fromstring(kF.formatted_wsd)) root = tree.getroot() for child in root: if child.tag == 'projects': proj = ET.Element('project') child.append(proj) projName = ET.Element('name') projName.text = str(self.name + '_' + ksdkProj.device[2]) proj.append(projName) projPath = ET.Element('path') projPath.text = '.' proj.append(projPath) projOpen = ET.Element('open') projOpen.text = 'true' proj.append(projOpen) projAct = ET.Element('activeconfig') projAct.text = 'debug' proj.append(projAct) projBulRef = ET.Element('buildreferences', {'config': "debug"}) projBulRef.text = 'false' proj.append(projBulRef) projAct = ET.Element('activeconfig') projAct.text = 'release' proj.append(projAct) projBulRef = ET.Element('buildreferences', {'config': "release"}) projBulRef.text = 'false' proj.append(projBulRef) if child.tag == 'workingsets': wSet = ET.Element('workingSet', {'editPageId': "org.eclipse.cdt.ui.CElementWorkingSetPage",\ 'id': "1323268527287_1", 'label': self.name, 'name': self.name}) child.append(wSet) wSetItem = ET.Element('item', {'factoryID': "org.eclipse.cdt.ui.PersistableCElementFactory", \ 'path': "/" + str(self.name + '_' + ksdkProj.device[2]), 'type': "4"}) wSet.append(wSetItem) if child.tag == 'cdtconfigurations': wSet = ET.Element('workingSet', {'name': self.name}) child.append(wSet) wSetConfig = ET.Element('config', {'name': "debug"}) wSet.append(wSetConfig) wSetProjName = str(self.name + '_' + ksdkProj.device[2]) wSetProj = ET.Element('project', {'config': "com.freescale.arm.cdt.toolchain.config.arm.release.695495605",\ 'name': wSetProjName,\ 'configName': "debug"}) wSetConfig.append(wSetProj) wSetConfig = ET.Element('config', {'name': "release"}) wSet.append(wSetConfig) wSetProj = ET.Element('project', {'config': "com.freescale.arm.cdt.toolchain.config.arm.release.695495605",\ 'name': wSetProjName,\ 'configName': "release"}) wSetConfig.append(wSetProj) # Format data to make it more readable prettyRoot = kT.pretty_xml(root, "UTF-8") #print prettyRoot # Write data to file if not os.path.isdir(kdsPath): os.mkdir(kdsPath) tree = ET.ElementTree(ET.fromstring(prettyRoot)) tree.write(kdsPath + '/' + self.name + '.wsd', "UTF-8") return