Skip to content

Commit

Permalink
DFU via MIPI - started
Browse files Browse the repository at this point in the history
  • Loading branch information
remibettan committed Jul 17, 2022
1 parent e2f8509 commit db22646
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
44 changes: 44 additions & 0 deletions common/fw-update-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,54 @@ namespace rs2
return false;
}

void firmware_update_manager::process_flow_mipi()
{
if (!_is_signed)
{
LOG_INFO("Only Signed Firmware can be burnt on MIPI device");
return;
}

// Enter DFU mode
auto device_debug = _dev.as<rs2::debug_protocol>();
uint32_t dfu_opcode = 0x1e;
device_debug.build_command(dfu_opcode, 1);

_progress = 30;
// Grant permissions for writing
// skipped for now - must be done in sudo
//chmod("/dev/d4xx-dfu504", __S_IREAD|__S_IWRITE);

// Write signed firmware to appropriate file descritptor
std::ofstream fw_path_in_device("/dev/d4xx-dfu504", std::ios::binary);
if (fw_path_in_device)
{
fw_path_in_device.write(reinterpret_cast<const char*>(_fw.data()), _fw.size());
}
else
{
fail("Firmware Update failed - wrong path or permissions missing");
return;
}
LOG_INFO("Firmware Update for MIPI device done.");
fw_path_in_device.close();

_progress = 100;
_done = true;
// need to find a way to update the fw version field in the viewer
}

void firmware_update_manager::process_flow(
std::function<void()> cleanup,
invoker invoke)
{
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();
return;
}

std::string serial = "";
if (_dev.supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID))
serial = _dev.get_info(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID);
Expand Down
3 changes: 2 additions & 1 deletion common/fw-update-helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace rs2
private:
void process_flow(std::function<void()> cleanup,
invoker invoke) override;
void process_flow_mipi();
bool check_for(
std::function<bool()> action, std::function<void()> cleanup,
std::chrono::system_clock::duration delta);
Expand All @@ -53,4 +54,4 @@ namespace rs2
void draw_expanded(ux_window& win, std::string& error_message) override;
int calc_height() override;
};
}
}

0 comments on commit db22646

Please sign in to comment.