-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.py
More file actions
74 lines (56 loc) · 2.42 KB
/
template.py
File metadata and controls
74 lines (56 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# %% [markdown]
"""
[](https://renode.io)
[](https://colab.research.google.com/github/antmicro/test-colabs/blob/main/boards/{{platform}}_{{sample_name}}.ipynb) [](https://github.com/antmicro/test-colabs/blob/main/boards/{{platform}}_{{sample_name}}.ipynb) [](https://github.com/antmicro/test-colabs/blob/main/boards/{{platform}}_{{sample_name}}.py)
"""
# %% [markdown]
"""
## Install requirements
"""
# %%
! pip install -q git+https://github.com/antmicro/renode-colab-tools.git
! pip install -q git+https://github.com/antmicro/renode-run.git
! pip install -q git+https://github.com/antmicro/pyrenode3.git
! renode-run download --renode-variant dotnet-portable
# %% [markdown]
"""## Start Renode"""
# %%
import os
from renode_run import get_default_renode_path
from renode_run.utils import RenodeVariant
os.environ['PYRENODE_RUNTIME'] = 'coreclr'
os.environ['PYRENODE_BIN'] = get_default_renode_path(variant=RenodeVariant.DOTNET_PORTABLE)
from pyrenode3.wrappers import Emulation, Monitor, TerminalTester, LEDTester
from Antmicro.Renode.Peripherals.UART import UARTBackend
from Antmicro.Renode.Analyzers import LoggingUartAnalyzer
from System import String
currentDirectory = os.getcwd()
emulation = Emulation()
monitor = Monitor()
emulation.BackendManager.SetPreferredAnalyzer(UARTBackend, LoggingUartAnalyzer)
# %% [markdown]
"""## Setup a script"""
# %%
%%writefile script.resc
{{script}}
# %% [markdown]
"""## Run the sample"""
# %%
{{sample}}
# %% [markdown]
"""## UART output"""
# %%
from renode_colab_tools import asciinema
asciinema.display_asciicast('{{sample_name}}-asciinema')
# %% [markdown]
"""## Renode metrics analysis"""
# %%
import sys
from pathlib import Path
from renode_run import get_default_renode_path
sys.path.append(str(Path(get_default_renode_path()).parent))
from renode_colab_tools import metrics
from tools.metrics_analyzer.metrics_parser import MetricsParser
metrics.init_notebook_mode(connected=False)
parser = MetricsParser('metrics.dump')
metrics.display_metrics(parser)