EIE4-FYP/demo/demo.py

38 lines
1.3 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
#
# This file is part of LiteX.
#
# Copyright (c) 2020-2022 Florent Kermarrec <florent@enjoy-digital.fr>
# SPDX-License-Identifier: BSD-2-Clause
import os
import sys
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)
2023-05-12 13:01:16 +00:00
# parser.add_argument("--with-cxx", action="store_true", help="Enable CXX support.")
parser.add_argument("--mem", default="main_ram", help="Memory Region where code will be loaded/executed.")
args = parser.parse_args()
# 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)
2023-05-12 13:01:16 +00:00
os.system(f"export BUILD_DIR={build_path} && export WITH_CXX=1 && cd demo && make")
# Copy demo.bin
os.system("cp demo/demo.bin ./")
# Prepare flash boot image.
# python3 = sys.executable or "python3" # Nix specific: Reuse current Python executable if available.
# os.system(f"{python3} -m litex.soc.software.crcfbigen demo.bin -o demo.fbi --fbi --little") # FIXME: Endianness.
if __name__ == "__main__":
main()