Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rs-fw-update tool - handle D457 MIPI device #12054

Merged
merged 5 commits into from
Aug 14, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 49 additions & 1 deletion tools/fw-update/rs-fw-update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,40 @@ void list_devices(rs2::context ctx)
}
}

int write_to_mipi_device( const std::vector< uint8_t > & fw_image)
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
{
// Write firmware to appropriate file descritptor
std::cout << std::endl << "Update can take up to 2 minutes" << std::endl;
std::ofstream fw_path_in_device( "/dev/d4xx-dfu504", std::ios::binary );
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
if( fw_path_in_device )
{
bool done = false;
std::thread t1(
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
[&done]()
{
for( int i = 0; i < 101 && ! done; ++i )
{
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
printf( "%d%%\r", i );
std::cout.flush();
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
}
} );
fw_path_in_device.write( reinterpret_cast< const char * >( fw_image.data() ), fw_image.size() );
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
done = true;
t1.join();
printf( " \r" );
}
else
{
std::cout << std::endl << "Firmware Update failed - wrong path or permissions missing";
return EXIT_FAILURE;
}
fw_path_in_device.close();
std::cout << std::endl << "Firmware update done" << std::endl;

return EXIT_SUCCESS;
}

int main(int argc, char** argv) try
{
#ifdef BUILD_EASYLOGGINGPP
Expand Down Expand Up @@ -299,9 +333,10 @@ int main(int argc, char** argv) try
if (!d.is<rs2::updatable>() || !(d.supports(RS2_CAMERA_INFO_SERIAL_NUMBER) && d.supports(RS2_CAMERA_INFO_FIRMWARE_UPDATE_ID)))
continue;

std::string usb_type = "unknown";
if (d.supports(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR))
{
std::string usb_type = d.get_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR);
usb_type = d.get_info(RS2_CAMERA_INFO_USB_TYPE_DESCRIPTOR);
if (usb_type.find("2.") != std::string::npos) {
std::cout << std::endl << "Warning! the camera is connected via USB 2 port, in case the process fails, connect the camera to a USB 3 port and try again" << std::endl;
}
Expand Down Expand Up @@ -342,6 +377,19 @@ int main(int argc, char** argv) try
std::cout << std::endl << "Updating device: " << std::endl;
print_device_info(d);

// If device is D457 connected by MIPI connector
if( strcmp( d.get_info( RS2_CAMERA_INFO_PRODUCT_ID ), "ABCD" ) == 0 &&
OhadMeir marked this conversation as resolved.
Show resolved Hide resolved
usb_type.compare( "unknown" ) == 0)
{
if( unsigned_arg.isSet() )
{
std::cout << std::endl << "Only signed FW is currently supported for MIPI devices" << std::endl;
return EXIT_FAILURE;
}

return write_to_mipi_device( fw_image );
Nir-Az marked this conversation as resolved.
Show resolved Hide resolved
}

if (unsigned_arg.isSet())
{
std::cout << std::endl << "Firmware update started" << std::endl << std::endl;
Expand Down
Loading