Skip to content

Commit 8f4b207

Browse files
author
Qinghao Shi
authored
Update Iris API replace CADI API (#6)
* update IRIS API replace CADI API * Add GHA CI Test * update config file
1 parent 896ab6e commit 8f4b207

File tree

16 files changed

+256
-398
lines changed

16 files changed

+256
-398
lines changed

.github/ci_test_settings.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"COMMON": {
3+
"IRIS_path": "/opt/FVP_Corstone_SSE-300_Ethos-U55/Iris/Python/"
4+
},
5+
"FVP_CS300_U55": {
6+
"model_binary": "/opt/FVP_Corstone_SSE-300_Ethos-U55/models/Linux64_GCC-6.4//FVP_Corstone_SSE-300_Ethos-U55",
7+
"terminal_component": "component.FVP_MPS3_Corstone_SSE_300.mps3_board.telnetterminal0",
8+
"configs": {
9+
"MPS3": "MPS3.conf"
10+
}
11+
}
12+
}

.github/workflows/PR-Build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Pull-Request Test
2+
name: PR-Check Build and Run
3+
4+
on:
5+
# Triggers the workflow on pull request
6+
pull_request:
7+
8+
jobs:
9+
10+
Corstone300:
11+
runs-on: ubuntu-latest
12+
# Run this this job inside container
13+
container: mbedos/mbed-os-env-fm:corstone300
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
19+
- name: Unit Test
20+
run: python setup.py test
21+
22+
- name: Install Test
23+
run: |
24+
rm fm_agent/settings.json
25+
cp .github/ci_test_settings.json fm_agent/settings.json
26+
python setup.py install
27+
28+
- name: Run Self Test
29+
run: mbedfm --self-test

README.md

Lines changed: 39 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,19 @@ If user only need to run mbed OS applications or examples rather than Greentea t
1111

1212

1313
## Requirements
14-
1. Make sure you have Arm Fast Models Libraries files installed to your host machines, as well as the Fast Models PyCADI.
14+
1. Make sure you have Arm Fast Models FVPs as well as the Fast Models Iris python modules installed. This Package is not including neither of them. Also a valid license to the Fastmodels could be required.
1515

1616
>please referencing [Fast Models User Guide](https://developer.arm.com/docs/100965/latest)
1717
18-
2. A valid Fast Models license been set up correctly.
19-
20-
>please referencing [Fast Models User Guide](https://developer.arm.com/docs/100965/latest)
21-
22-
3. Greentea version 1.5.0 or later
18+
2. Use Greentea and mbedhtrun version 1.5.0 or later
2319
```
24-
pip install mbed-greentea -U
20+
# Check versions
2521
mbedgt --version
26-
```
27-
4. Htrun version 1.4.1 or later
28-
```
29-
pip install mbed-host-tests -U
3022
mbedhtrun --version
23+
24+
# Update mbedgt and mbedhtrun
25+
pip install mbed-greentea -U
26+
pip install mbed-host-tests -U
3127
```
3228

3329
## Download
@@ -36,16 +32,15 @@ git clone https://github.com/ARMmbed/mbed-fastmodel-agent.git
3632
cd mbed-fastmodel-agent
3733
```
3834

39-
## Settings before installation
35+
## Configurations before installation
4036
1. Edit the configuration file `fm_agent\settings.json`
41-
2. Change `model_lib_path` value in the `GLOBAL` section to your Fast Models installation folder (where contains all fastmodel libs).
42-
3. Change `PyCADI_path` value to PyCADI folder, alternatively you can have `PVLIB_HOME` environment variable set on your host
43-
4. Optional: edit individual models if necessary
44-
5. Optional: add configs to models if necessary
37+
3. Change `IRIS_path` value to IRIS Python folder
38+
3. Edit individual models binarys file path
39+
4. Optional: customize configs to models
4540

4641
## Installation
4742
```
48-
python setup.py install
43+
sudo python setup.py install
4944
```
5045
*NOTE. you will need to re-run the install command after you changed the "settings.json" or any config file*
5146

@@ -57,29 +52,24 @@ python setup.py install
5752
```
5853
you should be able to see a table like:
5954
```
60-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
61-
| MODEL NAME | MODEL LIB full path | CONFIG NAME | CONFIG FILE | AVAILABILITY |
62-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
63-
| | | DEFAULT | DEFAULT.conf | YES |
64-
| FVP_MPS2_M0 | C:\work\model_libs\FVP_MPS2_Cortex-M0.dll | FAST | FAST.conf | YES |
65-
| | | NETWORK | NETWORK.conf | YES |
66-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
67-
| | | DEFAULT | DEFAULT.conf | YES |
68-
| FVP_MPS2_M0P | C:\work\model_libs\FVP_MPS2_Cortex-M0plus.dll | FAST | FAST.conf | YES |
69-
| | | NETWORK | NETWORK.conf | YES |
70-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
71-
| | | DEFAULT | DEFAULT.conf | YES |
72-
| FVP_MPS2_M3 | C:\work\model_libs\FVP_MPS2_Cortex-M3.dll | FAST | FAST.conf | YES |
73-
| | | NETWORK | NETWORK.conf | YES |
74-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
75-
| | | DEFAULT | DEFAULT.conf | YES |
76-
| FVP_MPS2_M4 | C:\work\model_libs\FVP_MPS2_Cortex-M4.dll | FAST | FAST.conf | YES |
77-
| | | NETWORK | NETWORK.conf | YES |
78-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
79-
| | | DEFAULT | DEFAULT.conf | YES |
80-
| FVP_MPS2_M7 | C:\work\model_libs\FVP_MPS2_Cortex-M7.dll | FAST | FAST.conf | YES |
81-
| | | NETWORK | NETWORK.conf | YES |
82-
+--------------+-----------------------------------------------+-------------+--------------+--------------+
55+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
56+
| MODEL NAME | MODEL Binary Full Path | CONFIG NAME | CONFIG FILE | AVAILABILITY |
57+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
58+
| FVP_MPS2_M0 | C:\work\models\FVP_MPS2_Cortex-M0.exe | MPS2 | MPS2.conf | YES |
59+
| | | COVERAGE | COVERAGE.conf | YES |
60+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
61+
| FVP_MPS2_M0P | C:\work\models\FVP_MPS2_Cortex-M0plus.exe | MPS2 | MPS2.conf | YES |
62+
| | | COVERAGE | COVERAGE.conf | YES |
63+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
64+
| FVP_MPS2_M3 | C:\work\models\FVP_MPS2_Cortex-M3.exe | MPS2 | MPS2.conf | YES |
65+
| | | COVERAGE | COVERAGE.conf | YES |
66+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
67+
| FVP_MPS2_M4 | C:\work\models\FVP_MPS2_Cortex-M4.exe | MPS2 | MPS2.conf | YES |
68+
| | | COVERAGE | COVERAGE.conf | YES |
69+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
70+
| FVP_MPS2_M7 | C:\work\models\FVP_MPS2_Cortex-M7.exe | MPS2 | MPS2.conf | YES |
71+
| | | COVERAGE | COVERAGE.conf | YES |
72+
+--------------+-----------------------------------------------+-------------+---------------+--------------+
8373
```
8474
### Self test for the settings
8575
```
@@ -92,13 +82,13 @@ This will try to launch every model in the above list to verify them, so will ta
9282
```
9383
mbedgt --fm <model_name>:<config_name>
9484
```
95-
>e.g. `mbedgt --fm FVP_MPS2_M3:DEFAULT`
85+
>e.g. `mbedgt --fm FVP_MPS2_M3:MPS2`
9686
9787
### run mbed test with htrun
9888
```
99-
mbedhtrun --fm <config_name> -m <model_name> -f <test_image>
89+
mbedhtrun --fm <config_name> -m <model_name> -f <test_image> <-e host_test_path>
10090
```
101-
>e.g. `mbedhtrun --fm DEFAULT -m FVP_MPS2_M3 -f test.elf`
91+
>e.g. `mbedhtrun -m FVP_MPS2_M3 --fm MPS2 -f test.elf -e ./host_tests`
10292
10393
*<model_name> : The name to fastmodel target supported in mbed os*
10494

@@ -108,9 +98,10 @@ This will try to launch every model in the above list to verify them, so will ta
10898

10999
The mbed fastmodel_agent module allow user to configure each individual module via a config file.
110100
by default, 3 config files are provided:
111-
* DEFAULT - default settings
112-
* FAST - based on default turned off speed limit
113-
* NETWORK - based on default enabled Ethernet
101+
* MPS2 - default settings for MPS2 based platforms
102+
* MPS3 - default settings for MPS3 based platforms
103+
* COVERAGE - configuration for MPS2 Code Coverage Test
104+
114105

115106
## change config files
116107

@@ -123,9 +114,9 @@ The config files are standard Fast Models config file. for more detail about det
123114

124115
Users are able to add their own customized config file to the `mbed-fastmodel-agent\fm_agent\configs` directory.
125116

126-
Then users need to edit `mbed-fastmodel-agent\fm_agent\settings.json` file either in `GLOBAL` section or individual models.
117+
Then users need to edit `mbed-fastmodel-agent\fm_agent\settings.json` file either in `COMMON` section or individual models.
127118

128-
Key `configs_add` can be added for additional config files for each model, Or Key `config` can be added to overwrite `GLOBAL` config files.
119+
Key `configs_add` can be added for additional config files for each model, Or Key `config` can be added to overwrite `COMMON` config files.
129120

130121
## Known limitations:
131122
1. Fast Models normally have 3 or 4 serial terminal ports. But currently only one port is used at moment.

fm_agent/configs/COVERAGE.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ fvp_mps2.mps2_visualisation.rate_limit-enable=0
1919
## Enable Ethernet Port
2020
fvp_mps2.hostbridge.userNetworking=1
2121
fvp_mps2.smsc_91c111.enabled=1
22+
23+
## Turn off GUI windows
24+
fvp_mps2.mps2_visualisation.disable-visualisation=1

fm_agent/configs/DEFAULT.conf

Lines changed: 0 additions & 15 deletions
This file was deleted.

fm_agent/configs/FAST.conf renamed to fm_agent/configs/MPS2.conf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
fvp_mps2.telnetterminal1.quiet=1
33
fvp_mps2.telnetterminal2.quiet=1
44

5-
65
## Control the output format of the telnet terminal
76
fvp_mps2.telnetterminal0.mode=raw
87

@@ -16,3 +15,7 @@ fvp_mps2.telnetterminal0.start_telnet=0
1615

1716
## turn the rate limite off
1817
fvp_mps2.mps2_visualisation.rate_limit-enable=0
18+
19+
## Enable Ethernet Port
20+
fvp_mps2.hostbridge.userNetworking=1
21+
fvp_mps2.smsc_91c111.enabled=1

fm_agent/configs/MPS3.conf

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## Turn off terminal1 terminal2 and termimal5, keep terminal0 open
2+
mps3_board.telnetterminal1.quiet=1
3+
mps3_board.telnetterminal2.quiet=1
4+
mps3_board.telnetterminal5.quiet=1
5+
6+
## Control the output format of the telnet terminal
7+
mps3_board.telnetterminal0.mode=raw
8+
## Suppress the telnet/xterm to be launched, so that model agent can talk to the port
9+
mps3_board.telnetterminal0.start_telnet=0
10+
11+
12+
## Turn the rate limite off, make FVP runs as fast as possiable
13+
mps3_board.visualisation.rate_limit-enable=0
14+
15+
16+
## Turn on user Networking
17+
mps3_board.smsc_91c111.enabled=1
18+
mps3_board.hostbridge.userNetworking=1
19+
20+
## Turn off GUI windows
21+
mps3_board.visualisation.disable-visualisation=1

fm_agent/configs/NETWORK.conf

Lines changed: 0 additions & 19 deletions
This file was deleted.

fm_agent/fm_agent.py

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,22 +64,30 @@ def setup_simulator(self, model_name, model_config):
6464
self.logger.prn_err("Please provided the name to a fastmodel!!")
6565
self.__guide()
6666
raise SimulatorError("fastmodel_name not provided!")
67-
self.model_lib = self.configuration.get_model_lib(self.fastmodel_name)
67+
self.model_binary = self.configuration.get_model_binary(self.fastmodel_name)
6868

69-
if not self.model_lib:
70-
self.logger.prn_err("NO model_lib available for '%s'"% self.fastmodel_name)
69+
if not self.model_binary:
70+
self.logger.prn_err("NO model_binary available for '%s'"% self.fastmodel_name)
7171
self.__guide()
7272
raise SimulatorError("fastmodel '%s' not available" % (self.fastmodel_name))
7373

7474
config_dict = self.configuration.get_configs(self.fastmodel_name)
7575

7676
if config_dict and self.config_name in config_dict:
77-
self.model_params = self.configuration.parse_params_file(config_dict[self.config_name])
77+
config_file = config_dict[self.config_name]
78+
self.model_config_file = os.path.join( os.path.dirname(__file__) ,"configs" , config_file )
79+
7880
elif os.path.exists(os.path.join( os.getcwd(), self.config_name )):
79-
self.model_params = self.configuration.parse_params_file(self.config_name,in_module=False)
81+
self.model_config_file = os.path.join( os.getcwd() , config_name )
8082
else:
8183
self.__guide()
8284
raise SimulatorError("No config %s avaliable for fastmodel %s" % (self.config_name,self.fastmodel_name))
85+
86+
self.model_terminal = self.configuration.get_model_terminal_comp(self.fastmodel_name)
87+
88+
if not self.model_terminal:
89+
self.logger.prn_err("NO terminal_compoment defined for '%s'"% self.fastmodel_name)
90+
raise SimulatorError("fastmodel '%s' not defined terminal compoment" % (self.fastmodel_name))
8391

8492
def __connect_terminal(self):
8593
""" connect socket terminal to a launched fastmodel"""
@@ -105,13 +113,16 @@ def is_simulator_alive(self):
105113
def start_simulator(self):
106114
""" launch given fastmodel with configs """
107115
if check_import():
108-
import fm.debug
109-
self.model = fm.debug.LibraryModel(self.model_lib, self.model_params)
116+
import iris.debug
117+
proc, IRIS_port, outs = launch_FVP_IRIS(self.model_binary, self.model_config_file)
118+
print(outs)
119+
self.model = iris.debug.NetworkModel('localhost',IRIS_port)
110120
# check which host socket port is used for terminal0
111-
terminal = self.model.get_target('fvp_mps2.telnetterminal0')
112-
self.port = terminal.read_register('Port')
121+
terminal = self.model.get_target(self.model_terminal)
122+
self.port = terminal.read_register('Default.Port')
113123
self.host = "localhost"
114124
self.image = None
125+
115126
return True
116127
else:
117128
raise SimulatorError("fastmodel product was NOT installed correctly")
@@ -151,11 +162,16 @@ def reset_simulator(self):
151162
self.__closeConnection()
152163
self.model.release(shutdown=True)
153164
time.sleep(1)
154-
import fm.debug
155-
self.model = fm.debug.LibraryModel(self.model_lib, self.model_params)
165+
import iris.debug
166+
167+
proc, IRIS_port, outs = launch_FVP_IRIS(self.model_binary, self.model_config_file)
168+
if IRIS_port==0:
169+
print(outs)
170+
return False
171+
self.model = iris.debug.NetworkModel('localhost',IRIS_port)
156172
# check which host socket port is used for terminal0
157-
terminal = self.model.get_target('fvp_mps2.telnetterminal0')
158-
self.port = terminal.read_register('Port')
173+
terminal = self.model.get_target(self.model_terminal)
174+
self.port = terminal.read_register('Default.Port')
159175
cpu = self.model.get_cpus()[0]
160176
if self.image:
161177
cpu.load_application(self.image)
@@ -172,12 +188,12 @@ def read(self):
172188
if not self.__socketConnected():
173189
return None
174190

175-
data = str()
191+
data = bytearray()
176192
read_stop = False
177193

178194
while not read_stop:
179195
try:
180-
char=''
196+
char=bytearray()
181197
char = self.socket.recv(1)
182198
except socket.timeout as eto:
183199
read_stop=True
@@ -205,7 +221,7 @@ def write(self, payload, log=False):
205221

206222
try:
207223
for char in payload:
208-
self.socket.sendall(char)
224+
self.socket.sendall(char.encode())
209225
time.sleep(0.01)
210226
if log:
211227
self.logger.prn_txd(payload)
@@ -325,16 +341,12 @@ def list_avaliable_models(self):
325341
""" return a dictionary of models and configs """
326342
return self.configuration.get_all_configs()
327343

328-
def list_model_lib(self, model_name):
329-
""" return model lib full path of give model_name """
330-
return self.configuration.get_model_lib(model_name)
344+
def list_model_binary(self, model_name):
345+
""" return model binary full path of give model_name """
346+
return self.configuration.get_model_binary(model_name)
331347

332348
def check_config_exist(self,filename):
333349
""" return the presents of give config name
334350
"""
335-
336351
filepath = os.path.join( os.path.dirname(__file__), "configs" , filename )
337-
338-
return os.path.exists(filepath)
339-
340-
352+
return os.path.exists(filepath)

0 commit comments

Comments
 (0)