Skip to content

I2c unsigned fw retry fix - #14107

Merged
Nir-Az merged 1 commit into
realsenseai:developmentfrom
ejgoldik:I2C_unsigned_FW_retry_fix
Jul 3, 2025
Merged

I2c unsigned fw retry fix#14107
Nir-Az merged 1 commit into
realsenseai:developmentfrom
ejgoldik:I2C_unsigned_FW_retry_fix

Conversation

@ejgoldik

@ejgoldik ejgoldik commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

Tracked on [RSDSO-19992]
Fixed typo in flash backup retry mechanism.
Now unsigned FW update over I2C succeeds.

@Nir-Az
Nir-Az requested review from Copilot and remibettan July 2, 2025 05:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a typo in the I²C firmware retry mechanism so that the correct loop index (j) is used when deciding whether to sleep before retrying, enabling unsigned FW updates over I²C to succeed.

  • Changed retry condition variable from i to j in the exception handler
  • Preserves sleep delay only on non-final retry attempts
Comments suppressed due to low confidence (1)

src/ds/ds-device-common.cpp:169

  • Add or update unit tests covering the I²C flash backup retry logic, verifying both the sleep behavior on intermediate retries and the exception thrown on the final attempt.
                        catch (...)

catch (...)
{
if (i < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (j < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));

Copilot AI Jul 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Add braces around the if and else branches to improve readability and reduce risk when modifying this block in the future.

Suggested change
if (j < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (j < retries - 1) {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}

Copilot uses AI. Check for mistakes.
Comment on lines 168 to 170
}
catch (...)
{

Copilot AI Jul 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider logging the retry attempt number (j) and the caught exception to aid debugging when an I²C flash backup retry fails.

Suggested change
}
catch (...)
{
}
catch (const std::exception& e)
{
LOG_DEBUG("Retry attempt " << j + 1 << " failed with exception: " << e.what());
if (j < retries - 1) std::this_thread::sleep_for(std::chrono::milliseconds(100));
else throw;
}
catch (...)
{
LOG_DEBUG("Retry attempt " << j + 1 << " failed with an unknown exception.");

Copilot uses AI. Check for mistakes.

@remibettan remibettan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the sleep really needed here?

@ejgoldik

ejgoldik commented Jul 2, 2025

Copy link
Copy Markdown
Contributor Author

Is the sleep really needed here?

@remibettan - Not sure, it was already there, but it happens only upon retry (which should happen up to 3 times) so I'm not sure it's an issue.

@Nir-Az

Nir-Az commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator

Is the sleep really needed here?

@remibettan - Not sure, it was already there, but it happens only upon retry (which should happen up to 3 times) so I'm not sure it's an issue.

So we have a backend retries and an app level retries..
We need to understand this better IMO

@Nir-Az

Nir-Az commented Jul 2, 2025

Copy link
Copy Markdown
Collaborator

@remibettan I think we need more investigation and work on unsigned FW update but this PR fix a BUG.
We can merge it right?

@remibettan

Copy link
Copy Markdown
Contributor

@remibettan I think we need more investigation and work on unsigned FW update but this PR fix a BUG. We can merge it right?

sure

@Nir-Az
Nir-Az merged commit 0b1e5b6 into realsenseai:development Jul 3, 2025

@ev-mp ev-mp left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100msec is huge in terms of i2c, and can make the flow run 2-4 times slower (which is already tens of sec). Is it possible to reduce it to [20-30]ms range? Alternatively/Additionally, if most of the fails are during the backup phase, then let's remove the FW backup from default flow, and make it available on demand via a dedicated API flag/attribute

@ejgoldik

ejgoldik commented Jul 3, 2025

Copy link
Copy Markdown
Contributor Author

100msec is huge in terms of i2c, and can make the flow run 2-4 times slower (which is already tens of sec). Is it possible to reduce it to [20-30]ms range? Alternatively/Additionally, if most of the fails are during the backup phase, then let's remove the FW backup from default flow, and make it available on demand via a dedicated API flag/attribute

The 100msec is only in case of retry which are observed between once and twice during the entire process so the impact should be very limited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants