From 306f8b7fa49ffd85839ddd776891e7af3893a174 Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Thu, 24 Apr 2025 11:36:23 +0300 Subject: [PATCH 1/5] giving time for the device to be discovered after burning fw --- unit-tests/test-fw-update.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/unit-tests/test-fw-update.py b/unit-tests/test-fw-update.py index e8c3543071..1a41afa3b8 100644 --- a/unit-tests/test-fw-update.py +++ b/unit-tests/test-fw-update.py @@ -242,6 +242,20 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): time.sleep(3) # MIPI devices do not re-enumerate so we need to give them some time to restart devices.query( monitor_changes = False ) sn_list = devices.all() +sn_list_size = len(sn_list) +if sn_list_size == 0: + retries = 10 + while retries > 0 and sn_list_size == 0: + retries -= 1 + time.sleep(3) + devices.query( monitor_changes = False ) + sn_list = devices.all() + sn_list_size = len(sn_list) + if sn_list_size == 0: + print("Device discovery... Device not found yet - remaining retries: " + repr(retries) ) + else: + print("Device discovery... Device found.") + device = devices.get_first( sn_list ).handle current_fw_version = rsutils.version( device.get_info( rs.camera_info.firmware_version )) test.check_equal(current_fw_version, bundled_fw_version if not custom_fw_d400_path else custom_fw_d400_version) From 8a6b35a19cfa10a0a48e6ea8608eb7de7c0714f7 Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Thu, 24 Apr 2025 14:40:05 +0300 Subject: [PATCH 2/5] iterations number and timers reviewed --- unit-tests/test-fw-update.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unit-tests/test-fw-update.py b/unit-tests/test-fw-update.py index 1a41afa3b8..f1bc2cbe63 100644 --- a/unit-tests/test-fw-update.py +++ b/unit-tests/test-fw-update.py @@ -244,10 +244,10 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): sn_list = devices.all() sn_list_size = len(sn_list) if sn_list_size == 0: - retries = 10 + retries = 5 while retries > 0 and sn_list_size == 0: retries -= 1 - time.sleep(3) + time.sleep(2) devices.query( monitor_changes = False ) sn_list = devices.all() sn_list_size = len(sn_list) From c7b4a726d43633bc6afea3966ea7a13aaf4eeac4 Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Thu, 24 Apr 2025 15:34:00 +0300 Subject: [PATCH 3/5] adding serial number for fw update --- unit-tests/test-fw-update.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unit-tests/test-fw-update.py b/unit-tests/test-fw-update.py index f1bc2cbe63..0646b7f8ac 100644 --- a/unit-tests/test-fw-update.py +++ b/unit-tests/test-fw-update.py @@ -173,6 +173,8 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): product_line = device.get_info( rs.camera_info.product_line ) product_name = device.get_info( rs.camera_info.name ) log.d( 'product line:', product_line ) +sn = device.get_info( rs.camera_info.serial_number ) +print("Device serial number = " + repr(sn)) ############################################################################### # @@ -184,7 +186,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): log.d( "recovering device ..." ) try: image_file = find_image_or_exit(product_name) if not custom_fw_d400_path else custom_fw_d400_path - cmd = [fw_updater_exe, '-r', '-f', image_file] + cmd = [fw_updater_exe, '-r', '-f', image_file, '-s', sn] if custom_fw_d400_path: # unsiged fw cmd.insert(1, '-u') @@ -230,7 +232,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): image_file = find_image_or_exit(product_name, fw_version_regex) if not custom_fw_d400_path else custom_fw_d400_path # finding file containing image for FW update -cmd = [fw_updater_exe, '-f', image_file] +cmd = [fw_updater_exe, '-f', image_file, '-s', sn] if custom_fw_d400_path: # unsigned fw cmd.insert(1, '-u') From 2c7b8362fe7e72f30bedde4396ff3a0409d38f07 Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Mon, 28 Apr 2025 13:53:35 +0300 Subject: [PATCH 4/5] device discovered after dfu in fw-update tool --- tools/fw-update/rs-fw-update.cpp | 75 +++++++++++++++++++------------- unit-tests/test-fw-update.py | 20 +-------- 2 files changed, 46 insertions(+), 49 deletions(-) diff --git a/tools/fw-update/rs-fw-update.cpp b/tools/fw-update/rs-fw-update.cpp index 93f716ab4b..ebfc3d00d0 100644 --- a/tools/fw-update/rs-fw-update.cpp +++ b/tools/fw-update/rs-fw-update.cpp @@ -31,6 +31,14 @@ using rsutils::json; +std::condition_variable cv; +std::mutex mutex; +std::string selected_serial_number; + +rs2::device new_device; +rs2::update_device new_fw_update_device; + +bool done = false; std::vector read_fw_file(std::string file_path) { @@ -139,7 +147,30 @@ void list_devices( rs2::context ctx ) } } -int write_fw_to_mipi_device( const rs2::device & dev, const std::vector< uint8_t > & fw_image ) + +void waiting_for_device_to_reconnect(rs2::context& ctx, rs2::cli::value& serial_number_arg) +{ + std::cout << std::endl << "Waiting for device to reconnect..." << std::endl; + std::unique_lock lk(mutex); + cv.wait_for(lk, std::chrono::seconds(WAIT_FOR_DEVICE_TIMEOUT), [&] { return !done || new_device; }); + + if (done) + { + auto devs = ctx.query_devices(); + for (auto&& d : devs) + { + auto sn = d.supports(RS2_CAMERA_INFO_SERIAL_NUMBER) ? d.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER) : "unknown"; + if (serial_number_arg.isSet() && sn != selected_serial_number) + continue; + + auto fw = d.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION) ? d.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION) : "unknown"; + std::cout << std::endl << "Device " << sn << " successfully updated to FW: " << fw << std::endl; + } + } + +} + +int write_fw_to_mipi_device( rs2::context& ctx, rs2::cli::value& serial_number_arg, const rs2::device & dev, const std::vector< uint8_t > & fw_image ) { // Write firmware to appropriate file descriptor std::cout << std::endl << "Update can take up to 2 minutes" << std::endl; @@ -186,6 +217,10 @@ int write_fw_to_mipi_device( const rs2::device & dev, const std::vector< uint8_t return EXIT_FAILURE; } std::cout << std::endl << "Firmware update done" << std::endl; + + done = true; + + waiting_for_device_to_reconnect(ctx, serial_number_arg); return EXIT_SUCCESS; } @@ -205,15 +240,6 @@ bool is_mipi_device( const rs2::device & dev ) int main( int argc, char ** argv ) try { - std::condition_variable cv; - std::mutex mutex; - std::string selected_serial_number; - - rs2::device new_device; - rs2::update_device new_fw_update_device; - - bool done = false; - using rs2::cli; cli cmd( "librealsense rs-fw-update tool" ); @@ -477,25 +503,28 @@ try // return EXIT_FAILURE; // } - return write_fw_to_mipi_device( d, fw_image ); + return write_fw_to_mipi_device(ctx, serial_number_arg, d, fw_image ); } if( unsigned_arg.isSet() ) { - std::cout << std::endl << "Firmware update started. Please don't disconnect device!" << std::endl << std::endl; + + std::cout << std::endl << "Unsigned Firmware update started. Please don't disconnect device!" << std::endl << std::endl; if( ISATTY( FILENO( stdout ) ) ) { d.as().update_unsigned( fw_image, [&]( const float progress ) { - printf( "\rFirmware update progress: %d[%%]", (int)( progress * 100 ) ); + printf( "\rUnsigned Firmware update progress: %d[%%]", (int)( progress * 100 ) ); std::cout.flush(); } ); } else d.as().update_unsigned( fw_image, [&]( const float progress ) {} ); - std::cout << std::endl << std::endl << "Firmware update done" << std::endl; + std::cout << std::endl << std::endl << "Unsigned Firmware update done" << std::endl; + + done = true; } else { @@ -547,23 +576,7 @@ try return EXIT_FAILURE; } - std::cout << std::endl << "Waiting for device to reconnect..." << std::endl; - std::unique_lock lk(mutex); - cv.wait_for(lk, std::chrono::seconds(WAIT_FOR_DEVICE_TIMEOUT), [&] { return !done || new_device; }); - - if (done) - { - auto devs = ctx.query_devices(); - for (auto&& d : devs) - { - auto sn = d.supports(RS2_CAMERA_INFO_SERIAL_NUMBER) ? d.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER) : "unknown"; - if (serial_number_arg.isSet() && sn != selected_serial_number) - continue; - - auto fw = d.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION) ? d.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION) : "unknown"; - std::cout << std::endl << "Device " << sn << " successfully updated to FW: " << fw << std::endl; - } - } + waiting_for_device_to_reconnect(ctx, serial_number_arg); return EXIT_SUCCESS; } diff --git a/unit-tests/test-fw-update.py b/unit-tests/test-fw-update.py index 0646b7f8ac..e8c3543071 100644 --- a/unit-tests/test-fw-update.py +++ b/unit-tests/test-fw-update.py @@ -173,8 +173,6 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): product_line = device.get_info( rs.camera_info.product_line ) product_name = device.get_info( rs.camera_info.name ) log.d( 'product line:', product_line ) -sn = device.get_info( rs.camera_info.serial_number ) -print("Device serial number = " + repr(sn)) ############################################################################### # @@ -186,7 +184,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): log.d( "recovering device ..." ) try: image_file = find_image_or_exit(product_name) if not custom_fw_d400_path else custom_fw_d400_path - cmd = [fw_updater_exe, '-r', '-f', image_file, '-s', sn] + cmd = [fw_updater_exe, '-r', '-f', image_file] if custom_fw_d400_path: # unsiged fw cmd.insert(1, '-u') @@ -232,7 +230,7 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): image_file = find_image_or_exit(product_name, fw_version_regex) if not custom_fw_d400_path else custom_fw_d400_path # finding file containing image for FW update -cmd = [fw_updater_exe, '-f', image_file, '-s', sn] +cmd = [fw_updater_exe, '-f', image_file] if custom_fw_d400_path: # unsigned fw cmd.insert(1, '-u') @@ -244,20 +242,6 @@ def find_image_or_exit( product_name, fw_version_regex = r'(\d+\.){3}(\d+)' ): time.sleep(3) # MIPI devices do not re-enumerate so we need to give them some time to restart devices.query( monitor_changes = False ) sn_list = devices.all() -sn_list_size = len(sn_list) -if sn_list_size == 0: - retries = 5 - while retries > 0 and sn_list_size == 0: - retries -= 1 - time.sleep(2) - devices.query( monitor_changes = False ) - sn_list = devices.all() - sn_list_size = len(sn_list) - if sn_list_size == 0: - print("Device discovery... Device not found yet - remaining retries: " + repr(retries) ) - else: - print("Device discovery... Device found.") - device = devices.get_first( sn_list ).handle current_fw_version = rsutils.version( device.get_info( rs.camera_info.firmware_version )) test.check_equal(current_fw_version, bundled_fw_version if not custom_fw_d400_path else custom_fw_d400_version) From da6881bbac34783d5ae60b04423dfe6fb4a66320 Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Tue, 29 Apr 2025 10:30:13 +0300 Subject: [PATCH 5/5] restoring d400_mipi_recovery device min fw version to 5.16.0.1 --- src/ds/d400/d400-private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ds/d400/d400-private.h b/src/ds/d400/d400-private.h index cd5edc8b41..276dbf0c65 100644 --- a/src/ds/d400/d400-private.h +++ b/src/ds/d400/d400-private.h @@ -166,7 +166,7 @@ namespace librealsense {RS405_PID, "5.12.11.8" }, {RS455_PID, "5.13.0.50" }, {RS457_PID, "5.16.8.0" }, - {RS400_MIPI_RECOVERY_PID, "5.16.8.0" }, + {RS400_MIPI_RECOVERY_PID, "5.16.0.1" }, {RS430_GMSL_PID, "5.16.8.0" } };