From a455713e0c75538832d01fc35bf50a4e1d4a2820 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 21 Jul 2021 11:41:35 +0200 Subject: [PATCH] kosagi_fomu: Handle bios_flash_offset in flash function and make DFU flash offset explicit. --- litex_boards/targets/kosagi_fomu.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/litex_boards/targets/kosagi_fomu.py b/litex_boards/targets/kosagi_fomu.py index aa81633..4751fc7 100755 --- a/litex_boards/targets/kosagi_fomu.py +++ b/litex_boards/targets/kosagi_fomu.py @@ -120,18 +120,19 @@ class BaseSoC(SoCCore): def flash(build_dir, build_name, bios_flash_offset): from litex.build.dfu import DFUProg prog = DFUProg(vid="1209", pid="5bf0") - bitstream = open(f"{build_dir}/gateware/{build_name}.bin", "rb") - bios = open(f"{build_dir}/software/bios/bios.bin", "rb") - image = open(f"{build_dir}/image.bin", "wb") - # Copy bitstream at 0x00000000 - for i in range(0x00000000, 0x0020000): + bitstream = open(f"{build_dir}/gateware/{build_name}.bin", "rb") + bios = open(f"{build_dir}/software/bios/bios.bin", "rb") + image = open(f"{build_dir}/image.bin", "wb") + # Copy bitstream at 0. + assert bios_flash_offset >= 128*kB + for i in range(0, bios_flash_offset): b = bitstream.read(1) if not b: image.write(0xff.to_bytes(1, "big")) else: image.write(b) - # Copy bios at 0x00020000 - for i in range(0x00000000, 0x00010000): + # Copy bios at bios_flash_offset. + for i in range(0, 32*kB): b = bios.read(1) if not b: image.write(0xff.to_bytes(1, "big")) @@ -148,14 +149,16 @@ def main(): parser = argparse.ArgumentParser(description="LiteX SoC on Fomu") parser.add_argument("--build", action="store_true", help="Build bitstream") parser.add_argument("--sys-clk-freq", default=12e6, help="System clock frequency (default: 12MHz)") - parser.add_argument("--bios-flash-offset", default=0x60000, help="BIOS offset in SPI Flash (default: 0x60000)") + parser.add_argument("--bios-flash-offset", default=0x20000, help="BIOS offset in SPI Flash (default: 0x20000)") parser.add_argument("--flash", action="store_true", help="Flash Bitstream") builder_args(parser) soc_core_args(parser) args = parser.parse_args() + dfu_flash_offset = 0x40000 + soc = BaseSoC( - bios_flash_offset = args.bios_flash_offset, + bios_flash_offset = dfu_flash_offset + args.bios_flash_offset, sys_clk_freq = int(float(args.sys_clk_freq)), **soc_core_argdict(args) )