Example #1
0
		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
					bios_data.append(struct.unpack(">I", w)[0])
			soc.init_bios_memory(bios_data)

		for decorator in args.decorate:
			soc = getattr(simplify, decorator)(soc)
		build_kwargs = dict((k, autotype(v)) for k, v in args.build_option)
		platform.build(soc, build_name=build_name, **build_kwargs)

	if actions["load-bitstream"] or actions["flash-bitstream"] or actions["flash-bios"]:
		prog = programmer.create_programmer(platform.name, args.flash_proxy_dir)
		if actions["load-bitstream"]:
			prog.load_bitstream("build/" + build_name + platform.bitstream_ext)
		if actions["flash-bitstream"]:
			if prog.needs_bitreverse:
				flashbit = "build/" + build_name + ".fpg"
				subprocess.call(["tools/byteswap",
					"build/" + build_name + ".bin",
					flashbit])
			else:
				flashbit = "build/" + build_name + ".bin"
			prog.flash(0, flashbit)
		if actions["flash-bios"]:
			prog.flash(soc.cpu_reset_address, "software/bios/bios.bin")
Example #2
0
#!/usr/bin/env python3

import sys, argparse
import programmer

if __name__ == "__main__":
	parser = argparse.ArgumentParser(description="Program extra data to flash memory.")
	parser.add_argument("-f", "--flash-proxy-dir", default=None, help="set search directory for flash proxy bitstreams")
	parser.add_argument("platform", help="target platform")
	parser.add_argument("file", help="file to flash")
	parser.add_argument("address", help="flash address to write")
	args = parser.parse_args()

	prog = programmer.create_programmer(args.platform, args.flash_proxy_dir)
	prog.flash(int(args.address, 0), args.file)