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

[gen3] fix internal -> external flash writes #2843

Merged
merged 4 commits into from
Dec 5, 2024

Conversation

avtolstoy
Copy link
Member

Problem

External flash writes must be performed from RAM and can't be done directly from internal flash due to DMA requirements.

Solution

If data address is not in RAM, force hal_flash_common_write to perform writes through an intermediate 256 byte on-stack aligned buffer.

Steps to Test

  • wiring/no_fixture_stress

Example App

N/A

References

#2840


Completeness

  • User is totes amazing for contributing!
  • Contributor has signed CLA (Info here)
  • Problem and Solution clearly stated
  • Run unit/integration/application tests on device
  • Added documentation
  • Added to CHANGELOG.md after merging (add links to docs and issues)

…gned_and_unaligned_writes_from_internal_flash_work. coalesce gen3/gen4 flash_common implementation
@avtolstoy avtolstoy added the bug label Dec 4, 2024
@avtolstoy avtolstoy added this to the 6.2.1 milestone Dec 4, 2024
@avtolstoy avtolstoy mentioned this pull request Dec 4, 2024
@@ -172,3 +205,17 @@ test(EXFLASH_02_rtl872x_validate_mode) {
assertEqual((uint32_t)SPIC->baudr, (uint32_t)1);
}
#endif // HAL_PLATFORM_RTL872X

test(EXFLASH_03_aligned_and_unaligned_writes_from_internal_flash_work) {
Copy link
Member

Choose a reason for hiding this comment

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

What part of this test is from_internal_flash? Does gen3 execute this code as XIP?
hal_storage_write() is the external OTA flash section for both platforms right?

Copy link
Member Author

Choose a reason for hiding this comment

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

static uint8_t dummy[8192 + 4] __attribute((aligned(4))) = {0xff, 0xff, 0xff, 0xff}; is internal on gen 3, RAM on Gen 4, but the test is still kind of valid for gen 4.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops, that needs to be static const now that you mention it.

@avtolstoy avtolstoy merged commit 4ad24ca into develop Dec 5, 2024
13 checks passed
@avtolstoy avtolstoy deleted the fix/gen3-internal-external-write branch December 5, 2024 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants