mirror of
https://github.com/saymrwulf/litex-boards.git
synced 2026-11-20 09:52:57 +00:00
targets/tec0117: minor cleanups.
This commit is contained in:
parent
43d9be08ed
commit
edb99797aa
1 changed files with 11 additions and 21 deletions
|
|
@ -44,10 +44,7 @@ class BaseSoC(SoCCore):
|
||||||
**kwargs)
|
**kwargs)
|
||||||
|
|
||||||
# CRG --------------------------------------------------------------------------------------
|
# CRG --------------------------------------------------------------------------------------
|
||||||
self.submodules.crg = CRG(
|
self.submodules.crg = CRG(platform.request("clk12"), ~platform.request("rst"))
|
||||||
platform.request(platform.default_clk_name),
|
|
||||||
~platform.request('rst'),
|
|
||||||
)
|
|
||||||
|
|
||||||
# SPI Flash --------------------------------------------------------------------------------
|
# SPI Flash --------------------------------------------------------------------------------
|
||||||
self.add_spi_flash(mode="1x", dummy_cycles=8)
|
self.add_spi_flash(mode="1x", dummy_cycles=8)
|
||||||
|
|
@ -68,11 +65,10 @@ class BaseSoC(SoCCore):
|
||||||
# Flash --------------------------------------------------------------------------------------------
|
# Flash --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def flash(offset, path):
|
def flash(offset, path):
|
||||||
from spiflash.serialflash import SerialFlashManager
|
# Create FTDI <--> SPI Flash proxy bitstream and load it.
|
||||||
platform = tec0117.Platform()
|
platform = tec0117.Platform()
|
||||||
flash = platform.request("spiflash", 0)
|
flash = platform.request("spiflash", 0)
|
||||||
bus = platform.request("spiflash", 1)
|
bus = platform.request("spiflash", 1)
|
||||||
|
|
||||||
module = Module()
|
module = Module()
|
||||||
module.comb += [
|
module.comb += [
|
||||||
flash.clk.eq(bus.clk),
|
flash.clk.eq(bus.clk),
|
||||||
|
|
@ -80,26 +76,25 @@ def flash(offset, path):
|
||||||
flash.mosi.eq(bus.mosi),
|
flash.mosi.eq(bus.mosi),
|
||||||
bus.miso.eq(flash.miso),
|
bus.miso.eq(flash.miso),
|
||||||
]
|
]
|
||||||
|
|
||||||
platform.build(module)
|
platform.build(module)
|
||||||
prog = platform.create_programmer()
|
prog = platform.create_programmer()
|
||||||
prog.load_bitstream('build/impl/pnr/project.fs')
|
prog.load_bitstream('build/impl/pnr/project.fs')
|
||||||
|
|
||||||
|
# Flash BIOS through proxy bitstream.
|
||||||
|
from spiflash.serialflash import SerialFlashManager
|
||||||
dev = SerialFlashManager.get_flash_device("ftdi://ftdi:2232/2")
|
dev = SerialFlashManager.get_flash_device("ftdi://ftdi:2232/2")
|
||||||
dev.TIMINGS['chip'] = (4, 60) # chip is too slow
|
dev.TIMINGS['chip'] = (4, 60) # Chip is too slow
|
||||||
print("Erasing flash...")
|
print("Erasing flash...")
|
||||||
dev.erase(0, -1)
|
dev.erase(0, -1)
|
||||||
|
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
bios = f.read()
|
bios = f.read()
|
||||||
|
|
||||||
print("Programming flash...")
|
print("Programming flash...")
|
||||||
dev.write(offset, bios)
|
dev.write(offset, bios)
|
||||||
|
|
||||||
# Build --------------------------------------------------------------------------------------------
|
# Build --------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="LiteX SoC on iCEBreaker")
|
parser = argparse.ArgumentParser(description="LiteX SoC on TEC0117")
|
||||||
parser.add_argument("--build", action="store_true", help="Build bitstream")
|
parser.add_argument("--build", action="store_true", help="Build bitstream")
|
||||||
parser.add_argument("--load", action="store_true", help="Load bitstream")
|
parser.add_argument("--load", action="store_true", help="Load bitstream")
|
||||||
parser.add_argument("--bios-flash-offset", default=0x00000, help="BIOS offset in SPI Flash (0x00000 default)")
|
parser.add_argument("--bios-flash-offset", default=0x00000, help="BIOS offset in SPI Flash (0x00000 default)")
|
||||||
|
|
@ -109,7 +104,7 @@ def main():
|
||||||
soc_core_args(parser)
|
soc_core_args(parser)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
soc= BaseSoC(
|
soc = BaseSoC(
|
||||||
bios_flash_offset = args.bios_flash_offset,
|
bios_flash_offset = args.bios_flash_offset,
|
||||||
sys_clk_freq = int(float(args.sys_clk_freq)),
|
sys_clk_freq = int(float(args.sys_clk_freq)),
|
||||||
**soc_core_argdict(args)
|
**soc_core_argdict(args)
|
||||||
|
|
@ -118,16 +113,11 @@ def main():
|
||||||
builder.build(run=args.build)
|
builder.build(run=args.build)
|
||||||
|
|
||||||
if args.flash:
|
if args.flash:
|
||||||
flash(
|
flash(args.bios_flash_offset, os.path.join(builder.software_dir, "bios", "bios.bin"))
|
||||||
args.bios_flash_offset,
|
|
||||||
os.path.join(builder.software_dir, "bios", "bios.bin"))
|
|
||||||
|
|
||||||
if args.load:
|
if args.load:
|
||||||
prog = soc.platform.create_programmer()
|
prog = soc.platform.create_programmer()
|
||||||
prog.load_bitstream(
|
prog.load_bitstream(os.path.join(builder.gateware_dir, "impl", "pnr", "project.fs"), args.flash)
|
||||||
os.path.join(builder.gateware_dir, "impl", "pnr", "project.fs"),
|
|
||||||
args.flash)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue