kosagi_fomu: Handle bios_flash_offset in flash function and make DFU flash offset explicit.

This commit is contained in:
Florent Kermarrec 2021-07-21 11:41:35 +02:00
parent fbcecee1f8
commit a455713e0c
1 changed files with 12 additions and 9 deletions

View File

@ -123,15 +123,16 @@ def flash(build_dir, build_name, bios_flash_offset):
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):
# 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)
)