Skip to content

Commit

Permalink
Fix SR3xx FW recognized size.
Browse files Browse the repository at this point in the history
Modify SR3xx recovery type to be based on PID only (MF classes has changed as of build 1909)
  • Loading branch information
ev-mp committed Apr 21, 2021
1 parent b09a3df commit c29fc3c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
2 changes: 2 additions & 0 deletions include/librealsense2/h/rs_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ extern "C" {
* Firmware size constants
*/
const int signed_fw_size = 0x18031C;
const int signed_sr300_size = 0x0C025C;
const int unsigned_fw_size = 0x200000;
const int unsigned_sr300_size = 0x100000;

/**
* librealsense Recorder is intended for effective unit-testing
Expand Down
2 changes: 1 addition & 1 deletion src/fw-update/fw-update-factory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ namespace librealsense

int get_product_line(const platform::usb_device_info &usb_info)
{
if( SR300_RECOVERY == usb_info.pid && platform::RS2_USB_CLASS_VENDOR_SPECIFIC == usb_info.cls )
if( SR300_RECOVERY == usb_info.pid )
return RS2_PRODUCT_LINE_SR300;
if( ds::RS_RECOVERY_PID == usb_info.pid )
return RS2_PRODUCT_LINE_D400;
Expand Down
25 changes: 20 additions & 5 deletions src/rs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,10 @@ void rs2_update_firmware_cpp(const rs2_device* device, const void* fw_image, int
{
VALIDATE_NOT_NULL(device);
VALIDATE_NOT_NULL(fw_image);
VALIDATE_FIXED_SIZE(fw_image_size, signed_fw_size); // check if the given FW size matches the expected FW size
// check if the given FW size matches the expected FW size
auto fw_image_sz = { signed_fw_size, signed_sr300_size };
if (std::find(fw_image_sz.begin(), fw_image_sz.end(), fw_image_size) == fw_image_sz.end())
throw librealsense::invalid_value_exception(to_string() << "Unsupported firmware binary image provided { " << fw_image_size << " }");

auto fwu = VALIDATE_INTERFACE(device->device, librealsense::update_device_interface);

Expand All @@ -2933,7 +2936,10 @@ void rs2_update_firmware(const rs2_device* device, const void* fw_image, int fw_
{
VALIDATE_NOT_NULL(device);
VALIDATE_NOT_NULL(fw_image);
VALIDATE_FIXED_SIZE(fw_image_size, signed_fw_size); // check if the given FW size matches the expected FW size
// check if the given FW size matches the expected FW size
auto fw_image_sz = { signed_fw_size, signed_sr300_size };
if (std::find(fw_image_sz.begin(), fw_image_sz.end(), fw_image_size) == fw_image_sz.end())
throw librealsense::invalid_value_exception(to_string() << "Unsupported firmware binary image provided { " << fw_image_size << " }");

if (fw_image_size <= 0)
throw std::runtime_error("invlid firmware image size provided to rs2_update");
Expand Down Expand Up @@ -2997,7 +3003,13 @@ void rs2_update_firmware_unsigned_cpp(const rs2_device* device, const void* imag
{
VALIDATE_NOT_NULL(device);
VALIDATE_NOT_NULL(image);
VALIDATE_FIXED_SIZE(image_size, unsigned_fw_size); // check if the given FW size matches the expected FW size
// check if the given FW size matches the expected FW size
auto fw_image_sz = { unsigned_fw_size, unsigned_sr300_size };
if (std::find(fw_image_sz.begin(), fw_image_sz.end(), image_size) == fw_image_sz.end())
throw librealsense::invalid_value_exception(to_string() << "Unsupported firmware binary image provided { " << image_size << " }");

if (image_size <= 0)
throw std::runtime_error("invalid firmware image size provided to rs2_update_firmware_unsigned");

auto fwud = std::dynamic_pointer_cast<updatable>(device->device);
if (!fwud)
Expand All @@ -3016,10 +3028,13 @@ void rs2_update_firmware_unsigned(const rs2_device* device, const void* image, i
{
VALIDATE_NOT_NULL(device);
VALIDATE_NOT_NULL(image);
VALIDATE_FIXED_SIZE(image_size, unsigned_fw_size); // check if the given FW size matches the expected FW size
// check if the given FW size matches the expected FW size
auto fw_image_sz = { unsigned_fw_size, unsigned_sr300_size };
if (std::find(fw_image_sz.begin(), fw_image_sz.end(), image_size) == fw_image_sz.end())
throw librealsense::invalid_value_exception(to_string() << "Unsupported firmware binary image provided { " << image_size << " }");

if (image_size <= 0)
throw std::runtime_error("invlid firmware image size provided to rs2_update_firmware_unsigned");
throw std::runtime_error("invalid firmware image size provided to rs2_update_firmware_unsigned");

auto fwud = std::dynamic_pointer_cast<updatable>(device->device);
if (!fwud)
Expand Down

0 comments on commit c29fc3c

Please sign in to comment.