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

embassy-stm32 support g0 second flash bank #3711

Merged
merged 4 commits into from
Jan 2, 2025

Conversation

chanterheld
Copy link
Contributor

Integration of changes made in embassy-rs/stm32-data/pull/556: Addition of dual flash bank support for G0.

  • Setting of bank select for erase bit in erase sector
  • Waiting for both busy flags

Would be nice to have some feedback on how to deal with the now diverging options/registers other than the conditional compilation

Copy link
Member

@Dirbaio Dirbaio left a comment

Choose a reason for hiding this comment

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

thank you!

Would be nice to have some feedback on how to deal with the now diverging options/registers other than the conditional compilation

conditional compilation is the way to go. it's a giant pain but there's no better alternative really :(

@Dirbaio Dirbaio added this pull request to the merge queue Jan 2, 2025
Merged via the queue into embassy-rs:main with commit 6824567 Jan 2, 2025
7 checks passed
@chanterheld chanterheld deleted the feature/flash_stm32g0_dualbank branch January 3, 2025 06:34
@chanterheld
Copy link
Contributor Author

It has occurred to me that there might be an issue with this code for dual bank 256kb or less devices. The way the idx variable is calculated in the page erase method does not take into account the dual flash banks. This is 'fixed' for 512kbit devices by the 7bit bit mask for the page number. Another device will for example attempt to erase bank 2 page 64, instead of bank 2 page 0. This was an issue that arguably existed before already as bank 2 was just unavailable.

I will read up on the full set of available G0/G4 variants and see if i can come up with a more general solution. In the meantime could you elaborate on:

  1. Why is the idx value being recalculated instead of using the index_in_bank variable available in FlashSector. Using this value instead of idx would probably solve the issue.
  2. If and how would you want to deal with ic varients that can operate both in single and dual bank mode

@chanterheld
Copy link
Contributor Author

From what I can tell this will be an issue for

  • G0x1 256kb devices operating in dual bank mode (no supported by stm32-metapac)
  • G0x0 512kb devices. This however has never worked
  • G4C3 devices with 256kb or less in dual bank mode (not supported also)

Ill come with a proper solution that works for these devices once I'm back from vacation.

@Dirbaio
Copy link
Member

Dirbaio commented Jan 3, 2025

Why is the idx value being recalculated instead of using the index_in_bank variable available in FlashSector. Using this value instead of idx would probably solve the issue.

I don't know, maybe the person who wrote the code wasn't aware of it.

If and how would you want to deal with ic varients that can operate both in single and dual bank mode

this is something that Embassy should definitely support and is currently a bit lacking. Currently embassy-stm32 assumes single-bank for some chips and just breaks in dual-bank mode (for example G4, in dual bank it has a hole in the address space between the two banks). It's possible it assumes dual-bank for other chips, not sure.

I think what would make most sense is a dual-bank Cargo feature.

It also has implications for stm32-data, because the memory map changes depending on the mode. G4 has the hole, also G4 and others change the sector size.

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.

2 participants