Skip to content

Comments

Bugfix: SDIO capacity shows incorrectly on F4 devices#11347

Open
cluez0r wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
cluez0r:sdmmc_f4_capacity_bug
Open

Bugfix: SDIO capacity shows incorrectly on F4 devices#11347
cluez0r wants to merge 1 commit intoiNavFlight:maintenance-9.xfrom
cluez0r:sdmmc_f4_capacity_bug

Conversation

@cluez0r
Copy link

@cluez0r cluez0r commented Feb 20, 2026

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.

@github-actions
Copy link

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@cluez0r cluez0r changed the base branch from master to maintenance-9.x February 21, 2026 09:00
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.

1 participant