software/demo: Add --mem parameter to allow specifying Memory region where code will be loaded/executed.

This commit is contained in:
Florent Kermarrec 2022-04-07 11:22:12 +02:00
parent 20c9bba8da
commit 5222e7fc1a
1 changed files with 8 additions and 2 deletions

View File

@ -3,16 +3,19 @@
#
# This file is part of LiteX.
#
# Copyright (c) 2020 Florent Kermarrec <florent@enjoy-digital.fr>
# Copyright (c) 2020-2022 Florent Kermarrec <florent@enjoy-digital.fr>
# SPDX-License-Identifier: BSD-2-Clause
import os
import argparse
from litex.build.tools import replace_in_file
def main():
parser = argparse.ArgumentParser(description="LiteX Bare Metal Demo App.")
parser.add_argument("--build-path", help="Target's build path (ex build/board_name).", required=True)
parser.add_argument("--with-cxx", action="store_true", help="Enable CXX support.")
parser.add_argument("--mem", default="main_ram", help="Memory Region from which code will be executed.")
args = parser.parse_args()
# Create demo directory
@ -21,6 +24,9 @@ def main():
# Copy contents to demo directory
os.system(f"cp {os.path.abspath(os.path.dirname(__file__))}/* demo")
# Update memory region.
replace_in_file("demo/linker.ld", "main_ram", args.mem)
# Compile demo
build_path = args.build_path if os.path.isabs(args.build_path) else os.path.join("..", args.build_path)
os.system(f"export BUILD_DIR={build_path} && {'export WITH_CXX=1 &&' if args.with_cxx else ''} cd demo && make")