From b044ad118c2b0f1b30e467a2a1fc50f6e06bd88d Mon Sep 17 00:00:00 2001 From: Noha Yassin <37175819+nohayassin@users.noreply.github.com> Date: Wed, 16 Dec 2020 17:02:55 +0200 Subject: [PATCH 1/3] FW update exception fix --- src/ds5/ds5-device.cpp | 14 ++++++++++++++ src/l500/l500-device.cpp | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index ce5f27bc68..e6ea24e16a 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -123,12 +123,26 @@ namespace librealsense { // Stop all data streaming/exchange pipes with HW stop_activity(); + using namespace std; + using namespace std::chrono; try { LOG_INFO("entering to update state, device disconnect is expected"); command cmd(ds::DFU); cmd.param1 = 1; _hw_monitor->send(cmd); + std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); + for (auto i = 0; i < 10; i++) + { + _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD); + this_thread::sleep_for(milliseconds(50)); + } + throw std::runtime_error("Device still connected!"); + + } + catch (std::exception& e) + { + LOG_WARNING(e.what()); } catch (...) { // The set command returns a failure because switching to DFU resets the device while the command is running. diff --git a/src/l500/l500-device.cpp b/src/l500/l500-device.cpp index 051eba2474..c240d4d992 100644 --- a/src/l500/l500-device.cpp +++ b/src/l500/l500-device.cpp @@ -435,12 +435,26 @@ namespace librealsense { // Stop all data streaming/exchange pipes with HW stop_activity(); + using namespace std; + using namespace std::chrono; try { LOG_INFO("entering to update state, device disconnect is expected"); command cmd(ivcam2::DFU); cmd.param1 = 1; _hw_monitor->send(cmd); + std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); + for (auto i = 0; i < 25; i++) + { + + _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), GVD); + this_thread::sleep_for(milliseconds(50)); + } + throw std::runtime_error("Device still connected!"); + + } + catch (std::exception& e) { + LOG_WARNING(e.what()); } catch (...) { // The set command returns a failure because switching to DFU resets the device while the command is running. From 73186bac1d5bb1b89bfeafb195eda5c0bef86647 Mon Sep 17 00:00:00 2001 From: Noha Yassin <37175819+nohayassin@users.noreply.github.com> Date: Wed, 23 Dec 2020 10:32:44 +0200 Subject: [PATCH 2/3] FW update exception fix, SR3 device --- common/fw-update-helper.cpp | 4 ++++ src/ds5/ds5-device.cpp | 2 +- src/ivcam/sr300.cpp | 13 +++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index e608fe77c0..ee256564a0 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -232,6 +232,10 @@ namespace rs2 if (_is_signed) { log("Requesting to switch to recovery mode"); + + // in order to update device to DFU state, it will be disconnected then switches to DFU state + // if querying devices is called while device still switching to DFU state, an exception will be thrown + // to prevent that, a blocking is added to make sure device is updated before continue to next step of querying device upd.enter_update_state(); if (!check_for([this, serial, &dfu]() { diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index e6ea24e16a..0f98454a39 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -132,7 +132,7 @@ namespace librealsense cmd.param1 = 1; _hw_monitor->send(cmd); std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); - for (auto i = 0; i < 10; i++) + for (auto i = 0; i < 25; i++) { _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD); this_thread::sleep_for(milliseconds(50)); diff --git a/src/ivcam/sr300.cpp b/src/ivcam/sr300.cpp index 9b17a76b5a..821aa0a73f 100644 --- a/src/ivcam/sr300.cpp +++ b/src/ivcam/sr300.cpp @@ -326,11 +326,24 @@ namespace librealsense { // Stop all data streaming/exchange pipes with HW stop_activity(); + using namespace std; + using namespace std::chrono; try { command cmd(ivcam::GoToDFU); cmd.param1 = 1; _hw_monitor->send(cmd); + std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); + for (auto i = 0; i < 25; i++) + { + _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD); + this_thread::sleep_for(milliseconds(50)); + } + throw std::runtime_error("Device still connected!"); + } + catch (std::exception& e) + { + LOG_WARNING(e.what()); } catch (...) { // The set command returns a failure because switching to DFU resets the device while the command is running. From f9479766e3d4c32a651ca5a31b1d9ac93abfc56c Mon Sep 17 00:00:00 2001 From: Noha Yassin <37175819+nohayassin@users.noreply.github.com> Date: Mon, 22 Feb 2021 14:12:13 +0200 Subject: [PATCH 3/3] dso_16069_fw_update increase loops to 50 --- src/ds5/ds5-device.cpp | 2 +- src/ivcam/sr300.cpp | 2 +- src/l500/l500-device.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ds5/ds5-device.cpp b/src/ds5/ds5-device.cpp index 0f98454a39..654cc14b32 100644 --- a/src/ds5/ds5-device.cpp +++ b/src/ds5/ds5-device.cpp @@ -132,7 +132,7 @@ namespace librealsense cmd.param1 = 1; _hw_monitor->send(cmd); std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); - for (auto i = 0; i < 25; i++) + for (auto i = 0; i < 50; i++) { _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD); this_thread::sleep_for(milliseconds(50)); diff --git a/src/ivcam/sr300.cpp b/src/ivcam/sr300.cpp index 821aa0a73f..17e8f6f7fe 100644 --- a/src/ivcam/sr300.cpp +++ b/src/ivcam/sr300.cpp @@ -334,7 +334,7 @@ namespace librealsense cmd.param1 = 1; _hw_monitor->send(cmd); std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); - for (auto i = 0; i < 25; i++) + for (auto i = 0; i < 50; i++) { _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), ds::GVD); this_thread::sleep_for(milliseconds(50)); diff --git a/src/l500/l500-device.cpp b/src/l500/l500-device.cpp index c240d4d992..47af7b2254 100644 --- a/src/l500/l500-device.cpp +++ b/src/l500/l500-device.cpp @@ -444,7 +444,7 @@ namespace librealsense cmd.param1 = 1; _hw_monitor->send(cmd); std::vector gvd_buff(HW_MONITOR_BUFFER_SIZE); - for (auto i = 0; i < 25; i++) + for (auto i = 0; i < 50; i++) { _hw_monitor->get_gvd(gvd_buff.size(), gvd_buff.data(), GVD);