@@ -84,8 +84,7 @@ def test_rom_secure_boot(self):
8484 print ("Starting the rom secure boot test" )
8585
8686 # Directory for the trace log files
87- pc_trace_file_1 = os .path .join (log_dir , "rom_secure_boot_pc_trace_1.log" )
88- pc_trace_file_2 = os .path .join (log_dir , "rom_secure_boot_pc_trace_2.log" )
87+ pc_trace_file = os .path .join (log_dir , "rom_secure_boot_pc_trace.log" )
8988 # Directory for the the log of the campaign
9089 campaign_file = os .path .join (log_dir , "rom_secure_boot_test_campaign.log" )
9190
@@ -112,8 +111,6 @@ def test_rom_secure_boot(self):
112111 gdb .reset_target ()
113112 gdb .send_command (f"set $pc={ jump_address } " )
114113
115- # Tracing in done in two steps to jump over sc_otbn_cmd_run which makes GDB hang
116-
117114 # Functions where we can get GDB to jump over
118115 upsert_register_address = rom_parser .get_function_start_address ("upsert_register" )
119116
@@ -123,74 +120,16 @@ def test_rom_secure_boot(self):
123120 "sigverify_ecdsa_p256_key_id_get"
124121 )
125122
126- # We stop tracing when we execute the p256 verify in the otbn
127- trace_end_address = rom_parser .get_function_start_address ("sc_otbn_cmd_run" )
128-
129- print (
130- "Start and stop addresses for the rom for trace 1: " ,
131- trace_start_address ,
132- trace_end_address ,
133- flush = True ,
134- )
135- print ("First trace data is logged in " , pc_trace_file_1 , flush = True )
136-
137- # Start the tracing
138- # We set a short timeout to detect whether GDB has connected properly
139- # and a long timeout for the entire tracing
140- initial_timeout = 20
141- total_timeout = 60 * 60 * 5
142-
143- gdb .setup_pc_trace (
144- pc_trace_file_1 ,
145- trace_start_address ,
146- trace_end_address ,
147- skip_addrs = [upsert_register_address ],
148- )
149- gdb .send_command ("c" , check_response = False )
150-
151- start_time = time .time ()
152- initial_timeout_stopped = False
153- total_timeout_stopped = False
154-
155- # Run the tracing to get the trace log
156- # Sometimes the tracing fails due to race conditions,
157- # we have a quick initial timeout to catch this
158- while time .time () - start_time < initial_timeout :
159- output = gdb .read_output ()
160- if "breakpoint 1, " in output :
161- initial_timeout_stopped = True
162- break
163- if not initial_timeout_stopped :
164- print ("No initial break point found, can be a misfire, try again" )
165- sys .exit (1 )
166- while time .time () - start_time < total_timeout :
167- output = gdb .read_output ()
168- if "PC trace complete" in output :
169- print ("\n Trace complete" )
170- total_timeout_stopped = True
171- break
172- if not total_timeout_stopped :
173- print ("Final tracing timeout reached" )
174- sys .exit (1 )
175-
176- # Reset the target, flush the output, and close gdb
177- gdb = reset_target_and_gdb (gdb , jump_address )
178-
179- # We ready the second part of the trace
180-
181- # We start from sc_otbn_dmem_read which reads p256 verify's results from otbn
182- trace_start_address = rom_parser .get_function_start_address ("sc_otbn_dmem_read" )
183-
184123 # We expect with the test that we end up in shutdown_finalize
185124 trace_end_address = rom_parser .get_function_start_address ("shutdown_finalize" )
186125
187126 print (
188- "Start and stop addresses for the rom for trace 2 : " ,
127+ "Start and stop addresses for the rom: " ,
189128 trace_start_address ,
190129 trace_end_address ,
191130 flush = True ,
192131 )
193- print ("Second trace data is logged in " , pc_trace_file_2 , flush = True )
132+ print ("Trace data is logged in " , pc_trace_file , flush = True )
194133
195134 # Start the tracing
196135 # We set a short timeout to detect whether GDB has connected properly
@@ -199,7 +138,7 @@ def test_rom_secure_boot(self):
199138 total_timeout = 60 * 60 * 5
200139
201140 gdb .setup_pc_trace (
202- pc_trace_file_2 ,
141+ pc_trace_file ,
203142 trace_start_address ,
204143 trace_end_address ,
205144 skip_addrs = [upsert_register_address ],
@@ -232,8 +171,7 @@ def test_rom_secure_boot(self):
232171 sys .exit (1 )
233172
234173 # Parse and truncate the trace log to get all PCs in a list
235- pc_list = gdb .parse_pc_trace_file (pc_trace_file_1 )
236- pc_list .extend (gdb .parse_pc_trace_file (pc_trace_file_2 ))
174+ pc_list = gdb .parse_pc_trace_file (pc_trace_file )
237175 # Get the unique PCs and annotate their occurence count
238176 pc_count_dict = Counter (pc_list )
239177 if len (pc_count_dict ) <= 0 :
0 commit comments