From e99471820107d1bc7234f18c912b2c92888fd102 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 4 Aug 2021 14:52:21 +0300 Subject: [PATCH 1/7] remove support for L535 FW update to allow recovery update --- common/fw-update-helper.cpp | 34 +++++++++++++++++----------------- common/fw-update-helper.h | 8 +++----- common/model-views.cpp | 12 ++---------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index eff0f79cbb..69719af311 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -45,10 +45,10 @@ namespace rs2 RS2_FWU_STATE_FAILED = 3, }; - bool is_recommended_fw_available(const std::string& product_line, const std::string& PID) + bool is_recommended_fw_available(const std::string& product_line) { auto pl = parse_product_line(product_line); - auto fv = get_available_firmware_version(pl, PID); + auto fv = get_available_firmware_version(pl); return !(fv == ""); } @@ -60,27 +60,27 @@ namespace rs2 else return -1; } - std::string get_available_firmware_version(int product_line, const std::string& PID) + std::string get_available_firmware_version(int product_line) { if (product_line == RS2_PRODUCT_LINE_D400) return FW_D4XX_FW_IMAGE_VERSION; //else if (product_line == RS2_PRODUCT_LINE_SR300) return FW_SR3XX_FW_IMAGE_VERSION; - else if (product_line == RS2_PRODUCT_LINE_L500 && PID == "0B64") return FW_L51X_FW_IMAGE_VERSION; - else if (product_line == RS2_PRODUCT_LINE_L500 && PID == "0B68") return FW_L53X_FW_IMAGE_VERSION; + //else if (product_line == RS2_PRODUCT_LINE_L500 && PID == "0B68") return FW_L53X_FW_IMAGE_VERSION; + else if (product_line == RS2_PRODUCT_LINE_L500 ) return FW_L51X_FW_IMAGE_VERSION; else return ""; } - std::map, std::vector> create_default_fw_table() + std::map> create_default_fw_table() { bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false); - std::map, std::vector> rv; + std::map> rv; if (strlen(FW_D4XX_FW_IMAGE_VERSION) && !allow_rc_firmware) { int size = 0; auto hex = fw_get_D4XX_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_D400, ""}] = vec; + rv[{RS2_PRODUCT_LINE_D400}] = vec; } if (strlen(FW_SR3XX_FW_IMAGE_VERSION)) @@ -88,7 +88,7 @@ namespace rs2 int size = 0; auto hex = fw_get_SR3XX_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_SR300, ""}] = vec; + rv[{RS2_PRODUCT_LINE_SR300}] = vec; } if (strlen(FW_L51X_FW_IMAGE_VERSION)) @@ -96,15 +96,15 @@ namespace rs2 int size = 0; auto hex = fw_get_L51X_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_L500, "0B64"}] = vec; - } - if (strlen(FW_L53X_FW_IMAGE_VERSION)) - { - int size = 0; - auto hex = fw_get_L53X_FW_Image(size); - auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_L500, "0B68"}] = vec; + rv[{RS2_PRODUCT_LINE_L500}] = vec; } + //if (strlen(FW_L53X_FW_IMAGE_VERSION)) + //{ + // int size = 0; + // auto hex = fw_get_L53X_FW_Image(size); + // auto vec = std::vector(hex, hex + size); + // rv[{RS2_PRODUCT_LINE_L500, "0B68"}] = vec; + //} return rv; } diff --git a/common/fw-update-helper.h b/common/fw-update-helper.h index b99a77cb30..e8299d863e 100644 --- a/common/fw-update-helper.h +++ b/common/fw-update-helper.h @@ -11,14 +11,12 @@ namespace rs2 class viewer_model; int parse_product_line(const std::string& id); - std::string get_available_firmware_version(int product_line, const std::string& PID); + std::string get_available_firmware_version(int product_line); - // product line + PID to FW image data - // if PID doesn't make any difference (ds5, sr300) its will be "" - std::map, std::vector> create_default_fw_table(); + std::map> create_default_fw_table(); std::vector parse_fw_version(const std::string& fw); bool is_upgradeable(const std::string& curr, const std::string& available); - bool is_recommended_fw_available(const std::string& product_line, const std::string& PID); + bool is_recommended_fw_available(const std::string& product_line); class firmware_update_manager : public process_manager { diff --git a/common/model-views.cpp b/common/model-views.cpp index cd89beb726..a030860e93 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3868,9 +3868,8 @@ namespace rs2 configurations::update::allow_rc_firmware, false ); bool is_rc = ( product_line == RS2_PRODUCT_LINE_D400 ) && allow_rc_firmware; - std::string PID = dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID); - std::string available_fw_ver = get_available_firmware_version( product_line, PID); + std::string available_fw_ver = get_available_firmware_version( product_line); std::shared_ptr< firmware_update_manager > manager = nullptr; @@ -3881,18 +3880,11 @@ namespace rs2 static auto table = create_default_fw_table(); - std::vector image; - - if (table.find({ product_line, PID }) != table.end()) - image = table[{product_line, PID}]; - else - image = table[{product_line, ""}]; - manager = std::make_shared< firmware_update_manager >( not_model, *this, dev, ctx, - image, + table[product_line], true ); } From 9707e6898e5ccfbde374c4fa1d2423477f416adc Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 4 Aug 2021 16:24:38 +0300 Subject: [PATCH 2/7] Notify on FW update on DFU mode --- common/model-views.cpp | 57 +++++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 15 deletions(-) diff --git a/common/model-views.cpp b/common/model-views.cpp index a030860e93..f03d5274e4 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3853,16 +3853,31 @@ namespace rs2 // it). Lacking an available version, we try to let the user choose a "recommended" // version for download. The recommended version is defined by the device (and comes // from a #define). - if( dev.supports( RS2_CAMERA_INFO_FIRMWARE_VERSION ) - && dev.supports( RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION ) - && dev.supports( RS2_CAMERA_INFO_PRODUCT_LINE ) ) + + // Detect if fw_update notification is on to avoid displaying it during FW update process when + // the device enters recovery mode + auto fw_update_notification_is_in + = std::any_of( related_notifications.cbegin(), + related_notifications.cend(), + []( const std::shared_ptr< notification_model > & rn ) { + return rn->is< fw_update_notification_model >(); + } ); + + + if ( !fw_update_notification_is_in && dev.is() || dev.is() ) { - std::string fw = dev.get_info( RS2_CAMERA_INFO_FIRMWARE_VERSION ); - std::string recommended_fw_ver - = dev.get_info( RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION ); + std::string fw; + std::string recommended_fw_ver; + int product_line = 0; - int product_line - = parse_product_line( dev.get_info( RS2_CAMERA_INFO_PRODUCT_LINE ) ); + // Override with device info if info is available + if (dev.is()) + { + fw = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION); + recommended_fw_ver = dev.get_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION); + } + + product_line = parse_product_line(dev.get_info(RS2_CAMERA_INFO_PRODUCT_LINE)); bool allow_rc_firmware = config_file::instance().get_or_default( configurations::update::allow_rc_firmware, @@ -3874,7 +3889,7 @@ namespace rs2 std::shared_ptr< firmware_update_manager > manager = nullptr; - if( is_upgradeable( fw, available_fw_ver) ) + if( dev.is() || is_upgradeable( fw, available_fw_ver) ) { recommended_fw_ver = available_fw_ver; @@ -3889,17 +3904,29 @@ namespace rs2 } auto dev_name = get_device_name(dev); - if( is_upgradeable( fw, recommended_fw_ver) ) + if( dev.is() || is_upgradeable( fw, recommended_fw_ver) ) { std::stringstream msg; - msg << dev_name.first << " (S/N " << dev_name.second << ")\n" - << "Current Version: " << fw << "\n"; - if( is_rc ) - msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; + if (dev.is()) + { + msg << dev_name.first << "\n(S/N " << dev.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID) << ")\n"; + + if (is_rc) + msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; + else + msg << "Recommended Version: " << recommended_fw_ver; + } else - msg << "Recommended Version: " << recommended_fw_ver; + { + msg << dev_name.first << " (S/N " << dev_name.second << ")\n" + << "Current Version: " << fw << "\n"; + if (is_rc) + msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; + else + msg << "Recommended Version: " << recommended_fw_ver; + } auto n = std::make_shared< fw_update_notification_model >( msg.str(), manager, false ); From b60c00908fd0d5a0de5b7184bd770159c90e039f Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Wed, 4 Aug 2021 17:35:17 +0300 Subject: [PATCH 3/7] do not show fw update notification when manual update is displayed --- common/model-views.cpp | 36 +++++++++++------------------------- common/notifications.h | 8 ++++++++ 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/common/model-views.cpp b/common/model-views.cpp index f03d5274e4..fb8b9b0d1b 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3854,17 +3854,10 @@ namespace rs2 // version for download. The recommended version is defined by the device (and comes // from a #define). - // Detect if fw_update notification is on to avoid displaying it during FW update process when + // 'notification_type_is_displayed()' is used to detect if fw_update notification is on to avoid displaying it during FW update process when // the device enters recovery mode - auto fw_update_notification_is_in - = std::any_of( related_notifications.cbegin(), - related_notifications.cend(), - []( const std::shared_ptr< notification_model > & rn ) { - return rn->is< fw_update_notification_model >(); - } ); - - - if ( !fw_update_notification_is_in && dev.is() || dev.is() ) + if( ! not_model->notification_type_is_displayed< fw_update_notification_model >() + && ( dev.is< updatable >() || dev.is< update_device >() ) ) { std::string fw; std::string recommended_fw_ver; @@ -3882,19 +3875,15 @@ namespace rs2 bool allow_rc_firmware = config_file::instance().get_or_default( configurations::update::allow_rc_firmware, false ); - bool is_rc = ( product_line == RS2_PRODUCT_LINE_D400 ) && allow_rc_firmware; + bool is_rc = ( product_line == RS2_PRODUCT_LINE_D400 ) && allow_rc_firmware; std::string available_fw_ver = get_available_firmware_version( product_line); - std::shared_ptr< firmware_update_manager > manager = nullptr; - if( dev.is() || is_upgradeable( fw, available_fw_ver) ) { recommended_fw_ver = available_fw_ver; - static auto table = create_default_fw_table(); - manager = std::make_shared< firmware_update_manager >( not_model, *this, dev, @@ -3911,22 +3900,18 @@ namespace rs2 if (dev.is()) { msg << dev_name.first << "\n(S/N " << dev.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID) << ")\n"; - - if (is_rc) - msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; - else - msg << "Recommended Version: " << recommended_fw_ver; } else { msg << dev_name.first << " (S/N " << dev_name.second << ")\n" << "Current Version: " << fw << "\n"; - - if (is_rc) - msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; - else - msg << "Recommended Version: " << recommended_fw_ver; } + + if (is_rc) + msg << "Release Candidate: " << recommended_fw_ver << " Pre-Release"; + else + msg << "Recommended Version: " << recommended_fw_ver; + auto n = std::make_shared< fw_update_notification_model >( msg.str(), manager, false ); @@ -3935,6 +3920,7 @@ namespace rs2 n->delay_id = "fw_update_alert." + recommended_fw_ver + "." + dev_name.second; n->enable_complex_dismiss = true; + // If a delay request received in the past, reset it. if( reset_delay ) n->reset_delay(); if( ! n->is_delayed() ) diff --git a/common/notifications.h b/common/notifications.h index df005944b8..8553e50988 100644 --- a/common/notifications.h +++ b/common/notifications.h @@ -203,6 +203,14 @@ namespace rs2 std::function custom_action, bool use_custom_action = true); void add_notification(std::shared_ptr model); + + // Check of a notification of type T is currently on the display queue. + template + bool notification_type_is_displayed() + { + std::lock_guard lock(m); + return std::any_of(pending_notifications.cbegin(), pending_notifications.cend(), [](const std::shared_ptr& nm) {return nm->is(); }); + } bool draw(ux_window& win, int w, int h, std::string& error_message); notifications_model() {} From 21b6668fb02c93e7c52d3fab3dd4d5b24a73680a Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Thu, 5 Aug 2021 13:39:34 +0300 Subject: [PATCH 4/7] get FW by pid --- common/fw-update-helper.cpp | 46 ++++++++++++++++-------------- common/fw-update-helper.h | 8 +++--- common/model-views.cpp | 14 +++++++-- src/fw-update/fw-update-device.cpp | 4 ++- src/fw-update/fw-update-device.h | 1 + 5 files changed, 45 insertions(+), 28 deletions(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index 69719af311..122235a243 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -45,42 +45,42 @@ namespace rs2 RS2_FWU_STATE_FAILED = 3, }; - bool is_recommended_fw_available(const std::string& product_line) + bool is_recommended_fw_available(const std::string& product_line, const std::string& pid) { auto pl = parse_product_line(product_line); - auto fv = get_available_firmware_version(pl); + auto fv = get_available_firmware_version(pl, pid); return !(fv == ""); } - int parse_product_line(const std::string& id) + int parse_product_line(const std::string& product_line) { - if (id == "D400") return RS2_PRODUCT_LINE_D400; - else if (id == "SR300") return RS2_PRODUCT_LINE_SR300; - else if (id == "L500") return RS2_PRODUCT_LINE_L500; + if (product_line == "D400") return RS2_PRODUCT_LINE_D400; + else if (product_line == "SR300") return RS2_PRODUCT_LINE_SR300; + else if (product_line == "L500") return RS2_PRODUCT_LINE_L500; else return -1; } - std::string get_available_firmware_version(int product_line) + std::string get_available_firmware_version(int product_line, const std::string& pid) { if (product_line == RS2_PRODUCT_LINE_D400) return FW_D4XX_FW_IMAGE_VERSION; //else if (product_line == RS2_PRODUCT_LINE_SR300) return FW_SR3XX_FW_IMAGE_VERSION; - //else if (product_line == RS2_PRODUCT_LINE_L500 && PID == "0B68") return FW_L53X_FW_IMAGE_VERSION; - else if (product_line == RS2_PRODUCT_LINE_L500 ) return FW_L51X_FW_IMAGE_VERSION; + else if (product_line == RS2_PRODUCT_LINE_L500 && pid == "0B68") return FW_L53X_FW_IMAGE_VERSION; + else if (product_line == RS2_PRODUCT_LINE_L500) return FW_L51X_FW_IMAGE_VERSION; else return ""; } - std::map> create_default_fw_table() + std::map, std::vector> create_default_fw_table() { bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false); - std::map> rv; + std::map, std::vector> rv; if (strlen(FW_D4XX_FW_IMAGE_VERSION) && !allow_rc_firmware) { int size = 0; auto hex = fw_get_D4XX_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_D400}] = vec; + rv[{RS2_PRODUCT_LINE_D400, ""}] = vec; } if (strlen(FW_SR3XX_FW_IMAGE_VERSION)) @@ -88,7 +88,7 @@ namespace rs2 int size = 0; auto hex = fw_get_SR3XX_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_SR300}] = vec; + rv[{RS2_PRODUCT_LINE_SR300, ""}] = vec; } if (strlen(FW_L51X_FW_IMAGE_VERSION)) @@ -96,15 +96,19 @@ namespace rs2 int size = 0; auto hex = fw_get_L51X_FW_Image(size); auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_L500}] = vec; + rv[{RS2_PRODUCT_LINE_L500, "0B64"}] = vec; + + // This empty pid cell covers the case for L515 USB2 wrong pid on devices with old DFU version + rv[{RS2_PRODUCT_LINE_L500, ""}] = vec; + } + + if (strlen(FW_L53X_FW_IMAGE_VERSION)) + { + int size = 0; + auto hex = fw_get_L53X_FW_Image(size); + auto vec = std::vector(hex, hex + size); + rv[{RS2_PRODUCT_LINE_L500, "0B68"}] = vec; } - //if (strlen(FW_L53X_FW_IMAGE_VERSION)) - //{ - // int size = 0; - // auto hex = fw_get_L53X_FW_Image(size); - // auto vec = std::vector(hex, hex + size); - // rv[{RS2_PRODUCT_LINE_L500, "0B68"}] = vec; - //} return rv; } diff --git a/common/fw-update-helper.h b/common/fw-update-helper.h index e8299d863e..a2a079068b 100644 --- a/common/fw-update-helper.h +++ b/common/fw-update-helper.h @@ -10,13 +10,13 @@ namespace rs2 { class viewer_model; - int parse_product_line(const std::string& id); - std::string get_available_firmware_version(int product_line); + int parse_product_line(const std::string& product_line); + std::string get_available_firmware_version(int product_line, const std::string& pid); - std::map> create_default_fw_table(); + std::map, std::vector> create_default_fw_table(); std::vector parse_fw_version(const std::string& fw); bool is_upgradeable(const std::string& curr, const std::string& available); - bool is_recommended_fw_available(const std::string& product_line); + bool is_recommended_fw_available(const std::string& product_line, const std::string& pid); class firmware_update_manager : public process_manager { diff --git a/common/model-views.cpp b/common/model-views.cpp index fb8b9b0d1b..a0254d6053 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3877,22 +3877,32 @@ namespace rs2 false ); bool is_rc = ( product_line == RS2_PRODUCT_LINE_D400 ) && allow_rc_firmware; - std::string available_fw_ver = get_available_firmware_version( product_line); + std::string pid = dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID); + std::string available_fw_ver = get_available_firmware_version( product_line, pid); std::shared_ptr< firmware_update_manager > manager = nullptr; if( dev.is() || is_upgradeable( fw, available_fw_ver) ) { recommended_fw_ver = available_fw_ver; static auto table = create_default_fw_table(); + + std::vector image; + + if (table.find({ product_line, pid }) != table.end()) + image = table[{product_line, pid}]; + else + image = table[{product_line, ""}]; + manager = std::make_shared< firmware_update_manager >( not_model, *this, dev, ctx, - table[product_line], + image, true ); } auto dev_name = get_device_name(dev); + if( dev.is() || is_upgradeable( fw, recommended_fw_ver) ) { std::stringstream msg; diff --git a/src/fw-update/fw-update-device.cpp b/src/fw-update/fw-update-device.cpp index f8a2bdb132..2d483bcc6f 100644 --- a/src/fw-update/fw-update-device.cpp +++ b/src/fw-update/fw-update-device.cpp @@ -110,7 +110,7 @@ namespace librealsense } update_device::update_device(const std::shared_ptr& ctx, bool register_device_notifications, std::shared_ptr usb_device) - : _context(ctx), _usb_device(usb_device), _physical_port( usb_device->get_info().id ) + : _context(ctx), _usb_device(usb_device), _physical_port( usb_device->get_info().id), _pid(hexify(usb_device->get_info().pid)) { if (auto messenger = _usb_device->open(FW_UPDATE_INTERFACE_NUMBER)) { @@ -277,6 +277,7 @@ namespace librealsense case RS2_CAMERA_INFO_NAME: return get_name(); case RS2_CAMERA_INFO_PRODUCT_LINE: return get_product_line(); case RS2_CAMERA_INFO_PHYSICAL_PORT: return _physical_port; + case RS2_CAMERA_INFO_PRODUCT_ID: return _pid; default: throw std::runtime_error("update_device does not support " + std::string(rs2_camera_info_to_string(info))); } @@ -290,6 +291,7 @@ namespace librealsense case RS2_CAMERA_INFO_NAME: case RS2_CAMERA_INFO_PRODUCT_LINE: case RS2_CAMERA_INFO_PHYSICAL_PORT: + case RS2_CAMERA_INFO_PRODUCT_ID: return true; default: diff --git a/src/fw-update/fw-update-device.h b/src/fw-update/fw-update-device.h index fa52b0be90..d780869471 100644 --- a/src/fw-update/fw-update-device.h +++ b/src/fw-update/fw-update-device.h @@ -151,6 +151,7 @@ namespace librealsense std::string _highest_fw_version; std::string _last_fw_version; std::string _physical_port; + std::string _pid; bool _is_dfu_locked = false; }; } From 3c653d29c37b1613c20aaca897fcdebd477637ed Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Thu, 5 Aug 2021 14:14:10 +0300 Subject: [PATCH 5/7] reduce FW tables storage size in ram --- common/fw-update-helper.cpp | 79 ++++++++++++++++++++----------------- common/fw-update-helper.h | 2 +- common/model-views.cpp | 14 +++---- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index 122235a243..ecd7752087 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -69,48 +69,55 @@ namespace rs2 else return ""; } - std::map, std::vector> create_default_fw_table() + std::vector get_default_fw_image(int product_line, const std::string& pid) { - bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false); + std::vector image; - std::map, std::vector> rv; - - if (strlen(FW_D4XX_FW_IMAGE_VERSION) && !allow_rc_firmware) - { - int size = 0; - auto hex = fw_get_D4XX_FW_Image(size); - auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_D400, ""}] = vec; - } - - if (strlen(FW_SR3XX_FW_IMAGE_VERSION)) + switch (product_line) { - int size = 0; - auto hex = fw_get_SR3XX_FW_Image(size); - auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_SR300, ""}] = vec; - } - - if (strlen(FW_L51X_FW_IMAGE_VERSION)) + case RS2_PRODUCT_LINE_D400: { - int size = 0; - auto hex = fw_get_L51X_FW_Image(size); - auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_L500, "0B64"}] = vec; - - // This empty pid cell covers the case for L515 USB2 wrong pid on devices with old DFU version - rv[{RS2_PRODUCT_LINE_L500, ""}] = vec; + bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false); + if (strlen(FW_D4XX_FW_IMAGE_VERSION) && !allow_rc_firmware) + { + int size = 0; + auto hex = fw_get_D4XX_FW_Image(size); + image = std::vector(hex, hex + size); + } } - - if (strlen(FW_L53X_FW_IMAGE_VERSION)) - { - int size = 0; - auto hex = fw_get_L53X_FW_Image(size); - auto vec = std::vector(hex, hex + size); - rv[{RS2_PRODUCT_LINE_L500, "0B68"}] = vec; + break; + case RS2_PRODUCT_LINE_SR300: + if (strlen(FW_SR3XX_FW_IMAGE_VERSION)) + { + int size = 0; + auto hex = fw_get_SR3XX_FW_Image(size); + image = std::vector(hex, hex + size); + } + break; + case RS2_PRODUCT_LINE_L500: + if (pid == "0B68") // L535 + { + if (strlen(FW_L53X_FW_IMAGE_VERSION)) + { + int size = 0; + auto hex = fw_get_L53X_FW_Image(size); + image = std::vector(hex, hex + size); + } + } + else + { // default for all L515 use cases (include recovery usb2 old pid) + if (strlen(FW_L51X_FW_IMAGE_VERSION)) + { + int size = 0; + auto hex = fw_get_L51X_FW_Image(size); + image = std::vector(hex, hex + size); + } + } + break; + default: + break; } - - return rv; + return image; } std::vector parse_fw_version(const std::string& fw) diff --git a/common/fw-update-helper.h b/common/fw-update-helper.h index a2a079068b..78840ef6b7 100644 --- a/common/fw-update-helper.h +++ b/common/fw-update-helper.h @@ -13,7 +13,7 @@ namespace rs2 int parse_product_line(const std::string& product_line); std::string get_available_firmware_version(int product_line, const std::string& pid); - std::map, std::vector> create_default_fw_table(); + std::vector get_default_fw_image(int product_line, const std::string& pid); std::vector parse_fw_version(const std::string& fw); bool is_upgradeable(const std::string& curr, const std::string& available); bool is_recommended_fw_available(const std::string& product_line, const std::string& pid); diff --git a/common/model-views.cpp b/common/model-views.cpp index a0254d6053..f495b02fd0 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3884,14 +3884,12 @@ namespace rs2 if( dev.is() || is_upgradeable( fw, available_fw_ver) ) { recommended_fw_ver = available_fw_ver; - static auto table = create_default_fw_table(); - - std::vector image; - - if (table.find({ product_line, pid }) != table.end()) - image = table[{product_line, pid}]; - else - image = table[{product_line, ""}]; + auto image = get_default_fw_image(product_line, pid); + if (image.empty()) + { + not_model->add_log("could not detect a bundled FW version for the connected device", RS2_LOG_SEVERITY_WARN); + return false; + } manager = std::make_shared< firmware_update_manager >( not_model, *this, From 933b1a45c652f785032b65c647c78fa03938ba49 Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 8 Aug 2021 09:40:59 +0300 Subject: [PATCH 6/7] L535 recovery pid addition --- common/fw-update-helper.cpp | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index ecd7752087..103c4f0f4b 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -69,48 +69,48 @@ namespace rs2 else return ""; } - std::vector get_default_fw_image(int product_line, const std::string& pid) + std::vector< uint8_t > get_default_fw_image( int product_line, const std::string & pid ) { - std::vector image; + std::vector< uint8_t > image; - switch (product_line) + switch( product_line ) { - case RS2_PRODUCT_LINE_D400: + case RS2_PRODUCT_LINE_D400: { - bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false); - if (strlen(FW_D4XX_FW_IMAGE_VERSION) && !allow_rc_firmware) + bool allow_rc_firmware = config_file::instance().get_or_default( configurations::update::allow_rc_firmware, false ); + if( strlen( FW_D4XX_FW_IMAGE_VERSION ) && ! allow_rc_firmware ) { int size = 0; - auto hex = fw_get_D4XX_FW_Image(size); - image = std::vector(hex, hex + size); + auto hex = fw_get_D4XX_FW_Image( size ); + image = std::vector< uint8_t >( hex, hex + size ); } } - break; + break; case RS2_PRODUCT_LINE_SR300: - if (strlen(FW_SR3XX_FW_IMAGE_VERSION)) + if( strlen( FW_SR3XX_FW_IMAGE_VERSION ) ) { int size = 0; - auto hex = fw_get_SR3XX_FW_Image(size); - image = std::vector(hex, hex + size); + auto hex = fw_get_SR3XX_FW_Image( size ); + image = std::vector< uint8_t >( hex, hex + size ); } break; case RS2_PRODUCT_LINE_L500: - if (pid == "0B68") // L535 + if( pid == "0B68" || pid == "0B72" ) // L535 || L535 Recovery { - if (strlen(FW_L53X_FW_IMAGE_VERSION)) + if( strlen( FW_L53X_FW_IMAGE_VERSION ) ) { int size = 0; - auto hex = fw_get_L53X_FW_Image(size); - image = std::vector(hex, hex + size); - } + auto hex = fw_get_L53X_FW_Image( size ); + image = std::vector< uint8_t >( hex, hex + size ); + } } else - { // default for all L515 use cases (include recovery usb2 old pid) - if (strlen(FW_L51X_FW_IMAGE_VERSION)) + { // default for all L515 use cases (include recovery usb2 old pid) + if( strlen( FW_L51X_FW_IMAGE_VERSION ) ) { int size = 0; - auto hex = fw_get_L51X_FW_Image(size); - image = std::vector(hex, hex + size); + auto hex = fw_get_L51X_FW_Image( size ); + image = std::vector< uint8_t >( hex, hex + size ); } } break; From 3fdbe5105b1a6dca575a3d7ea006b19156258c4f Mon Sep 17 00:00:00 2001 From: Nir Azkiel Date: Sun, 8 Aug 2021 10:01:42 +0300 Subject: [PATCH 7/7] check supported option --- common/model-views.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/common/model-views.cpp b/common/model-views.cpp index f495b02fd0..bd499590b5 100644 --- a/common/model-views.cpp +++ b/common/model-views.cpp @@ -3866,11 +3866,18 @@ namespace rs2 // Override with device info if info is available if (dev.is()) { - fw = dev.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION); - recommended_fw_ver = dev.get_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION); + fw = dev.supports( RS2_CAMERA_INFO_FIRMWARE_VERSION ) + ? dev.get_info( RS2_CAMERA_INFO_FIRMWARE_VERSION ) + : ""; + + recommended_fw_ver = dev.supports(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION) + ? dev.get_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION) + : ""; } - product_line = parse_product_line(dev.get_info(RS2_CAMERA_INFO_PRODUCT_LINE)); + product_line = dev.supports(RS2_CAMERA_INFO_PRODUCT_LINE) + ? parse_product_line(dev.get_info(RS2_CAMERA_INFO_PRODUCT_LINE)) + : -1; // invalid product line, will be handled later on bool allow_rc_firmware = config_file::instance().get_or_default( configurations::update::allow_rc_firmware, @@ -3940,12 +3947,15 @@ namespace rs2 } else { - std::stringstream msg; - msg << "Current FW >= Bundled FW for: " << dev_name.first << " (S/N " << dev_name.second << ")\n" - << "Current Version: " << fw << "\n" - << "Recommended Version: " << recommended_fw_ver; + if( ! fw.empty() && ! recommended_fw_ver.empty() ) + { + std::stringstream msg; + msg << "Current FW >= Bundled FW for: " << dev_name.first << " (S/N " << dev_name.second << ")\n" + << "Current Version: " << fw << "\n" + << "Recommended Version: " << recommended_fw_ver; - not_model->add_log(msg.str(), RS2_LOG_SEVERITY_DEBUG); + not_model->add_log(msg.str(), RS2_LOG_SEVERITY_DEBUG); + } } } return false;