Page 2 of 3

Re: SDMMC2 on STM32F7 Discovery

Posted: Thu Jan 18, 2018 6:30 pm
by dflogeras
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?

Re: SDMMC2 on STM32F7 Discovery

Posted: Thu Jan 18, 2018 6:55 pm
by Giovanni
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

Re: SDMMC2 on STM32F7 Discovery

Posted: Thu Jan 18, 2018 7:01 pm
by dflogeras
Thanks as always for ChibiOS! Also for a codebase that is easy to navigate/debug.

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 11:49 am
by Giovanni
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

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 1:54 pm
by dflogeras
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?

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 2:12 pm
by Giovanni
Missed that, done, thanks.

Giovanni

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 2:24 pm
by dflogeras
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

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 2:30 pm
by dflogeras
Well, to be fair, I still have a copied version of the fatfs_wrapper, which is currently hard-coded to SDCD1

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 2:42 pm
by Giovanni
Made it configurable.

Giovanni

Re: SDMMC2 on STM32F7 Discovery

Posted: Fri Jan 19, 2018 3:22 pm
by dflogeras
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