def generate(self): """Generate the .uvproj file""" cache = Cache(True, False) if cache_d: cache.cache_descriptors() srcs = self.resources.headers + self.resources.s_sources + \ self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries ctx = { 'name': self.project_name, # project_files => dict of generators - file group to generator of # UVFile tuples defined above 'project_files': sorted(list(self.format_src(srcs).iteritems()), key=lambda (group, _): group.lower()), 'linker_script':self.resources.linker_script, 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'device': DeviceUvision(self.target), } # Turn on FPU optimizations if the core has an FPU ctx['fpu_setting'] = 1 if 'f' not in ctx['device'].core.lower() \ or 'd' in ctx['device'].core.lower() else 2 ctx.update(self.format_flags()) self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
def generate(self): """Generate the .uvproj file""" cache = Cache(True, False) if cache_d: cache.cache_descriptors() srcs = self.resources.headers + self.resources.s_sources + \ self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries ctx = { 'name': self.project_name, # project_files => dict of generators - file group to generator of # UVFile tuples defined above 'project_files': sorted(list(self.format_src(srcs).iteritems()), key=lambda (group, _): group.lower()), 'linker_script':self.toolchain.correct_scatter_shebang( self.resources.linker_script), 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'device': DeviceUvision(self.target), } if ctx['linker_script'] is not self.resources.linker_script: self.generated_files.append(ctx['linker_script']) core = ctx['device'].core ctx['cputype'] = core.rstrip("FD") if core.endswith("FD"): ctx['fpu_setting'] = 3 elif core.endswith("F"): ctx['fpu_setting'] = 2 else: ctx['fpu_setting'] = 1 ctx['fputype'] = self.format_fpu(core) ctx.update(self.format_flags()) self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
def generate(self): """Generate the .uvproj file""" cache = Cache(True, False) if cache_d: cache.cache_descriptors() srcs = self.resources.headers + self.resources.s_sources + \ self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries ctx = { 'name': self.project_name, # project_files => dict of generators - file group to generator of # UVFile tuples defined above 'project_files': sorted(list(self.format_src(srcs).iteritems()), key=lambda (group, _): group.lower()), 'linker_script':self.resources.linker_script, 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'device': DeviceUvision(self.target), } core = ctx['device'].core ctx['cputype'] = core.rstrip("FD") if core.endswith("FD"): ctx['fpu_setting'] = 3 elif core.endswith("F"): ctx['fpu_setting'] = 2 else: ctx['fpu_setting'] = 1 ctx['fputype'] = self.format_fpu(core) ctx.update(self.format_flags()) self.gen_file('uvision/uvision.tmpl', ctx, self.project_name+".uvprojx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
def generate(self): """Generate the .uvproj file""" cache = Cache(True, False) if cache_d: cache.cache_descriptors() srcs = self.resources.headers + self.resources.s_sources + \ self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries ctx = { 'name': self.project_name, 'project_files': self.format_src(srcs), 'linker_script': self.resources.linker_script, 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'device': DeviceUvision(self.target), } # Turn on FPU optimizations if the core has an FPU ctx['fpu_setting'] = 1 if 'f' not in ctx['device'].core.lower() \ or 'd' in ctx['device'].core.lower() else 2 ctx.update(self.format_flags()) self.gen_file('uvision/uvision.tmpl', ctx, self.project_name + ".uvprojx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
def __init__(self, target): cache = Cache(True, False) data_path = join(save_data_path('arm-pack-manager'), "index.json") if not exists(data_path) or not self.check_version(data_path): cache.cache_descriptors() t = TARGET_MAP[target] self.core = t.core try: cpu_name = t.device_name target_info = cache.index[cpu_name] # Target does not have device name or pdsc file except: try: # Try to find the core as a generic CMSIS target cpu_name = self.cpu_cmsis() target_info = cache.index[cpu_name] except: raise TargetNotSupportedException("Target not in CMSIS packs") self.target_info = target_info self.url = target_info['pdsc_file'] self.pack_url, self.pack_id = ntpath.split(self.url) self.dname = cpu_name self.dfpu = target_info['processor']['fpu'] self.debug, self.dvendor = self.vendor_debug(target_info['vendor']) self.dendian = target_info['processor'].get('endianness', 'Little-endian') self.debug_svd = target_info.get('debug', '') self.compile_header = target_info['compile']['header']
def generate(self): """Generate the .uvproj file""" cache = Cache(True, False) if cache_d: cache.cache_descriptors() srcs = self.resources.headers + self.resources.s_sources + \ self.resources.c_sources + self.resources.cpp_sources + \ self.resources.objects + self.resources.libraries ctx = { 'name': self.project_name, # project_files => dict of generators - file group to generator of # UVFile tuples defined above 'project_files': sorted(list(self.format_src(srcs).iteritems()), key=lambda (group, _): group.lower()), 'linker_script': self.resources.linker_script, 'include_paths': '; '.join(self.resources.inc_dirs).encode('utf-8'), 'device': DeviceUvision(self.target), } core = ctx['device'].core ctx['cputype'] = core.rstrip("FD") # Turn on FPU optimizations if the core has an FPU ctx['fpu_setting'] = 1 if 'F' not in core or 'D' in core else 2 ctx['fputype'] = self.format_fpu(core) ctx.update(self.format_flags()) self.gen_file('uvision/uvision.tmpl', ctx, self.project_name + ".uvprojx") self.gen_file('uvision/uvision_debug.tmpl', ctx, self.project_name + ".uvoptx")
def main(): """Generate flash algorithms""" parser = argparse.ArgumentParser(description='Flash generator') parser.add_argument("--rebuild_all", action="store_true", help="Rebuild entire cache") parser.add_argument("--rebuild_descriptors", action="store_true", help="Rebuild descriptors") parser.add_argument("--target", default=None, help="Name of target to generate algo for") parser.add_argument("--all", action="store_true", help="Build all flash algos for devcies") args = parser.parse_args() cache = Cache(True, True) if args.rebuild_all: cache.cache_everything() print("Cache rebuilt") return if args.rebuild_descriptors: cache.cache_descriptors() print("Descriptors rebuilt") return if args.target is None: device_and_filenames = [(target.device_name, target.name) for target in TARGETS if hasattr(target, "device_name")] else: device_and_filenames = [(args.target, args.target.replace("/", "-"))] try: os.mkdir("output") except OSError: # Directory already exists pass for device, filename in device_and_filenames: dev = cache.index[device] binaries = cache.get_flash_algorthim_binary(device, all=True) algos = [PackFlashAlgo(binary.read()) for binary in binaries] filtered_algos = algos if args.all else filter_algos(dev, algos) for idx, algo in enumerate(filtered_algos): file_name = ("%s_%i.c" % (filename, idx) if args.all or len(filtered_algos) != 1 else "%s.c" % filename) output_path = join("output", file_name) algo.process_template(TEMPLATE_PATH, output_path) print("%s: %s \r" % (device, filename))
def main(): """Entry point""" # Parse Options parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = EXPORTERS.keys() toolchainlist.sort() parser.add_argument("-m", "--mcu", metavar="MCU", type=str.upper, help="generate project for the given MCU ({})".format( ', '.join(targetnames))) parser.add_argument("-i", dest="ide", type=argparse_force_lowercase_type( toolchainlist, "toolchain"), help="The target IDE: %s" % str(toolchainlist)) parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the export directory") group = parser.add_mutually_exclusive_group(required=False) group.add_argument("-p", type=test_known, dest="program", help="The index of the desired test program: [0-%s]" % (len(TESTS) - 1)) group.add_argument("-n", type=test_name_known, dest="program", help="The name of the desired test program") parser.add_argument( "-b", dest="build", default=False, action="store_true", help="use the mbed library build, instead of the sources") group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests", default=False, help="list available programs in order and exit") group.add_argument("-S", "--list-matrix", dest="supported_ides", default=False, const="matrix", choices=["matrix", "ides"], nargs="?", help="displays supported matrix of MCUs and IDEs") parser.add_argument("-E", action="store_true", dest="supported_ides_html", default=False, help="writes tools/export/README.md") parser.add_argument("--source", action="append", type=argparse_filestring_type, dest="source_dir", default=[], help="The source (input) directory") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("--profile", dest="profile", action="append", type=argparse_profile_filestring_type, help="Build profile to use. Can be either path to json" \ "file or one of the default one ({})".format(", ".join(list_profiles())), default=[]) parser.add_argument("--update-packs", dest="update_packs", action="store_true", default=False) parser.add_argument("--app-config", dest="app_config", default=None) options = parser.parse_args() # Print available tests in order and exit if options.list_tests is True: print '\n'.join([str(test) for test in sorted(TEST_MAP.values())]) sys.exit() # Only prints matrix of supported IDEs if options.supported_ides: if options.supported_ides == "matrix": print_large_string(mcu_ide_matrix()) elif options.supported_ides == "ides": print mcu_ide_list() exit(0) # Only prints matrix of supported IDEs if options.supported_ides_html: html = mcu_ide_matrix(verbose_html=True) try: with open("./export/README.md", "w") as readme: readme.write("Exporter IDE/Platform Support\n") readme.write("-----------------------------------\n") readme.write("\n") readme.write(html) except IOError as exc: print "I/O error({0}): {1}".format(exc.errno, exc.strerror) except: print "Unexpected error:", sys.exc_info()[0] raise exit(0) if options.update_packs: from tools.arm_pack_manager import Cache cache = Cache(True, True) cache.cache_descriptors() # Target if not options.mcu: args_error(parser, "argument -m/--mcu is required") # Toolchain if not options.ide: args_error(parser, "argument -i is required") # Clean Export Directory if options.clean: if exists(EXPORT_DIR): rmtree(EXPORT_DIR) zip_proj = not bool(options.source_dir) if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") exporter, toolchain_name = get_exporter_toolchain(options.ide) mcu = extract_mcus(parser, options)[0] if not exporter.is_target_supported(mcu): args_error(parser, "%s not supported by %s" % (mcu, options.ide)) profile = extract_profile(parser, options, toolchain_name, fallback="debug") if options.clean: rmtree(BUILD_DIR) try: export(mcu, options.ide, build=options.build, src=options.source_dir, macros=options.macros, project_id=options.program, zip_proj=zip_proj, build_profile=profile, app_config=options.app_config) except NotSupportedException as exc: print "[ERROR] %s" % str(exc)
def main(): """Entry point""" # Parse Options parser = ArgumentParser() targetnames = TARGET_NAMES targetnames.sort() toolchainlist = EXPORTERS.keys() toolchainlist.sort() parser.add_argument("-m", "--mcu", metavar="MCU", default='LPC1768', type=argparse_force_uppercase_type(targetnames, "MCU"), help="generate project for the given MCU ({})".format( ', '.join(targetnames))) parser.add_argument("-i", dest="ide", default='uvision', type=argparse_force_lowercase_type( toolchainlist, "toolchain"), help="The target IDE: %s"% str(toolchainlist)) parser.add_argument("-c", "--clean", action="store_true", default=False, help="clean the export directory") group = parser.add_mutually_exclusive_group(required=False) group.add_argument( "-p", type=test_known, dest="program", help="The index of the desired test program: [0-%s]"% (len(TESTS)-1)) group.add_argument("-n", type=test_name_known, dest="program", help="The name of the desired test program") parser.add_argument("-b", dest="build", default=False, action="store_true", help="use the mbed library build, instead of the sources") group.add_argument("-L", "--list-tests", action="store_true", dest="list_tests", default=False, help="list available programs in order and exit") group.add_argument("-S", "--list-matrix", action="store_true", dest="supported_ides", default=False, help="displays supported matrix of MCUs and IDEs") parser.add_argument("-E", action="store_true", dest="supported_ides_html", default=False, help="writes tools/export/README.md") parser.add_argument("--source", action="append", type=argparse_filestring_type, dest="source_dir", default=[], help="The source (input) directory") parser.add_argument("-D", action="append", dest="macros", help="Add a macro definition") parser.add_argument("--profile", type=argparse_filestring_type, default=[], help="Toolchain profile") parser.add_argument("--update-packs", dest="update_packs", action="store_true", default=False) options = parser.parse_args() # Print available tests in order and exit if options.list_tests is True: print '\n'.join([str(test) for test in sorted(TEST_MAP.values())]) sys.exit() # Only prints matrix of supported IDEs if options.supported_ides: print_large_string(mcu_ide_matrix()) exit(0) # Only prints matrix of supported IDEs if options.supported_ides_html: html = mcu_ide_matrix(verbose_html=True) try: with open("./export/README.md", "w") as readme: readme.write("Exporter IDE/Platform Support\n") readme.write("-----------------------------------\n") readme.write("\n") readme.write(html) except IOError as exc: print "I/O error({0}): {1}".format(exc.errno, exc.strerror) except: print "Unexpected error:", sys.exc_info()[0] raise exit(0) if options.update_packs: from tools.arm_pack_manager import Cache cache = Cache(True, True) cache.cache_descriptors() # Clean Export Directory if options.clean: if exists(EXPORT_DIR): rmtree(EXPORT_DIR) for mcu in options.mcu: zip_proj = not bool(options.source_dir) # Target if not options.mcu: args_error(parser, "argument -m/--mcu is required") # Toolchain if not options.ide: args_error(parser, "argument -i is required") if (options.program is None) and (not options.source_dir): args_error(parser, "one of -p, -n, or --source is required") # Export to selected toolchain exporter, toolchain_name = get_exporter_toolchain(options.ide) if options.mcu not in exporter.TARGETS: args_error(parser, "%s not supported by %s"%(options.mcu,options.ide)) profile = extract_profile(parser, options, toolchain_name) export(options.mcu, options.ide, build=options.build, src=options.source_dir, macros=options.macros, project_id=options.program, clean=options.clean, zip_proj=zip_proj, build_profile=profile)