drivers: memc: stm32_sdram: SDRAM content is lost when the SoC enters Stop
Describe the bug
memc_stm32_sdram.c has no PM support, so with CONFIG_PM=y an STM32F4 enters Stop without putting the SDRAM into self-refresh. Stop stops all clocks in the 1.2 V domain (RM0090 Rev 22 section 5.3.5), including the FMC's, so the SDRAM is no longer refreshed and starts losing data within 10 s.
Measured on an STM32F429I-DISC1: fill all 8 MB, stay idle (one Stop entry), then compare. Bad 32-bit words over three rounds:
| Idle | PM off | CONFIG_PM=y |
CONFIG_PM=y, self-refresh around Stop |
|---|---|---|---|
| 1 s | 0 | 0 | 0 |
| 10 s | 0 | 24 to 40 | 0 |
| 60 s | 0 | 61,692 to 69,114 | 0 |
The LCD frame buffer of this board is in SDRAM; a display test saw it change after one 10 s Stop.
Regression
- This is a regression.
Steps to reproduce
- Build an app for
stm32f429i_disc1withCONFIG_PM=ythat fills the SDRAM (0xD0000000, 8 MB) with a known pattern, sleeps 10 s (k_msleep(), one Stop entry), then checks the pattern. - Clear DBGMCU_CR.DBG_STOP before the test. OpenOCD sets it when it connects and only a power cycle clears it (RM0090 Rev 22 section 38.16.3); while it is set, HCLK keeps running in Stop, the FMC keeps refreshing and the test passes.
- Run it: words have changed after the sleep. With PM off none have.
Relevant log output
sdram-pm: run=2 set=1 idle_ms=10000 up_ms=10000 awake_ms=0.1 stop_in=1 stop_out=1 slow_exit=0 sr_fail=0 bad_words=40 bad_bits=40 fell=26 rose=14 first=0xd000421c
sdram-pm: run=3 set=1 idle_ms=60000 up_ms=60000 awake_ms=0.2 stop_in=1 stop_out=1 slow_exit=0 sr_fail=0 bad_words=69114 bad_bits=70322 fell=34950 rose=35372 first=0xd0000018Impact
Functional Limitation – Some features not working as expected, but system usable.
Environment
- OS: Ubuntu 24.04 (VM on macOS 26.6)
- Toolchain: Zephyr SDK 1.0.1
- Commit: 55303e23f59
- Board: STM32F429I-DISC1 (MB1075 rev E, IS42S16400J)
Additional Context
The self-refresh column is a prototype that follows ST's STM32CubeF4 FMC_SDRAM_LowPower example for this board: self-refresh before Stop, normal mode after wake-up. Would a PM action in the driver or a pm_notifier be preferred?
Source: zephyrproject-rtos/zephyr