Skip to content

Commit e5faf0b

Browse files
authored
PR #14428 from AviaAv: add D555 to test-fw-update
2 parents e497e49 + 77bbceb commit e5faf0b

File tree

3 files changed

+64
-59
lines changed

3 files changed

+64
-59
lines changed

third-party/realdds/src/dds-device-watcher.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ dds_device_watcher::dds_device_watcher( std::shared_ptr< dds_participant > const
6868
}
6969
continue;
7070
}
71-
else if( device.alive )
71+
else if( device.alive && guid == device.writer_guid)
7272
{
7373
// We already know about this device; likely this was a broadcast meant for someone else
74+
// If guid mismatches the device was reset without us getting a subscription
75+
// lost callback in time - handle like old device coming back to life
7476
continue;
7577
}
7678
else if( device.alive = device.in_use.lock() )

unit-tests/run-unit-tests.py

Lines changed: 10 additions & 2 deletions
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
@@ -178,7 +180,10 @@ def usage():
178180
skip_regex = arg
179181
elif opt == '--custom-fw-d400':
180182
custom_fw_path = arg # Store the custom firmware path
181-
log.i(f"custom firmware path was provided ${custom_fw_path}")
183+
log.i(f"custom D400 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: 51 additions & 56 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,16 @@
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")
23-
parser.add_argument('--custom-fw-d400', type=str, help='Path to custom firmware file')
24+
parser.add_argument('--custom-fw-d400', type=str, help='Path to custom D400 firmware file')
25+
parser.add_argument('--custom-fw-d555', type=str, help='Path to custom D555 firmware file')
2426
args = parser.parse_args()
2527

26-
custom_fw_d400_path = args.custom_fw_d400
27-
if custom_fw_d400_path:
28-
log.i(f"Custom firmware path provided: {custom_fw_d400_path}")
29-
else:
30-
log.i(f"No Custom firmware path provided. using bundled firmware")
31-
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-
4928

5029
def send_hardware_monitor_command(device, command):
5130
# byte_index = -1
@@ -73,7 +52,7 @@ def extract_version_from_filename(file_path):
7352
return None
7453

7554
filename = os.path.basename(file_path)
76-
match = re.search(r'(\d+)_(\d+)_(\d+)_(\d+)\.bin$', filename)
55+
match = re.search(r'[-_](\d+)[._](\d+)[._](\d+)[._](\d+)', filename)
7756
if match:
7857
groups = match.groups()
7958
if groups[3] == '0':
@@ -95,6 +74,8 @@ def get_update_counter(device):
9574

9675
if product_line == "D400":
9776
size = 0x2
77+
elif product_line == "D500":
78+
return 0 # D500 do not have update counter
9879
else:
9980
log.f( "Incompatible product line:", product_line )
10081

@@ -163,29 +144,37 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
163144
if not fw_updater_exe:
164145
log.f( "Could not find the update tool file (rs-fw-update.exe)" )
165146

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 )
147+
device, ctx = test.find_first_device_or_exit()
173148
product_line = device.get_info( rs.camera_info.product_line )
174149
product_name = device.get_info( rs.camera_info.name )
175150
log.d( 'product line:', product_line )
176151
###############################################################################
177152
#
178153

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 "D555" in product_name and args.custom_fw_d555:
164+
custom_fw_path = args.custom_fw_d555
165+
179166

180167
test.start( "Update FW" )
181168
# check if recovery. If so recover
182169
recovered = False
183170
if device.is_in_recovery_mode():
184171
log.d( "recovering device ..." )
185172
try:
186-
# always flash signed fw when device on recovery befre flashing anything else
187-
image_file = find_image_or_exit(product_name)
173+
# always flash signed fw when device on recovery before flashing anything else
174+
# on D555 we currently do not have bundled FW
175+
image_file = find_image_or_exit(product_name) if "D555" not in product_name else custom_fw_path
188176
cmd = [fw_updater_exe, '-r', '-f', image_file]
177+
del device, ctx
189178
log.d( 'running:', cmd )
190179
subprocess.run( cmd )
191180
recovered = True
@@ -199,26 +188,28 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
199188
test.unexpected_exception()
200189
log.f( "Unexpected error while trying to recover device:", e )
201190
else:
202-
devices.query( monitor_changes = False )
203-
device = devices.get_first( devices.all() ).handle
191+
device, ctx = test.find_first_device_or_exit()
192+
current_fw_version = rsutils.version(device.get_info(rs.camera_info.firmware_version))
193+
log.d("FW version after recovery:", current_fw_version)
204194

205-
current_fw_version = rsutils.version( device.get_info( rs.camera_info.firmware_version ))
206-
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 )
209-
custom_fw_d400_version = extract_version_from_filename(custom_fw_d400_path)
210-
log.d( 'custom FW D400 version:', custom_fw_d400_version )
211195

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)
212206

213-
if (current_fw_version == bundled_fw_version and not custom_fw_d400_path) or \
214-
(current_fw_version == custom_fw_d400_version):
207+
if (current_fw_version == bundled_fw_version and not custom_fw_path) or \
208+
(current_fw_version == custom_fw_version):
215209
if recovered or 'nightly' not in test.context:
216210
log.d('versions are same; skipping FW update')
217211
test.finish()
218212
test.print_results_and_exit()
219-
else:
220-
# It is expected that, post-recovery, the FW versions will be the same
221-
test.check(not recovered, on_fail=test.ABORT)
222213

223214
update_counter = get_update_counter( device )
224215
log.d( 'update counter:', update_counter )
@@ -231,29 +222,33 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ):
231222
if not bundled_fw_version.build():
232223
fw_version_regex += ".0" # version drops the build if 0
233224
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
225+
image_file = find_image_or_exit(product_name, fw_version_regex) if not custom_fw_path else custom_fw_path
235226
# finding file containing image for FW update
236227

237228
cmd = [fw_updater_exe, '-f', image_file]
238-
if custom_fw_d400_path:
229+
if custom_fw_path:
239230
# Add '-u' only if the path doesn't include 'signed'
240-
if 'signed' not in custom_fw_d400_path.lower():
231+
if ('signed' not in custom_fw_path.lower()
232+
and "d555" not in product_name.lower()): # currently -u is not supported for D555
241233
cmd.insert(1, '-u')
234+
235+
# for DDS devices we need to close device and context to detect it back after FW update
236+
del device, ctx
242237
log.d( 'running:', cmd )
243238
sys.stdout.flush()
244239
subprocess.run( cmd ) # may throw
245240

246241
# make sure update worked
247242
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
243+
device, ctx = test.find_first_device_or_exit()
251244
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)
245+
246+
expected_fw_version = custom_fw_version if custom_fw_path else bundled_fw_version
247+
test.check_equal(current_fw_version, expected_fw_version)
253248
new_update_counter = get_update_counter( device )
254249
# According to FW: "update counter zeros if you load newer FW than (ever) before"
255250
# TODO: check why update counter is 255 when installing cutom fw
256-
if new_update_counter > 0 and not custom_fw_d400_version:
251+
if new_update_counter > 0 and not custom_fw_version:
257252
test.check_equal( new_update_counter, update_counter + 1 )
258253

259254
test.finish()

0 commit comments

Comments
 (0)