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

Add CRC code to EEPROM parameter storage #601

Merged
merged 2 commits into from
Jan 18, 2024
Merged

Add CRC code to EEPROM parameter storage #601

merged 2 commits into from
Jan 18, 2024

Conversation

jlaitine
Copy link

No description provided.

@jlaitine jlaitine requested review from pussuw and jnippula January 18, 2024 07:49
Copy link

@jnippula jnippula left a comment

Choose a reason for hiding this comment

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

Looks good

@jlaitine
Copy link
Author

I added code to fill the block with ff and re-calculate the crc, if the block reading fails many times. If the content of the eeprom is corrupted, and the crc really doesn't match, the block is otherwise permanently unusable; when separate bytes are updated via MTD layer, the layer does read-modify-write for the block. If the block read fails permanently, it also cannot be written.

@jlaitine
Copy link
Author

Still fixed pixhawk build

An EEPROM behind and i2c media is not 100% failure proof. But any errors
in e.g. mtd_params reading can cause catastrophic failures in flight.

Mitigate any possible errors in px4 mtd_params reading by adding crc code
to every page on EEPROM

In addition:
- Read every block into a temporary buffer before copying to clients buffer;
  this fixes some issues with memory protected builds when writing directly
  to user buffers from i2c driver interrupt handler
- If a read request fails, don't return any partially filled buffer to user

Signed-off-by: Jukka Laitinen <[email protected]>
@jlaitine jlaitine merged commit 92ef045 into main Jan 18, 2024
23 checks passed
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.

3 participants