Skip to content

Commit

Permalink
tools: Read the BIOS maxsize from the SoC.
Browse files Browse the repository at this point in the history
Means the larger BIOS size on or1k should be understood by `mkimage.py`
command.

Fixes timvideos#43.
  • Loading branch information
mithro committed Sep 8, 2018
1 parent e260e6e commit 8c17b79
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
6 changes: 4 additions & 2 deletions flash.py
Expand Up @@ -18,6 +18,8 @@ def main():

builddir = make.get_builddir(args)
platform = make.get_platform(args)
soc = make.get_soc(args, platform)
bios_maxsize = make.get_bios_maxsize(args, soc)

if args.mode == 'image':
filename = make.get_image(builddir, "flash")
Expand All @@ -32,15 +34,15 @@ def main():
elif args.mode == 'bios':
filename = make.get_bios(builddir, "flash")
address_start = platform.gateware_size
address_end = platform.gateware_size + make.BIOS_SIZE
address_end = platform.gateware_size + bios_maxsize

elif args.mode == 'firmware':
if args.override_firmware:
filename = args.override_firmware
else:
filename = make.get_firmware(builddir, "flash")

address_start = platform.gateware_size + make.BIOS_SIZE
address_start = platform.gateware_size + bios_maxsize
address_end = platform.spiflash_total_size

elif args.mode == 'other':
Expand Down
23 changes: 17 additions & 6 deletions make.py
Expand Up @@ -7,8 +7,6 @@
from litex.soc.integration.soc_sdram import *
from litex.soc.integration.builder import *

BIOS_SIZE = 0x8000


def get_args(parser, platform='opsis', target='hdmi2usb'):
parser.add_argument("--platform", action="store", default=os.environ.get('PLATFORM', platform))
Expand Down Expand Up @@ -52,6 +50,14 @@ def get_platform(args):
return Platform(**dict(args.platform_option))


def get_soc(args, platform):
exec("from targets.{}.{} import SoC".format(args.platform, args.target.lower(), args.target), globals())
soc = SoC(platform, ident=SoC.__name__, **soc_sdram_argdict(args), **dict(args.target_option))
if hasattr(soc, 'configure_iprange'):
soc.configure_iprange(args.iprange)
return soc


def get_prog(args, platform):
assert platform is not None
prog = platform.create_programmer()
Expand Down Expand Up @@ -82,6 +88,14 @@ def get_bios(builddir, filetype="flash"):
assert False, "Unknown file type %s" % filetype


def get_bios_maxsize(args, soc):
for name, start, size in soc.get_memory_regions():
if name == 'rom':
return size
# FIXME: Hard coded value?
return 0x8000


def get_firmware(builddir, filetype="flash"):
basedir = os.path.join(builddir, "software", "firmware", "firmware")
if filetype in ("load",):
Expand All @@ -104,10 +118,7 @@ def main():

platform = get_platform(args)

exec("from targets.{}.{} import SoC".format(args.platform, args.target.lower(), args.target), globals())
soc = SoC(platform, ident=SoC.__name__, **soc_sdram_argdict(args), **dict(args.target_option))
if hasattr(soc, 'configure_iprange'):
soc.configure_iprange(args.iprange)
soc = get_soc(args, platform)

builddir = get_builddir(args)
testdir = get_testdir(args)
Expand Down
6 changes: 4 additions & 2 deletions mkimage.py
Expand Up @@ -68,10 +68,12 @@ def main():
"Firmware must be a MiSoC .fbi image.")

platform = make.get_platform(args)
soc = make.get_soc(args, platform)
bios_size = make.get_bios_maxsize(args, soc)

gateware_pos = 0
bios_pos = platform.gateware_size
firmware_pos = platform.gateware_size + make.BIOS_SIZE
firmware_pos = platform.gateware_size + bios_size

print()
with open(output_file, "wb") as f:
Expand All @@ -97,7 +99,7 @@ def main():
bios = "Skipped"

# LiteX BIOS
assert len(bios_data) < make.BIOS_SIZE
assert len(bios_data) < bios_size
f.seek(bios_pos)
f.write(bios_data)
print((" BIOS @ 0x{:08x} ({:10} bytes) {:60}"
Expand Down

0 comments on commit 8c17b79

Please sign in to comment.