SDMMC2 on STM32F7 Discovery Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Thu Jan 18, 2018 6:30 pm

I snooped the registers, and noticed that the CHSEL bits in DMA_SxCR register were set to the incorrect channel 4. This is the channel used for SDMMC1.

It is because in the sdc_lld_start( SDCDriver* ) function, dmamode is always being set to SDMMC1_DMA_CHANNEL.

If I temporarily change that to be SDMMC2, the DMA works, card initializes, and I can successfully mount it.

I'm guessing the logic that sets the SDMMC1_DMA_CHANNEL and SDMMC1_DMA_PRIORITY bits will need to be broken out per-device?

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: SDMMC2 on STM32F7 Discovery

Postby Giovanni » Thu Jan 18, 2018 6:55 pm

I think you are correct, moving this topic in the bug reports forum. I will try to address both the clock settings and this issue before next release.

Giovanni

dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Thu Jan 18, 2018 7:01 pm

Thanks as always for ChibiOS! Also for a codebase that is easy to navigate/debug.

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: SDMMC2 on STM32F7 Discovery

Postby Giovanni » Fri Jan 19, 2018 11:49 am

Hi,

I fixed the SDMMC-related problems in both 17.6 and trunk (bug #912). The clock settings have only been added to trunk (bug #913) because the changes are a bit invasive, 17.6 defaults SDMMC2 clock to HSI48.

Could you give a try to trunk version?

Giovanni

dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Fri Jan 19, 2018 1:54 pm

Absolutely, but before I do, could you also please fix SDMMCx_DMA_PRIORITY the same way you split up SDMMCx_DMA_CHANNEL in os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c?

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: SDMMC2 on STM32F7 Discovery

Postby Giovanni » Fri Jan 19, 2018 2:12 pm

Missed that, done, thanks.

Giovanni

dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Fri Jan 19, 2018 2:24 pm

My pleasure, other than normal migration, my code to mount and write a file to SDCard on SDMMC2 works as advertised on the trunk with no changes to ChibiOS itself.

I tried both DMA channels supported for SDMMC2.

ch> info
Kernel: 5.0.0
Compiler: GCC 5.4.0
Architecture: ARMv7E-M
Core Variant: Cortex-M7
Port Info: Advanced kernel mode
Platform: STM32F769 Very High Performance with DSP and DP FPU
Board: STMicroelectronics STM32F769I-Discovery
Build time: Jan 19 2018 - 09:22:36

dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Fri Jan 19, 2018 2:30 pm

Well, to be fair, I still have a copied version of the fatfs_wrapper, which is currently hard-coded to SDCD1

User avatar
Giovanni
Site Admin
Posts: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: SDMMC2 on STM32F7 Discovery

Postby Giovanni » Fri Jan 19, 2018 2:42 pm

Made it configurable.

Giovanni

dflogeras
Posts: 165
Joined: Tue Sep 03, 2013 8:16 pm
Has thanked: 1 time
Been thanked: 5 times

Re: SDMMC2 on STM32F7 Discovery

Postby dflogeras » Fri Jan 19, 2018 3:22 pm

Tested overriding with #define FATFS_HAL_DEVICE SDCD2 in my halconf.h and works as expected.

Would it be possible to change GPIOG_SD_D0 and GPIOG_SD_D1 from PULLUP to FLOATING in the STM32F769-DISCOVERY board files for trunk and branch, then I promise I'll leave you alone :)

Thanks as always


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 3 guests