Bugfix: SDIO capacity shows incorrectly on F4 devices#11347
Open
cluez0r wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
Open
Bugfix: SDIO capacity shows incorrectly on F4 devices#11347cluez0r wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
cluez0r wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
Conversation
Branch Targeting SuggestionYou've targeted the
If This is an automated suggestion to help route contributions to the appropriate branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
So I decided to make my own flight controller and believe I found a bug on F4 devices. It seemed weird to me to run SD cards in SPI mode since SDIO mode is faster, so I designed that into an STM32F405 board and it worked fine - except the capacity shows as 512 times larger than actual capacity. The same board has also been produced with an STM32H743 CPU which shows the correct capacity, so I decided to dig a bit deeper:
In the F7 and H7 HAL at line 453, the capacity is divided with 512 before the SD_GetCardInfo function returns. The equivalent calculation is performed in SPI mode as well.
However, in the F4 HAL it is not.
I've noticed that almost no F4 targets use SDIO (they all seem to be using SPI mode) so that may be the reason why this went unnoticed. The devices that do are the F7 and H7 series but on those platforms this doesn't manifest as they use a different version of the HAL.
When you adjust the F4 HAL to be equivalent to the F7/H7 HAL, the correct capacity is reported. I've tested this on the five boards I have and all of them work when making this change. The only officially supported target using the F4 SDIO HAL seems to be the PIXRACER so the affected user base is likely to be minimal by this change.