15
15
16
16
logger = logging .getLogger (__name__ )
17
17
18
+
18
19
# Kill parent process and all child processes (if started)
19
20
def _kill (proc ):
20
21
try :
21
22
for child in psutil .Process (proc .pid ).children (recursive = True ):
22
23
child .kill ()
23
24
proc .kill ()
24
25
except Exception as e :
25
- logger .exception (f' Could not kill JLinkSWOViewerCLExe - { e } ' )
26
+ logger .exception (f" Could not kill JLinkSWOViewerCLExe - { e } " )
26
27
27
28
28
29
def test_swo_logging (dut : DeviceAdapter ):
@@ -37,53 +38,64 @@ def test_swo_logging(dut: DeviceAdapter):
37
38
COLLECT_TIMEOUT = 10.0
38
39
EXPECTED = rf"log_swo: \d+: Hello from { PLATFORM } "
39
40
41
+ NRF54L_JLINK_SCRIPT = Path (__file__ ).parent .resolve () / "nrf54l_swo.script"
42
+
40
43
logger .debug (f"{ dut .device_config = } " )
41
44
42
45
SWO_CONFIG = {
43
- 'nrf52dk/nrf52832' : {
44
- 'device' : 'nRF52832_xxAA' ,
45
- 'cpufreq' : 64000000 ,
46
- 'swofreq' : 1000000 ,
46
+ "nrf52dk/nrf52832" : {
47
+ "device" : "nRF52832_xxAA" ,
48
+ "cpufreq" : 64000000 ,
49
+ "swofreq" : 1000000 ,
50
+ "args" : "" ,
47
51
},
48
- 'nrf52840dk/nrf52840' : {
49
- 'device' : 'nRF52840_xxAA' ,
50
- 'cpufreq' : 64000000 ,
51
- 'swofreq' : 1000000 ,
52
+ "nrf52840dk/nrf52840" : {
53
+ "device" : "nRF52840_xxAA" ,
54
+ "cpufreq" : 64000000 ,
55
+ "swofreq" : 1000000 ,
56
+ "args" : "" ,
52
57
},
53
- 'nrf5340dk/nrf5340/cpuapp' : {
54
- 'device' : 'nRF5340_xxAA_APP' ,
55
- 'cpufreq' : 64000000 ,
56
- 'swofreq' : 1000000 ,
58
+ "nrf5340dk/nrf5340/cpuapp" : {
59
+ "device" : "nRF5340_xxAA_APP" ,
60
+ "cpufreq" : 64000000 ,
61
+ "swofreq" : 1000000 ,
62
+ "args" : "" ,
57
63
},
58
- 'nrf54l15dk/nrf54l05/cpuapp' : {
59
- 'device' : 'nRF54L05_M33' ,
60
- 'cpufreq' : 128000000 ,
61
- 'swofreq' : 1000000 ,
64
+ "nrf54l15dk/nrf54l05/cpuapp" : {
65
+ "device" : "nRF54L05_M33" ,
66
+ "cpufreq" : 128000000 ,
67
+ "swofreq" : 1000000 ,
68
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
62
69
},
63
- 'nrf54l15dk/nrf54l10/cpuapp' : {
64
- 'device' : 'nRF54L10_M33' ,
65
- 'cpufreq' : 128000000 ,
66
- 'swofreq' : 1000000 ,
70
+ "nrf54l15dk/nrf54l10/cpuapp" : {
71
+ "device" : "nRF54L10_M33" ,
72
+ "cpufreq" : 128000000 ,
73
+ "swofreq" : 1000000 ,
74
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
67
75
},
68
- 'nrf54l15dk/nrf54l15/cpuapp' : {
69
- 'device' : 'nRF54L15_M33' ,
70
- 'cpufreq' : 128000000 ,
71
- 'swofreq' : 1000000 ,
76
+ "nrf54l15dk/nrf54l15/cpuapp" : {
77
+ "device" : "nRF54L15_M33" ,
78
+ "cpufreq" : 128000000 ,
79
+ "swofreq" : 1000000 ,
80
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
72
81
},
73
- 'nrf54lm20dk/nrf54lm20a/cpuapp' : {
74
- 'device' : 'NRF54LM20A_M33' ,
75
- 'cpufreq' : 128000000 ,
76
- 'swofreq' : 1000000 ,
82
+ "nrf54lm20dk/nrf54lm20a/cpuapp" : {
83
+ "device" : "NRF54LM20A_M33" ,
84
+ "cpufreq" : 128000000 ,
85
+ "swofreq" : 1000000 ,
86
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
77
87
},
78
- 'nrf54lv10dk/nrf54lv10a/cpuapp' : {
79
- 'device' : 'NRF54LV10A_M33' ,
80
- 'cpufreq' : 128000000 ,
81
- 'swofreq' : 1000000 ,
88
+ "nrf54lv10dk/nrf54lv10a/cpuapp" : {
89
+ "device" : "NRF54LV10A_M33" ,
90
+ "cpufreq" : 128000000 ,
91
+ "swofreq" : 1000000 ,
92
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
82
93
},
83
- '[email protected] /nrf54lv10a/cpuapp' : {
84
- 'device' : 'NRF54LV10A_M33' ,
85
- 'cpufreq' : 128000000 ,
86
- 'swofreq' : 1000000 ,
94
+ "[email protected] /nrf54lv10a/cpuapp" : {
95
+ "device" : "NRF54LV10A_M33" ,
96
+ "cpufreq" : 128000000 ,
97
+ "swofreq" : 1000000 ,
98
+ "args" : f"-jlinkscriptfile { NRF54L_JLINK_SCRIPT } " ,
87
99
},
88
100
}
89
101
@@ -103,13 +115,14 @@ def test_swo_logging(dut: DeviceAdapter):
103
115
cmd += f" -cpufreq { SWO_CONFIG [PLATFORM ]['cpufreq' ]} "
104
116
cmd += f" -swofreq { SWO_CONFIG [PLATFORM ]['swofreq' ]} "
105
117
cmd += f" -itmmask 0xFFFF -outputfile { log_filename } "
118
+ cmd += f" { SWO_CONFIG [PLATFORM ]['args' ]} "
106
119
try :
107
120
logger .info (f"Executing:\n { cmd } " )
108
121
proc = subprocess .Popen (
109
122
cmd ,
110
123
stdout = subprocess .PIPE ,
111
124
stderr = subprocess .STDOUT ,
112
- encoding = ' UTF-8' ,
125
+ encoding = " UTF-8" ,
113
126
shell = True ,
114
127
)
115
128
except OSError as exc :
@@ -127,9 +140,7 @@ def test_swo_logging(dut: DeviceAdapter):
127
140
log_file_content = log_file .read ()
128
141
129
142
# if nothing in log_file, stop test
130
- assert (
131
- len (log_file_content ) > 0
132
- ), f"File { log_filename } is empty"
143
+ assert len (log_file_content ) > 0 , f"File { log_filename } is empty"
133
144
134
145
# Check if log file contains expected string
135
146
expected_str = re .search (EXPECTED , log_file_content )
0 commit comments