software/demo: Add --mem parameter to allow specifying Memory region where code will be loaded/executed.
This commit is contained in:
parent
20c9bba8da
commit
5222e7fc1a
|
@ -3,16 +3,19 @@
|
||||||
#
|
#
|
||||||
# This file is part of LiteX.
|
# 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
|
# SPDX-License-Identifier: BSD-2-Clause
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
|
from litex.build.tools import replace_in_file
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description="LiteX Bare Metal Demo App.")
|
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("--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("--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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Create demo directory
|
# Create demo directory
|
||||||
|
@ -21,6 +24,9 @@ def main():
|
||||||
# Copy contents to demo directory
|
# Copy contents to demo directory
|
||||||
os.system(f"cp {os.path.abspath(os.path.dirname(__file__))}/* demo")
|
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
|
# Compile demo
|
||||||
build_path = args.build_path if os.path.isabs(args.build_path) else os.path.join("..", args.build_path)
|
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")
|
os.system(f"export BUILD_DIR={build_path} && {'export WITH_CXX=1 &&' if args.with_cxx else ''} cd demo && make")
|
||||||
|
|
Loading…
Reference in New Issue