Skip to content

Commit 3e91edb

Browse files
committed
add D555 to test-fw-update
1 parent 77b8fa2 commit 3e91edb

File tree

2 files changed

+61
-47
lines changed

2 files changed

+61
-47
lines changed

unit-tests/run-unit-tests.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ def usage():
5555
print( ' --no-reset Do not try to reset any devices, with or without a hub' )
5656
print( ' --hub-reset If a hub is available, reset the hub itself' )
5757
print( ' --custom-fw-d400 If custom fw provided flash it if its different that the current fw installed' )
58+
print( ' --custom-fw-d555 If custom fw provided flash it if its different that the current fw installed' )
5859
print( ' --rslog Enable LibRS logging (LOG_DEBUG etc.) to console in each test' )
5960
print( ' --skip-disconnected Skip live test if required device is disconnected (only applies w/o a hub)' )
6061
print( ' --test-dir <> Path to test dir; default: librealsense/unit-tests' )
@@ -84,7 +85,7 @@ def usage():
8485
opts, args = getopt.getopt( sys.argv[1:], 'hvqr:st:',
8586
longopts=['help', 'verbose', 'debug', 'quiet', 'regex=', 'stdout', 'tag=', 'list-tags',
8687
'list-tests', 'no-exceptions', 'context=', 'repeat=', 'retry=', 'config=', 'no-reset', 'hub-reset',
87-
'rslog', 'skip-disconnected', 'live', 'not-live', 'device=', 'exclude-device=', 'test-dir=','skip-regex=','custom-fw-d400='] )
88+
'rslog', 'skip-disconnected', 'live', 'not-live', 'device=', 'exclude-device=', 'test-dir=','skip-regex=','custom-fw-d400=','custom-fw-d555='] )
8889
except getopt.GetoptError as err:
8990
log.e( err ) # something like "option -a not recognized"
9091
usage()
@@ -104,6 +105,7 @@ def usage():
104105
hub_reset = False
105106
skip_disconnected = False
106107
custom_fw_path=''
108+
custom_fw_d555_path=''
107109
rslog = False
108110
only_live = False
109111
only_not_live = False
@@ -179,6 +181,9 @@ def usage():
179181
elif opt == '--custom-fw-d400':
180182
custom_fw_path = arg # Store the custom firmware path
181183
log.i(f"custom firmware path was provided ${custom_fw_path}")
184+
elif opt == '--custom-fw-d555':
185+
custom_fw_d555_path = arg # Store the custom D555 firmware path
186+
log.i(f"custom D555 firmware path was provided ${custom_fw_d555_path}")
182187

183188
def find_build_dir( dir ):
184189
"""
@@ -469,6 +474,9 @@ def test_wrapper_( test, configuration=None, repetition=1, curr_retry=0, max_ret
469474
if test.name == "test-fw-update" and custom_fw_path:
470475
opts.append('--custom-fw-d400')
471476
opts.append(custom_fw_path)
477+
if test.name == "test-fw-update" and custom_fw_d555_path:
478+
opts.append('--custom-fw-d555')
479+
opts.append(custom_fw_d555_path)
472480
try:
473481
test.run_test( configuration = configuration, log_path = log_path, opts = opts )
474482
except FileNotFoundError as e:

unit-tests/test-fw-update.py

Lines changed: 52 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#test:timeout 500
77
#test:donotrun:gha
88
#test:device each(D400*)
9+
#test:device D555
910

1011
import sys
1112
import os
@@ -14,38 +15,25 @@
1415
import platform
1516
import pyrealsense2 as rs
1617
import pyrsutils as rsutils
17-
from rspy import devices, log, test, file, repo
18+
from rspy import log, test, file, repo
1819
import time
1920
import argparse
2021

2122
# Parse command-line arguments
2223
parser = argparse.ArgumentParser(description="Test firmware update")
2324
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')
2426
args = parser.parse_args()
2527

2628
custom_fw_d400_path = args.custom_fw_d400
29+
custom_fw_d555_path = args.custom_fw_d555
2730
if custom_fw_d400_path:
28-
log.i(f"Custom firmware path provided: {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}")
2934
else:
3035
log.i(f"No Custom firmware path provided. using bundled firmware")
3136

32-
# This is the first test running, discover acroname modules.
33-
# Not relevant to MIPI devices running on jetson for LibCI
34-
if 'jetson' not in test.context:
35-
if not devices.hub:
36-
log.i( "No hub library found; skipping device FW update" )
37-
sys.exit(0)
38-
# Following will throw if no acroname module is found
39-
from rspy import device_hub
40-
41-
if device_hub.create() is None:
42-
log.f("No hub found")
43-
# Remove acroname -- we're likely running inside run-unit-tests in which case the
44-
# acroname hub is likely already connected-to from there and we'll get an error
45-
# thrown ('failed to connect to acroname (result=11)'). We do not need it -- just
46-
# needed to verify it is available above...
47-
devices.hub = None
48-
4937

5038
def send_hardware_monitor_command(device, command):
5139
# byte_index = -1
@@ -73,7 +61,7 @@ def extract_version_from_filename(file_path):
7361
return None
7462

7563
filename = os.path.basename(file_path)
76-
match = re.search(r'(\d+)_(\d+)_(\d+)_(\d+)\.bin$', filename)
64+
match = re.search(r'(\d+)[._](\d+)[._](\d+)[._](\d+)', filename)
7765
if match:
7866
groups = match.groups()
7967
if groups[3] == '0':
@@ -89,12 +77,15 @@ def extract_version_from_filename(file_path):
8977

9078
def get_update_counter(device):
9179
product_line = device.get_info(rs.camera_info.product_line)
80+
product_name = device.get_info(rs.camera_info.name)
9281
opcode = 0x09
9382
start_index = 0x30
9483
size = None
9584

9685
if product_line == "D400":
9786
size = 0x2
87+
elif "D555" in product_name:
88+
return 0 # D555 does not have update counter
9889
else:
9990
log.f( "Incompatible product line:", product_line )
10091

@@ -163,16 +154,11 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
163154
if not fw_updater_exe:
164155
log.f( "Could not find the update tool file (rs-fw-update.exe)" )
165156

166-
devices.query( monitor_changes = False )
167-
sn_list = devices.all()
168-
# acroname should ensure there is always 1 available device
169-
if len( sn_list ) != 1:
170-
log.f( "Expected 1 device, got", len( sn_list ) )
171-
device = devices.get_first( sn_list ).handle
172-
log.d( 'found:', device )
157+
device, ctx = test.find_first_device_or_exit()
173158
product_line = device.get_info( rs.camera_info.product_line )
174159
product_name = device.get_info( rs.camera_info.name )
175-
log.d( 'product line:', product_line )
160+
serial_number = device.get_info(rs.camera_info.serial_number)
161+
log.d( 'product line:', product_line, 'serial number:', serial_number )
176162
###############################################################################
177163
#
178164

@@ -185,7 +171,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
185171
try:
186172
# always flash signed fw when device on recovery befre flashing anything else
187173
image_file = find_image_or_exit(product_name)
188-
cmd = [fw_updater_exe, '-r', '-f', image_file]
174+
cmd = [fw_updater_exe, '-r', '-f', image_file, '-s', serial_number]
189175
log.d( 'running:', cmd )
190176
subprocess.run( cmd )
191177
recovered = True
@@ -199,19 +185,35 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
199185
test.unexpected_exception()
200186
log.f( "Unexpected error while trying to recover device:", e )
201187
else:
202-
devices.query( monitor_changes = False )
203-
device = devices.get_first( devices.all() ).handle
188+
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 )
204193

205194
current_fw_version = rsutils.version( device.get_info( rs.camera_info.firmware_version ))
206195
log.d( 'current FW version:', current_fw_version )
207-
bundled_fw_version = rsutils.version( device.get_info( rs.camera_info.recommended_firmware_version ) )
208-
log.d( 'bundled FW version:', bundled_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 )
209200
custom_fw_d400_version = extract_version_from_filename(custom_fw_d400_path)
210201
log.d( 'custom FW D400 version:', custom_fw_d400_version )
211-
212-
213-
if (current_fw_version == bundled_fw_version and not custom_fw_d400_path) or \
214-
(current_fw_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
214+
215+
if (current_fw_version == bundled_fw_version and not custom_fw_path) or \
216+
(current_fw_version == custom_fw_version):
215217
if recovered or 'nightly' not in test.context:
216218
log.d('versions are same; skipping FW update')
217219
test.finish()
@@ -231,29 +233,33 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
231233
if not bundled_fw_version.build():
232234
fw_version_regex += ".0" # version drops the build if 0
233235
fw_version_regex = re.escape( fw_version_regex )
234-
image_file = find_image_or_exit(product_name, fw_version_regex) if not custom_fw_d400_path else custom_fw_d400_path
236+
image_file = find_image_or_exit(product_name, fw_version_regex) if not custom_fw_path else custom_fw_path
235237
# finding file containing image for FW update
236238

237-
cmd = [fw_updater_exe, '-f', image_file]
238-
if custom_fw_d400_path:
239+
cmd = [fw_updater_exe, '-f', image_file, '-s', serial_number]
240+
if custom_fw_path:
239241
# Add '-u' only if the path doesn't include 'signed'
240-
if 'signed' not in custom_fw_d400_path.lower():
242+
if ('signed' not in custom_fw_path.lower()
243+
and "d555" not in product_name.lower()): # currently -u is not supported for D555
241244
cmd.insert(1, '-u')
245+
246+
# for DDS devices we need to close device and context to detect it back after FW update
247+
del device, ctx
242248
log.d( 'running:', cmd )
243249
sys.stdout.flush()
244250
subprocess.run( cmd ) # may throw
245251

246252
# make sure update worked
247253
time.sleep(3) # MIPI devices do not re-enumerate so we need to give them some time to restart
248-
devices.query( monitor_changes = False )
249-
sn_list = devices.all()
250-
device = devices.get_first( sn_list ).handle
254+
device, ctx = test.find_first_device_or_exit()
251255
current_fw_version = rsutils.version( device.get_info( rs.camera_info.firmware_version ))
252-
test.check_equal(current_fw_version, bundled_fw_version if not custom_fw_d400_path else custom_fw_d400_version)
256+
257+
expected_fw_version = custom_fw_version if custom_fw_path else bundled_fw_version
258+
test.check_equal(current_fw_version, expected_fw_version)
253259
new_update_counter = get_update_counter( device )
254260
# According to FW: "update counter zeros if you load newer FW than (ever) before"
255261
# TODO: check why update counter is 255 when installing cutom fw
256-
if new_update_counter > 0 and not custom_fw_d400_version:
262+
if new_update_counter > 0 and not custom_fw_version:
257263
test.check_equal( new_update_counter, update_counter + 1 )
258264

259265
test.finish()

0 commit comments

Comments
 (0)