From 56beeb271846d0b27954a795b516b52fda12f03d Mon Sep 17 00:00:00 2001 From: Remi Bettan Date: Sun, 24 Jul 2022 14:18:31 +0300 Subject: [PATCH] check fw compatibility for dfu via mipi --- common/fw-update-helper.cpp | 11 +++++++++-- common/fw-update-helper.h | 21 +++++++++++++++++++-- src/ds5/ds5-private.h | 3 ++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/common/fw-update-helper.cpp b/common/fw-update-helper.cpp index 29a7efe2e9..8ebe80f6b3 100644 --- a/common/fw-update-helper.cpp +++ b/common/fw-update-helper.cpp @@ -194,13 +194,19 @@ namespace rs2 return false; } - void firmware_update_manager::process_flow_mipi() + void firmware_update_manager_mipi::process_flow(std::function cleanup, invoker invoke) { if (!_is_signed) { LOG_INFO("Only Signed Firmware can be burnt on MIPI device"); return; } + auto dev_updatable = _dev.as(); + if(!(dev_updatable && dev_updatable.check_firmware_compatibility(_fw))) + { + fail("Firmware Update failed - fw version must be newer than version 5.13.1.1"); + return; + } // Enter DFU mode auto device_debug = _dev.as(); @@ -238,7 +244,8 @@ namespace rs2 auto str = _dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID); if (!strcmp(_dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID), "ABCD")) // if device is D457 { - process_flow_mipi(); + firmware_update_manager_mipi fw_update_mgr_mipi(_not_model, _model, _dev, _ctx, _fw, _is_signed); + fw_update_mgr_mipi.process_flow(cleanup, invoke); return; } diff --git a/common/fw-update-helper.h b/common/fw-update-helper.h index 1f2b05ea73..73f23846f6 100644 --- a/common/fw-update-helper.h +++ b/common/fw-update-helper.h @@ -4,6 +4,7 @@ #pragma once #include "notifications.h" +#include "../src/fw-update/fw-update-device-interface.h" namespace rs2 @@ -28,10 +29,9 @@ namespace rs2 const device_model& get_device_model() const { return _model; } std::shared_ptr get_protected_notification_model() { return _not_model.lock(); }; - private: + protected: void process_flow(std::function cleanup, invoker invoke) override; - void process_flow_mipi(); bool check_for( std::function action, std::function cleanup, std::chrono::system_clock::duration delta); @@ -44,6 +44,23 @@ namespace rs2 device_model& _model; }; + class firmware_update_manager_mipi : public process_manager + { + public: + firmware_update_manager_mipi(std::weak_ptr not_model, device_model& model, device dev, context ctx, std::vector fw, bool is_signed) + : process_manager("Firmware Update Mipi"), _not_model(not_model), _model(model), + _fw(fw), _is_signed(is_signed), _dev(dev), _ctx(ctx) {} + void process_flow(std::function cleanup, invoker invoke); + + private: + std::weak_ptr _not_model; + device _dev; + context _ctx; + std::vector _fw; + bool _is_signed; + device_model& _model; + }; + struct fw_update_notification_model : public process_notification_model { fw_update_notification_model(std::string name, diff --git a/src/ds5/ds5-private.h b/src/ds5/ds5-private.h index 29262e2812..84a26fd0df 100644 --- a/src/ds5/ds5-private.h +++ b/src/ds5/ds5-private.h @@ -735,7 +735,8 @@ namespace librealsense {RS465_PID, "5.12.7.100" }, {RS416_RGB_PID, "5.8.15.0" }, {RS405_PID, "5.12.11.8" }, - {RS455_PID, "5.12.7.100" } + {RS455_PID, "5.12.7.100" }, + {RS457_PID, "5.13.1.1" } };