Пример #1
0
def main():
	args = _get_args()

	platform_module = _misoc_import("mibuild.platforms", args.external_platform, args.platform)
	target_module = _misoc_import("targets", args.external_target, args.target)
	platform = platform_module.Platform()
	if args.sub_target:
		top_class = getattr(target_module, args.sub_target)
	else:
		top_class = target_module.get_default_subtarget(platform)
	build_name = top_class.__name__.lower() + "-" + args.platform
	top_kwargs = dict((k, autotype(v)) for k, v in args.target_option)
	soc = top_class(platform, **top_kwargs)

	soc.finalize()

	if not args.no_header:
		boilerplate = """/*
 * Platform: {}
 * Target: {}
 * Subtarget: {}
 */

""".format(args.platform, args.target, top_class.__name__)
		linker_header = cpuif.get_linker_regions(soc.cpu_memory_regions)
		write_to_file("software/include/generated/regions.ld", boilerplate + linker_header)
		csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
		write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
		if hasattr(soc, "ddrphy"):
			sdram_phy_header = initsequence.get_sdram_phy_header(soc.ddrphy)
			write_to_file("software/include/generated/sdram_phy.h", boilerplate + sdram_phy_header)
	if args.csr_csv:
		csr_csv = cpuif.get_csr_csv(soc.csr_base, soc.csrbankarray)
		write_to_file(args.csr_csv, csr_csv)

	if hasattr(soc, "init_bios_memory"):
		ret = subprocess.call(["make", "-C", "software/bios"])
		if ret:
			raise OSError("BIOS build failed")
		bios_file = open("software/bios/bios.bin", "rb")
		bios_data = []
		while True:
			w = bios_file.read(4)
			if not w:
				break
			bios_data.append(struct.unpack(">I", w)[0])
		bios_file.close()
		soc.init_bios_memory(bios_data)

	if not args.no_bitstream:
		build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
		platform.build(soc, build_name=build_name, **build_kwargs)
		subprocess.call(["tools/byteswap",
			"build/" + build_name + ".bin",
			"build/" + build_name + ".fpg"])

	if args.load:
		jtag.load(platform.name, "build/" + build_name + ".bit")
	if args.flash:
		jtag.flash("build/" + build_name + ".fpg")
Пример #2
0
		write_to_file("software/include/generated/regions.ld", boilerplate + linker_regions)
		try:
			flash_boot_address = soc.flash_boot_address
		except AttributeError:
			flash_boot_address = None
		mem_header = cpuif.get_mem_header(soc.cpu_memory_regions, flash_boot_address)
		write_to_file("software/include/generated/mem.h", boilerplate + mem_header)
		csr_header = cpuif.get_csr_header(soc.csr_base, soc.csrbankarray, soc.interrupt_map)
		write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
		for sdram_phy in ["sdrphy", "ddrphy"]:
			if hasattr(soc, sdram_phy):
				sdram_phy_header = initsequence.get_sdram_phy_header(getattr(soc, sdram_phy))
				write_to_file("software/include/generated/sdram_phy.h", boilerplate + sdram_phy_header)

	if actions["build-csr-csv"]:
		csr_csv = cpuif.get_csr_csv(soc.csr_base, soc.csrbankarray)
		write_to_file(args.csr_csv, csr_csv)

	if actions["build-bios"]:
		ret = subprocess.call(["make", "-C", "software/bios"])
		if ret:
			raise OSError("BIOS build failed")

	if actions["build-bitstream"]:
		if hasattr(soc, "init_bios_memory"):
			with open("software/bios/bios.bin", "rb") as bios_file:
				bios_data = []
				while True:
					w = bios_file.read(4)
					if not w:
						break
Пример #3
0
		write_to_file("software/include/generated/regions.ld", boilerplate + linker_regions)
		try:
			flash_boot_address = soc.flash_boot_address
		except AttributeError:
			flash_boot_address = None
		mem_header = cpuif.get_mem_header(soc.cpu_memory_regions, flash_boot_address)
		write_to_file("software/include/generated/mem.h", boilerplate + mem_header)
		csr_header = cpuif.get_csr_header(soc.cpu_csr_regions, soc.interrupt_map)
		write_to_file("software/include/generated/csr.h", boilerplate + csr_header)
		for sdram_phy in ["sdrphy", "ddrphy"]:
			if hasattr(soc, sdram_phy):
				sdram_phy_header = initsequence.get_sdram_phy_header(getattr(soc, sdram_phy))
				write_to_file("software/include/generated/sdram_phy.h", boilerplate + sdram_phy_header)

	if actions["build-csr-csv"]:
		csr_csv = cpuif.get_csr_csv(soc.cpu_csr_regions)
		write_to_file(args.csr_csv, csr_csv)

	if actions["build-bios"]:
		ret = subprocess.call(["make", "-C", "software/bios"])
		if ret:
			raise OSError("BIOS build failed")

	if actions["build-bitstream"]:
		if hasattr(soc, "init_bios_memory"):
			with open("software/bios/bios.bin", "rb") as bios_file:
				bios_data = []
				while True:
					w = bios_file.read(4)
					if not w:
						break