2121
2222# Parse command-line arguments
2323parser = argparse .ArgumentParser (description = "Test firmware update" )
24- parser .add_argument ('--custom-fw-d400' , type = str , help = 'Path to custom firmware file' )
25- parser .add_argument ('--custom-fw-d555 ' , type = str , help = 'Path to custom D555 firmware file' )
24+ parser .add_argument ('--custom-fw-d400' , type = str , help = 'Path to custom D400 firmware file' )
25+ parser .add_argument ('--custom-fw-d500 ' , type = str , help = 'Path to custom D500 firmware file' )
2626args = parser .parse_args ()
2727
28- custom_fw_d400_path = args .custom_fw_d400
29- custom_fw_d555_path = args .custom_fw_d555
30- if custom_fw_d400_path :
31- log .i (f"Custom D400 firmware path provided: { custom_fw_d400_path } " )
32- elif custom_fw_d555_path :
33- log .i (f"Custom D555 firmware path provided: { custom_fw_d555_path } " )
34- else :
35- log .i (f"No Custom firmware path provided. using bundled firmware" )
36-
3728
3829def send_hardware_monitor_command (device , command ):
3930 # byte_index = -1
@@ -61,7 +52,7 @@ def extract_version_from_filename(file_path):
6152 return None
6253
6354 filename = os .path .basename (file_path )
64- match = re .search (r'(\d+)[._](\d+)[._](\d+)[._](\d+)' , filename )
55+ match = re .search (r'[-_] (\d+)[._](\d+)[._](\d+)[._](\d+)' , filename )
6556 if match :
6657 groups = match .groups ()
6758 if groups [3 ] == '0' :
@@ -77,15 +68,14 @@ def extract_version_from_filename(file_path):
7768
7869def get_update_counter (device ):
7970 product_line = device .get_info (rs .camera_info .product_line )
80- product_name = device .get_info (rs .camera_info .name )
8171 opcode = 0x09
8272 start_index = 0x30
8373 size = None
8474
8575 if product_line == "D400" :
8676 size = 0x2
87- elif "D555" in product_name :
88- return 0 # D555 does not have update counter
77+ elif product_line == "D500" :
78+ return 0 # D500 do not have update counter
8979 else :
9080 log .f ( "Incompatible product line:" , product_line )
9181
@@ -157,11 +147,22 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
157147device , ctx = test .find_first_device_or_exit ()
158148product_line = device .get_info ( rs .camera_info .product_line )
159149product_name = device .get_info ( rs .camera_info .name )
160- serial_number = device .get_info (rs .camera_info .serial_number )
161- log .d ( 'product line:' , product_line , 'serial number:' , serial_number )
150+ log .d ( 'product line:' , product_line )
162151###############################################################################
163152#
164153
154+ current_fw_version = rsutils .version ( device .get_info ( rs .camera_info .firmware_version ))
155+ log .d ( 'current FW version:' , current_fw_version )
156+
157+ # Determine which firmware to use based on product
158+ bundled_fw_version = rsutils .version ("" )
159+ custom_fw_path = None
160+ custom_fw_version = None
161+ if product_line == "D400" and args .custom_fw_d400 :
162+ custom_fw_path = args .custom_fw_d400
163+ elif product_line == "D500" and args .custom_fw_d500 :
164+ custom_fw_path = args .custom_fw_d500
165+
165166
166167test .start ( "Update FW" )
167168# check if recovery. If so recover
@@ -170,8 +171,10 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
170171 log .d ( "recovering device ..." )
171172 try :
172173 # always flash signed fw when device on recovery before flashing anything else
173- image_file = find_image_or_exit (product_name )
174- cmd = [fw_updater_exe , '-r' , '-f' , image_file , '-s' , serial_number ]
174+ # on D500 we currently do not have bundled FW
175+ image_file = find_image_or_exit (product_name ) if not product_line == "D500" else custom_fw_path
176+ cmd = [fw_updater_exe , '-r' , '-f' , image_file ]
177+ del device , ctx
175178 log .d ( 'running:' , cmd )
176179 subprocess .run ( cmd )
177180 recovered = True
@@ -186,41 +189,27 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
186189 log .f ( "Unexpected error while trying to recover device:" , e )
187190 else :
188191 device , ctx = test .find_first_device_or_exit ()
189- # check we got the same serial number
190- new_serial_number = device .get_info (rs .camera_info .serial_number )
191- if new_serial_number != serial_number :
192- log .f ( "Recovered device has different serial number:" , new_serial_number )
192+ current_fw_version = rsutils .version (device .get_info (rs .camera_info .firmware_version ))
193+ log .d ("FW version after recovery:" , current_fw_version )
193194
194- current_fw_version = rsutils .version ( device .get_info ( rs .camera_info .firmware_version ))
195- log .d ( 'current FW version:' , current_fw_version )
196- bundled_fw_version = rsutils .version ("" )
197- if device .supports ( rs .camera_info .recommended_firmware_version ): # currently, D500 does not support recommended FW
198- bundled_fw_version = rsutils .version ( device .get_info ( rs .camera_info .recommended_firmware_version ) )
199- log .d ( 'bundled FW version:' , bundled_fw_version )
200- custom_fw_d400_version = extract_version_from_filename (custom_fw_d400_path )
201- log .d ( 'custom FW D400 version:' , custom_fw_d400_version )
202- custom_fw_d555_version = extract_version_from_filename (custom_fw_d555_path )
203- log .d ( 'custom FW D555 version:' , custom_fw_d555_version )
204-
205- # Determine which custom firmware to use based on product
206- custom_fw_path = None
207- custom_fw_version = None
208- if product_line == "D400" and custom_fw_d400_path :
209- custom_fw_path = custom_fw_d400_path
210- custom_fw_version = custom_fw_d400_version
211- elif "D555" in product_name and custom_fw_d555_path :
212- custom_fw_path = custom_fw_d555_path
213- custom_fw_version = custom_fw_d555_version
195+
196+ if custom_fw_path :
197+ custom_fw_version = extract_version_from_filename (custom_fw_path )
198+ log .d ('Using custom FW version: ' , custom_fw_version )
199+ elif device .supports (rs .camera_info .recommended_firmware_version ): # currently, D500 does not support recommended FW
200+ log .i (f"No Custom firmware path provided. using bundled firmware" )
201+ bundled_fw_version = rsutils .version (device .get_info (rs .camera_info .recommended_firmware_version ))
202+ log .d ('bundled FW version:' , bundled_fw_version )
203+ else :
204+ log .w ("No custom FW provided and no bundled FW version available; skipping FW update test" )
205+ exit (0 )
214206
215207if (current_fw_version == bundled_fw_version and not custom_fw_path ) or \
216208 (current_fw_version == custom_fw_version ):
217209 if recovered or 'nightly' not in test .context :
218210 log .d ('versions are same; skipping FW update' )
219211 test .finish ()
220212 test .print_results_and_exit ()
221- else :
222- # It is expected that, post-recovery, the FW versions will be the same
223- test .check (not recovered , on_fail = test .ABORT )
224213
225214update_counter = get_update_counter ( device )
226215log .d ( 'update counter:' , update_counter )
@@ -236,7 +225,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
236225image_file = find_image_or_exit (product_name , fw_version_regex ) if not custom_fw_path else custom_fw_path
237226# finding file containing image for FW update
238227
239- cmd = [fw_updater_exe , '-f' , image_file , '-s' , serial_number ]
228+ cmd = [fw_updater_exe , '-f' , image_file ]
240229if custom_fw_path :
241230 # Add '-u' only if the path doesn't include 'signed'
242231 if ('signed' not in custom_fw_path .lower ()
0 commit comments