Skip to content

Commit 095f4db

Browse files
committed
stm32/eth: Restore CLK_SLEEP_ENABLE for packet reception during CPU sleep.
The CLK_SLEEP_ENABLE calls were removed during the restructure (commit 90297bc), leaving the driver dependent on the HAL default state. While the default enables clocks during sleep, explicit configuration is more robust and documents the requirement. ETH clocks must remain enabled during CPU sleep (WFI) to allow the peripheral to receive packets and generate interrupts, which is necessary for DHCP and other network traffic. Tested on NUCLEO_F429ZI: DHCP acquisition successful. Signed-off-by: Andrew Leech <[email protected]>
1 parent b44cf0e commit 095f4db

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ports/stm32/eth.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,26 @@ static int eth_mac_init(eth_t *self) {
277277
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL;
278278
#endif
279279

280+
// Release ETH peripheral from reset and enable clocks during CPU sleep.
281+
// Note: CLK_SLEEP_ENABLE means clocks stay ON during sleep (not OFF).
282+
// Clocks must continue during sleep to allow the ETH peripheral to receive
283+
// packets and generate interrupts when the CPU enters sleep mode (WFI),
284+
// which is necessary for DHCP and other network traffic.
280285
#if defined(STM32H5)
281286
__HAL_RCC_ETH_RELEASE_RESET();
287+
__HAL_RCC_ETH_CLK_SLEEP_ENABLE();
288+
__HAL_RCC_ETHTX_CLK_SLEEP_ENABLE();
289+
__HAL_RCC_ETHRX_CLK_SLEEP_ENABLE();
282290
#elif defined(STM32H7)
283291
__HAL_RCC_ETH1MAC_RELEASE_RESET();
292+
__HAL_RCC_ETH1MAC_CLK_SLEEP_ENABLE();
293+
__HAL_RCC_ETH1TX_CLK_SLEEP_ENABLE();
294+
__HAL_RCC_ETH1RX_CLK_SLEEP_ENABLE();
284295
#else
285296
__HAL_RCC_ETHMAC_RELEASE_RESET();
297+
__HAL_RCC_ETHMAC_CLK_SLEEP_ENABLE();
298+
__HAL_RCC_ETHMACTX_CLK_SLEEP_ENABLE();
299+
__HAL_RCC_ETHMACRX_CLK_SLEEP_ENABLE();
286300
#endif
287301

288302
// Do a soft reset of the MAC core

0 commit comments

Comments
 (0)