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

Component: flash parameter storage on stm32h7. Fixes #15331. #19838

Merged
merged 1 commit into from
Jul 25, 2022

Conversation

taylornelms15
Copy link

As per the discussion in #15331, fixed issue where stm32h7 chips
use hardware ECC bits in program memory that disallow overwriting
32-byte flash line that has already been written. As such,
this change allows for a variant implementation of the flashfs system
that uses more space in the flash entry header in order to
allow an entire line to be reserved for erasing an entry.

Signed-off-by: Taylor Nelms [email protected]

Describe problem solved by this pull request

Fixed #15331 allowing for onboard-flash parameter storage on STM32H7 chips

Describe your solution

I added padding to the flash entry structure such that "erasing" an entry could be done by writing an entire flash line, avoiding the issue with hardware ECC bits causing issues in overwriting the flag on each entry.

Describe possible alternatives

I looked into other flash filesystems as potential drop-in alternatives, but did not find any that, out-of-the-box, met the limitations of the STM32H7.

Test data / coverage

Tests were admittedly minimal; application target was custom board for Robotic Research, LLC applications. Parameter reading/writing confirmed functional across reboots when configured to use two or one sectors of flash program memory.

Additional context

No additional context.

@dagar
Copy link
Member

dagar commented Jun 27, 2022

FYI @spiderkeys @taileron

@davids5
Copy link
Member

davids5 commented Jun 27, 2022

Thank you @taylornelms15 I am OOO until 7/5 I will look at it as soon as I can when I get back

Copy link
Member

@davids5 davids5 left a comment

Choose a reason for hiding this comment

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

@taylornelms15 - This looks good. I raised a minor nit in naming to match the reference manual.

What testing was done?

@taylornelms15
Copy link
Author

Also @davids5 let me know if there's anything I'm messing up procedurally with this request, I haven't gone through the pull request process in the past so I'm willing to take notes on process mistakes.

@davids5
Copy link
Member

davids5 commented Jul 6, 2022

@taylornelms15 - you have some CI failures

../../src/lib/parameters/flashparams/flashfs32.c:716:16: error: 'FLASH_FLAG_LINE_SIZE' undeclared (first use in this function); did you mean 'FLASH_FLAG_ROW_SIZE'?
  716 |  h_flag_t data[FLASH_FLAG_LINE_SIZE] = {0xffff};
      |                ^~~~~~~~~~~~~~~~~~~~
      |                FLASH_FLAG_ROW_SIZE

Once you fix it. Please rebase on main and fixup the commits
git checkout main
git pull <remote px4> main
git checkout pr-flash-params-32byte-aligned

git rebase i main

Then change the pick to f for the all the commits not including the top one.

then
git push -f <remote for taylornelms15> pr-flash-params-32byte-aligned

This will fixup the commits. making one clean commit with the comment from 5813198

    As per the discussion in PX4#15331, fixed issue where stm32h7 chips
    use hardware ECC bits in program memory that disallow overwriting
    32-byte flash line that has already been written. As such,
    this change allows for a variant implementation of the flashfs system
    that uses more space in the flash entry header in order to
    allow an entire line to be reserved for erasing an entry.

Signed-off-by: Taylor Nelms <[email protected]>
@taylornelms15 taylornelms15 force-pushed the pr-flash-params-32byte-aligned branch from 72e469d to 71e937b Compare July 6, 2022 18:12
@davids5
Copy link
Member

davids5 commented Jul 8, 2022

@taylornelms15 - will you be following up on this?

@taylornelms15
Copy link
Author

@davids5 I thought I put the edits into the code and pushed it; did it not go through? I'm happy to follow up on whatever parts are missing.

@davids5
Copy link
Member

davids5 commented Jul 8, 2022

@taylornelms15 - Sorry my bad. I missed the last commit. Let see how CI likes it.

@taylornelms15
Copy link
Author

I can't tell from the logs whether the continuous-integration/jenkins/pr-head CI failure is something on my end or not; definitely let me know if I can make any other modifications to close this thing out

@taylornelms15
Copy link
Author

@davids5 would love to wrap this up so we can use it in actual environments; is there anything else I should change? I can't tell if something on my end is blocking continuous-integration/jenkins/pr-head

@davids5
Copy link
Member

davids5 commented Jul 15, 2022

Having a build using the Flash parameters on an H7 and run on the test rack would help test this. There have been some issues with the test rack that are unrelated. @dagar - do you have a way of testing this?

@matthewoots
Copy link
Contributor

@taylornelms15 Thank you for your fix on the H743 flash params I've tested the flash32.c and your commit works for my H743 board, in fact I tried on an H7 AIO board without an SD card slot and it works like a charm using Matek H743-slim board target as a base. Can this be pushed to master?

matthewoots added a commit to matthewoots/PX4-Autopilot that referenced this pull request Jul 23, 2022
…H7 board with the relevant changes to flash params
@davids5 davids5 requested review from davids5 and dagar July 23, 2022 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STM32H7 flash-based params
6 participants