I've got a STM32F769I Discovery board here, and wanted to get the SDCard going.
I'm using ChibiOS_17.6.3
I've started with the RT-STM32F746G-DISCOVERY-LWIP-FATFS-USB demo, and deleted any of the LWIP/http related stuff. I just figured it shares the most in common with my board. I then switched to use the STM32F769 board file and linker script.
The first thing I noted is that on this board, the MicroSD connector is electrically connected to SDMMC2.
I augmented mcuconf.h to the following:
Code: Select all
#define STM32_SDC_USE_SDMMC1 FALSE
#define STM32_SDC_USE_SDMMC1 TRUE
....
#define STM32_SDC_SDMMC2_DMA_STREAM STM32_DMA_STREAM_ID(2, 5) // I also tried STREAM_ID(2, 0)
#define STM32_SDC_SDMMC2_DMA_PRIORITY 3
#define STM32_SDC_SDMMC2_IRQ_PRIORITY 9
This also required making a change in the fatfs_bindings, since by default it is hardcoded to only use SDCD1. I just made a copy, changed from SDCD1->SDCD2 and pointed my project at that.
Finally, in order to link, I had to add to os/hal/ports/STM32/STM32F7xx/stm32_rcc.h
Code: Select all
#define rccEnableSDMMC2(lp) rccEnableAPB2(RCC_APB2ENR_SDMMC2EN, lp)
When I step into sdcConnect(), it gets to the point where it "Switches to high speed.". At that point it gets stuck waiting for DMA with the following backtrace:
Code: Select all
#0 0x0020ccd4 in sdc_lld_wait_transaction_end.lto_priv.263 (sdcp=0x20000c08 <SD
CD2>, n=1, resp=0x200006c4) at ../os/hal/ports/STM32/LLD/SDMMCv1/hal_sdc_lld.c:2
63
#1 0x0020aaf8 in sdc_lld_read_special (sdcp=0x20000c08 <SDCD2>, buf=0x200006d8
"UUUU\354\006", bytes=64, cmd=6 '\006', arg=0) at ../os/hal/ports/STM32/LLD/SDMM
Cv1/hal_sdc_lld.c:761
#2 0x0020fa70 in sdc_detect_bus_clk (sdcp=0x20000c08 <SDCD2>, clk=0x2000076f) a
t ../os/hal/src/hal_sdc.c:334
#3 0x0020fb88 in detect_bus_clk (sdcp=0x20000c08 <SDCD2>, clk=0x2000076f) at ..
/os/hal/src/hal_sdc.c:411
#4 0x0020fe3c in sdcConnect (sdcp=0x20000c08 <SDCD2>) at ../os/hal/src/hal_sdc.
c:680
#5 0x002011ec in InsertHandler.lto_priv.474 (id=0) at main.c:192
#6 0x0021357c in chEvtDispatch (handlers=0x80173b4 <evhndl.9927.lto_priv>, even
ts=0) at ../os/rt/src/chevents.c:358
#7 0x002013ca in main () at main.c:317
I'm guessing I'm blazing a new trail here, but am at my limit as far as I can go without help.