Skip to content

STM32 {F7|H7} Use 250 Ms Data path timeout, regardless of Card Clock frequency - #3669

Merged
antmerlino merged 3 commits into
apache:masterfrom
nuttx-to-asf:pr-stm-sdio-sdmmc-timeout-fix
May 7, 2021
Merged

antmerlino merged 3 commits into
apache:masterfrom
nuttx-to-asf:pr-stm-sdio-sdmmc-timeout-fix

Conversation

@davids5

@davids5 davids5 commented May 7, 2021

Copy link
Copy Markdown
Contributor

Summary

Timeouts were occurring on STMF4 based platforms on differnt SD card based on formatting, and age. For additional information See

Impact

The hard coded contestant would timeout at 100+ Ms. The spec is 250.

Testing

PX4 fmu-v3 (stm32F4)
PX4 fmu-v5X (stm32F7)
PX4 fmu-v6X (stm32H7)

@davids5
davids5 requested a review from antmerlino May 7, 2021 11:56
@davids5

davids5 commented May 7, 2021

Copy link
Copy Markdown
Contributor Author

Commiters Please review but wait for @antmerlino to cross test and approve.

Comment thread arch/arm/src/stm32/stm32_sdio.c Resolved
Comment thread arch/arm/src/stm32/stm32_sdio.c Resolved
@davids5
davids5 force-pushed the pr-stm-sdio-sdmmc-timeout-fix branch 2 times, most recently from f70179c to 7715b50 Compare May 7, 2021 15:18
@davids5
davids5 requested a review from gustavonihei May 7, 2021 16:30
Comment thread arch/arm/src/stm32/stm32_sdio.c Outdated
Comment on lines +175 to +179
/* DTIMER setting
*
* Assuming Max timeout in bypass 48 Mhz
*
*/

@gustavonihei gustavonihei May 7, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/* DTIMER setting
*
* Assuming Max timeout in bypass 48 Mhz
*
*/
/* DTIMER setting
*
* Assuming Max timeout in bypass 48 Mhz
*/

nit: This empty line may be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reformatted

Comment thread arch/arm/src/stm32/stm32_sdio.c Outdated
Comment on lines +181 to +180
#define IP_CLCK_FREQ UINT32_C(48000000)
#define SDIO_DTIMER_DATATIMEOUT_MS 250

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
#define IP_CLCK_FREQ UINT32_C(48000000)
#define SDIO_DTIMER_DATATIMEOUT_MS 250
#define IP_CLCK_FREQ UINT32_C(48000000)
#define SDIO_DTIMER_DATATIMEOUT_MS 250

nit: suggestion for alignment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Reformatted

static void stm32_dataconfig(uint32_t timeout, uint32_t dlen, uint32_t dctrl)
{
uint32_t regval = 0;
uint32_t clkdiv;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint32_t clkdiv;
uint32_t clkdiv = 0;

nit: since regval is being initialized, clkdiv could also be.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks. All Vars are initialized in the body, So I opted to remove the wasteful inits.

uint32_t dlen, uint32_t dctrl)
{
uint32_t regval = 0;
uint32_t clkdiv;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint32_t clkdiv;
uint32_t clkdiv = 0;

nit: same as the previous one

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"

static void stm32_dataconfig(struct stm32_dev_s *priv, uint32_t timeout,
uint32_t dlen, bool receive)
{
uint32_t clkdiv;

@gustavonihei gustavonihei May 7, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
uint32_t clkdiv;
uint32_t clkdiv = 0;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

"

@gustavonihei

Copy link
Copy Markdown
Contributor

LGTM.
I just focused on code quality aspects. Since I don't know much about these peripherals, I'll let the approval for the other reviewers.

@davids5
davids5 force-pushed the pr-stm-sdio-sdmmc-timeout-fix branch from 7715b50 to db97043 Compare May 7, 2021 17:06
@davids5

davids5 commented May 7, 2021

Copy link
Copy Markdown
Contributor Author

@gustavonihei - Thank you for being so thorough!

@gustavonihei

Copy link
Copy Markdown
Contributor

@gustavonihei - Thank you for being so thorough!

I'll take that as a compliment! 😆

@davids5

davids5 commented May 7, 2021

Copy link
Copy Markdown
Contributor Author

@gustavonihei - Thank you for being so thorough!

I'll take that as a compliment!

Good! Because It was meant as one!

@antmerlino antmerlino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Tested and confirmed this fixes the issue I was seeing on the H7.

@antmerlino
antmerlino merged commit 17b7863 into apache:master May 7, 2021
@antmerlino antmerlino added the backport/10.1 Consider backporting to the releases/10.1 branch. label May 7, 2021
@davids5

davids5 commented May 7, 2021

Copy link
Copy Markdown
Contributor Author

@jerpelea - This is critical for STM32 if CONFIG_MMCSD_MULTIBLOCK_DISABLE=y is not lit (using MULTIBLOCK) the driver will fail without this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/10.1 Consider backporting to the releases/10.1 branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants