Skip to content

Commit

Permalink
[#53309] scripts: run_renode: Fix board name, add debug option
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Torhan <mtorhan@antmicro.com>
  • Loading branch information
m-torhan authored and glatosinski committed Apr 3, 2024
1 parent c3fe6d9 commit 6ad1a4c
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions scripts/run_renode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Python script for running Kenning Zephyr Runtime in Renode.
"""

import argparse
import re

import serial
Expand Down Expand Up @@ -55,7 +56,11 @@ def get_kenning_communication_uart(boards: str) -> str:


if __name__ == "__main__":
board = get_cmake_var("BOARD:STRING")
parser = argparse.ArgumentParser(__doc__)
parser.add_argument("--debug", action="store_true", help="Enable GDB server")
args = parser.parse_args()

board = get_cmake_var("BOARD:STRING").split("/")[0]
build_path = get_cmake_var("APPLICATION_BINARY_DIR:PATH")
project_name = get_cmake_var("CMAKE_PROJECT_NAME:STATIC")

Expand All @@ -65,6 +70,13 @@ def get_kenning_communication_uart(boards: str) -> str:
platform.load_repl(f"{build_path}/{board}.repl")
platform.load_elf(f"{build_path}/zephyr/zephyr.elf")

if args.debug:
platform.StartGdbServer(3333)
print("gdb server started at :3333")
print("Press ENTER to start simulation")

input()

# create pty terminal for UART with logs
console_uart = get_zephyr_console_uart(board)
emulation.CreateUartPtyTerminal("console_uart_term", "/tmp/uart-log")
Expand All @@ -88,11 +100,19 @@ def get_kenning_communication_uart(boards: str) -> str:
print("Starting Renode simulation. Press CTRL+C to exit.")
emulation.StartAll()

logs_tail = ""
while True:
try:
logs = console.read_all().decode()
logs = console.read_all().decode(errors="ignore")

print(logs, end="", flush=True)
if "demo_app" == project_name and "inference done" in logs:

logs_tail = logs_tail.split("\n")[-1] + logs if logs_tail else logs
if (
"demo_app" == project_name
and "I: inference done" in logs_tail
and "\n" in logs_tail
):
break
except KeyboardInterrupt:
print("Exiting...")
Expand Down

0 comments on commit 6ad1a4c

Please sign in to comment.