Skip to content

Commit

Permalink
Merge pull request #4746 from dorodnic/development
Browse files Browse the repository at this point in the history
Adding option to use Pre-Release firmware
  • Loading branch information
ev-mp authored Aug 28, 2019
2 parents 446560b + 176a28d commit 8b48b3c
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 73 deletions.
33 changes: 21 additions & 12 deletions common/fw-update-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@

#ifdef INTERNAL_FW
#include "common/fw/D4XX_FW_Image.h"
#include "common/fw/D4XX_RC_Image.h"
#include "common/fw/SR3XX_FW_Image.h"
#else
#define FW_D4XX_FW_IMAGE_VERSION ""
#define FW_D4XX_RC_IMAGE_VERSION ""
#define FW_SR3XX_FW_IMAGE_VERSION ""
const char* fw_get_D4XX_FW_Image(int) { return NULL; }
const char* fw_get_D4XX_RC_Image(int) { return NULL; }
const char* fw_get_SR3XX_FW_Image(int) { return NULL; }
#endif // INTERNAL_FW

constexpr const char* recommended_fw_url = "https://downloadcenter.intel.com/download/27522/Latest-Firmware-for-Intel-RealSense-D400-Product-Family?v=t";
constexpr const char* recommended_fw_url = "https://dev.intelrealsense.com/docs/firmware-releases";

namespace rs2
{
Expand All @@ -40,12 +43,6 @@ namespace rs2
return !(strcmp("", FW_D4XX_FW_IMAGE_VERSION) == 0);
}

static std::map<int, std::string> product_line_to_fw =
{
{RS2_PRODUCT_LINE_D400, FW_D4XX_FW_IMAGE_VERSION},
{RS2_PRODUCT_LINE_SR300, FW_SR3XX_FW_IMAGE_VERSION},
};

int parse_product_line(std::string id)
{
if (id == "D400") return RS2_PRODUCT_LINE_D400;
Expand All @@ -55,24 +52,36 @@ namespace rs2

std::string get_available_firmware_version(int product_line)
{
auto it = product_line_to_fw.find(product_line);
if (it != product_line_to_fw.end())
return it->second;
return "";
bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false);

if (product_line == RS2_PRODUCT_LINE_D400 && allow_rc_firmware) return FW_D4XX_RC_IMAGE_VERSION;
else 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 return "";
}

std::map<int, std::vector<uint8_t>> create_default_fw_table()
{
bool allow_rc_firmware = config_file::instance().get_or_default(configurations::update::allow_rc_firmware, false);

std::map<int, std::vector<uint8_t>> rv;

if ("" != FW_D4XX_FW_IMAGE_VERSION)
if ("" != FW_D4XX_FW_IMAGE_VERSION && !allow_rc_firmware)
{
int size = 0;
auto hex = fw_get_D4XX_FW_Image(size);
auto vec = std::vector<uint8_t>(hex, hex + size);
rv[RS2_PRODUCT_LINE_D400] = vec;
}

if ("" != FW_D4XX_RC_IMAGE_VERSION && allow_rc_firmware)
{
int size = 0;
auto hex = fw_get_D4XX_RC_Image(size);
auto vec = std::vector<uint8_t>(hex, hex + size);
rv[RS2_PRODUCT_LINE_D400] = vec;
}

if ("" != FW_SR3XX_FW_IMAGE_VERSION)
{
int size = 0;
Expand Down
10 changes: 9 additions & 1 deletion common/fw/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@ file(READ "firmware-version.h" ver)

message(STATUS "Fetching recommended firmwares:")

string(REGEX MATCH "D4XX_RC_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver})
set(D4XX_RC_VERSION ${CMAKE_MATCH_1})
message(STATUS "D4XX_RC_VERSION: ${D4XX_RC_VERSION}")
set(D4XX_RC_SHA1 7ae298ff3c7bb1a6afc6fe70b3ec6527adcecd73)
set(D4XX_RC_URL "http://realsense-hw-public.s3-eu-west-1.amazonaws.com/Releases/RS4xx/FW")

string(REGEX MATCH "D4XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver})
set(D4XX_FW_VERSION ${CMAKE_MATCH_1})
message(STATUS "D4XX_FW_VERSION: ${D4XX_FW_VERSION}")
set(D4XX_FW_SHA1 7ae298ff3c7bb1a6afc6fe70b3ec6527adcecd73)
set(D4XX_FW_SHA1 2fb8830cd86c0871e59ec17bd674d98df229442b)
set(D4XX_FW_URL "http://realsense-hw-public.s3-eu-west-1.amazonaws.com/Releases/RS4xx/FW")


string(REGEX MATCH "SR3XX_RECOMMENDED_FIRMWARE_VERSION \"([0-9]+.[0-9]+.[0-9]+.[0-9]+)\"" _ ${ver})
set(SR3XX_FW_VERSION ${CMAKE_MATCH_1})
message(STATUS "SR3XX_FW_VERSION: ${SR3XX_FW_VERSION}")
Expand Down Expand Up @@ -61,6 +68,7 @@ function(target_binary url version sha1 symbol ext)
endfunction()

target_binary( "${D4XX_FW_URL}" "${D4XX_FW_VERSION}" "${D4XX_FW_SHA1}" D4XX_FW_Image .bin)
target_binary( "${D4XX_RC_URL}" "${D4XX_RC_VERSION}" "${D4XX_RC_SHA1}" D4XX_RC_Image .bin)
target_binary( "${SR3XX_FW_URL}" "${SR3XX_FW_VERSION}" "${SR3XX_FW_SHA1}" SR3XX_FW_Image .bin)

install(TARGETS ${PROJECT_NAME} EXPORT realsense2Targets
Expand Down
3 changes: 2 additions & 1 deletion common/fw/firmware-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@

#pragma once

#define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.11.14.0"
#define D4XX_RECOMMENDED_FIRMWARE_VERSION "5.11.11.100"
#define SR3XX_RECOMMENDED_FIRMWARE_VERSION "3.26.1.0"
#define D4XX_RC_FIRMWARE_VERSION "5.11.14.0"
1 change: 1 addition & 0 deletions common/fw/uvc_fw.rc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include "D4XX_FW_Image.rc"
#include "D4XX_RC_Image.rc"
#include "SR3XX_FW_Image.rc"
143 changes: 86 additions & 57 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2935,84 +2935,111 @@ namespace rs2
for (auto&& n : related_notifications) n->dismiss(false);
}

device_model::device_model(device& dev, std::string& error_message, viewer_model& viewer)
: dev(dev),
syncer(viewer.syncer),
_update_readonly_options_timer(std::chrono::seconds(6))
{
void device_model::refresh_notifications(viewer_model& viewer)
{
for (auto&& n : related_notifications) n->dismiss(false);

auto name = get_device_name(dev);
id = to_string() << name.first << ", " << name.second;

bool fw_update_required = false;
for (auto&& sub : dev.query_sensors())
if ((bool)config_file::instance().get(configurations::update::recommend_updates))
{
if (sub.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION) &&
sub.supports(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION) &&
sub.supports(RS2_CAMERA_INFO_PRODUCT_LINE))
bool fw_update_required = false;
for (auto&& sub : dev.query_sensors())
{
std::string fw = sub.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);
std::string recommended = sub.get_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION);
if (sub.supports(RS2_CAMERA_INFO_FIRMWARE_VERSION) &&
sub.supports(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION) &&
sub.supports(RS2_CAMERA_INFO_PRODUCT_LINE))
{
std::string fw = sub.get_info(RS2_CAMERA_INFO_FIRMWARE_VERSION);
std::string recommended = sub.get_info(RS2_CAMERA_INFO_RECOMMENDED_FIRMWARE_VERSION);

int product_line = parse_product_line(sub.get_info(RS2_CAMERA_INFO_PRODUCT_LINE));
int product_line = parse_product_line(sub.get_info(RS2_CAMERA_INFO_PRODUCT_LINE));

std::string available = get_available_firmware_version(product_line);
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;
std::string available = get_available_firmware_version(product_line);

std::shared_ptr<firmware_update_manager> manager = nullptr;
std::shared_ptr<firmware_update_manager> manager = nullptr;

if (is_upgradeable(fw, available))
{
recommended = available;
if (is_upgradeable(fw, available))
{
recommended = available;

static auto table = create_default_fw_table();
static auto table = create_default_fw_table();

manager = std::make_shared<firmware_update_manager>(*this, dev, viewer.ctx, table[product_line], true);
}
manager = std::make_shared<firmware_update_manager>(*this, dev, viewer.ctx, table[product_line], true);
}

if (is_upgradeable(fw, recommended))
{
std::string msg = to_string()
<< name.first << " (S/N " << name.second << ")\n"
<< "Current Version: " + fw + "\nRecommended Version: " + recommended;
if (!fw_update_required)
if (is_upgradeable(fw, recommended))
{
auto n = std::make_shared<fw_update_notification_model>(
msg, manager, false);
viewer.not_model.add_notification(n);
std::stringstream msg;
msg << name.first << " (S/N " << name.second << ")\n"
<< "Current Version: " << fw << "\n";

fw_update_required = true;
if (is_rc)
msg << "Release Candidate: " << recommended << " Pre-Release";
else
msg << "Recommended Version: " << recommended;

if (!fw_update_required)
{
auto n = std::make_shared<fw_update_notification_model>(
msg.str(), manager, false);
viewer.not_model.add_notification(n);

related_notifications.push_back(n);
fw_update_required = true;

related_notifications.push_back(n);
}
}
}
}
}
}

auto model = std::make_shared<subdevice_model>(dev, std::make_shared<sensor>(sub), error_message, viewer);
subdevices.push_back(model);

if (model->supports_on_chip_calib())
if ((bool)config_file::instance().get(configurations::update::recommend_calibration))
{
for (auto&& model : subdevices)
{
// Make sure we don't spam calibration remainders too often:
time_t rawtime;
time(&rawtime);
std::string id = to_string() << configurations::viewer::last_calib_notice << "." << name.second;
long long last_time = config_file::instance().get_or_default(id.c_str(), (long long)0);

std::string msg = to_string()
<< name.first << " (S/N " << name.second << ")";
auto manager = std::make_shared<on_chip_calib_manager>(viewer, model, *this, dev);
auto n = std::make_shared<autocalib_notification_model>(
msg, manager, false);

// Recommend calibration once a week per device
if (rawtime - last_time < 60)
if (model->supports_on_chip_calib())
{
n->snoozed = true;
// Make sure we don't spam calibration remainders too often:
time_t rawtime;
time(&rawtime);
std::string id = to_string() << configurations::viewer::last_calib_notice << "." << name.second;
long long last_time = config_file::instance().get_or_default(id.c_str(), (long long)0);

std::string msg = to_string()
<< name.first << " (S/N " << name.second << ")";
auto manager = std::make_shared<on_chip_calib_manager>(viewer, model, *this, dev);
auto n = std::make_shared<autocalib_notification_model>(
msg, manager, false);

// Recommend calibration once a week per device
if (rawtime - last_time < 60)
{
n->snoozed = true;
}

viewer.not_model.add_notification(n);
related_notifications.push_back(n);
}

viewer.not_model.add_notification(n);
related_notifications.push_back(n);
}
}
}

device_model::device_model(device& dev, std::string& error_message, viewer_model& viewer)
: dev(dev),
syncer(viewer.syncer),
_update_readonly_options_timer(std::chrono::seconds(6))
{
auto name = get_device_name(dev);
id = to_string() << name.first << ", " << name.second;

for (auto&& sub : dev.query_sensors())
{
auto model = std::make_shared<subdevice_model>(dev, std::make_shared<sensor>(sub), error_message, viewer);
subdevices.push_back(model);
}

// Initialize static camera info:
for (auto i = 0; i < RS2_CAMERA_INFO_COUNT; i++)
Expand Down Expand Up @@ -3046,6 +3073,8 @@ namespace rs2
}
play_defaults(viewer);
}

refresh_notifications(viewer);
}
void device_model::play_defaults(viewer_model& viewer)
{
Expand Down Expand Up @@ -4302,7 +4331,7 @@ namespace rs2
product_line_str = sensors.front().get_info(RS2_CAMERA_INFO_PRODUCT_LINE);
int product_line = parse_product_line(product_line_str);

static auto table = create_default_fw_table();
auto table = create_default_fw_table();

begin_update(table[product_line], viewer, error_message);
}
Expand Down
9 changes: 9 additions & 0 deletions common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ namespace rs2
static const char* default_path { "record.default_path" };
static const char* compression_mode { "record.compression" };
}
namespace update
{
static const char* allow_rc_firmware { "update.allow_rc_firmware" };
static const char* recommend_updates { "update.recommend_updates" };
static const char* recommend_calibration { "update.recommend_calibration" };
}
namespace viewer
{
static const char* is_3d_view { "viewer_model.is_3d_view" };
Expand Down Expand Up @@ -765,6 +771,9 @@ namespace rs2
void stop_recording(viewer_model& viewer);
void pause_record();
void resume_record();

void refresh_notifications(viewer_model& viewer);

int draw_playback_panel(ux_window& window, ImFont* font, viewer_model& view);
bool draw_advanced_controls(viewer_model& view, ux_window& window, std::string& error_message);
void draw_controls(float panel_width, float panel_height,
Expand Down
4 changes: 4 additions & 0 deletions common/ux-window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ namespace rs2
{
void prepare_config_file()
{
config_file::instance().set_default(configurations::update::allow_rc_firmware, false);
config_file::instance().set_default(configurations::update::recommend_calibration, true);
config_file::instance().set_default(configurations::update::recommend_updates, true);

config_file::instance().set_default(configurations::window::is_fullscreen, false);
config_file::instance().set_default(configurations::window::saved_pos, false);
config_file::instance().set_default(configurations::window::saved_size, false);
Expand Down
Loading

0 comments on commit 8b48b3c

Please sign in to comment.