Page 1 of 1
STM32H743 FMC driver porting from F4/F7
Posted: Wed Apr 02, 2025 7:58 pm
by dynfer
Hello,
I've got an problem while using the FMC driver (especially SDRAM). I've attempted to port the driver from ChibiOS-Contrib from F7 to H7. Everything seems to work however I've got a problem that no matter at all i'm not getting a clock output on the FMC_SDCLK pin with AF12 (STM32H743iit6 PG8 in my case). Also I've noticed the FMC_SDSR status bit is completely missing from the H7 and I'm trying to figure a way out without it on the H7.
Re: STM32H743 FMC driver porting from F4/F7
Posted: Thu Apr 03, 2025 10:09 pm
by dynfer
Managed to fix the clock. Seems the FMC is working correctly all registers written correctly. However when trying to write data to the SDRAM im hardfaulting with an imprecise hardfault. Ive double checked all clock settings and the sdram initialization and everything seems to be correct.
The sdram is connected to Bank1 and mapped to 0xC0000000 in my linker script. Any tips how to troubleshoot this?
Re: STM32H743 FMC driver porting from F4/F7
Posted: Fri Apr 04, 2025 5:34 am
by Giovanni
Hi,
I have never tried to write a driver for FMC so cannot help much, you best option is to look at ST initialization code for your driver and check all steps required.
Giovanni
Re: STM32H743 FMC driver porting from F4/F7
Posted: Sat Apr 05, 2025 12:00 am
by dynfer
Problem solved.
The ChibiOS-Contrib driver was missing a bit in the BTCR[0] register that enables the FMC.
Line in question
FMC_Bank1_R->BTCR[0] |= FMC_BCR1_FMCEN;Code: Select all
void sdram_lld_start(SDRAMDriver *sdramp, const SDRAMConfig *cfgp)
{
sdramp->sdram->SDCR1 = cfgp->sdcr;
sdramp->sdram->SDTR1 = cfgp->sdtr;
sdramp->sdram->SDCR2 = cfgp->sdcr;
sdramp->sdram->SDTR2 = cfgp->sdtr;
FMC_Bank1_R->BTCR[0] |= FMC_BCR1_FMCEN;
sdram_lld_init_sequence(cfgp);
}
Besides that the driver required minimal adaption for H7 like missing defines for the H7.
Re: STM32H743 FMC driver porting from F4/F7
Posted: Sat Apr 05, 2025 3:57 am
by Giovanni
Hi,
If you want to update a community-contributed driver you can go ask in the ChibiOS discord server, there is a dedicated channel there, or make a pull request on the github project.
Giovanni