Skip to content

Commit c8edd2e

Browse files
Merge pull request #5411 from LMESTM/rmii_f767
STM32: Ethernet: Workaround for STM32_F767 revA
2 parents a9b594b + 96b4c36 commit c8edd2e

File tree

1 file changed

+36
-0
lines changed
  • features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM

1 file changed

+36
-0
lines changed

features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_STM/stm32xx_emac.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ static sys_mutex_t tx_lock_mutex;
4646
/* function */
4747
static void _eth_arch_rx_task(void *arg);
4848
static void _eth_arch_phy_task(void *arg);
49+
#if defined (TARGET_NUCLEO_F767ZI)
50+
static void _rmii_watchdog(void *arg);
51+
#endif
4952

5053
#if LWIP_IPV4
5154
static err_t _eth_arch_netif_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
@@ -372,6 +375,35 @@ static void _eth_arch_phy_task(void *arg)
372375
}
373376
}
374377

378+
#if defined (TARGET_NUCLEO_F767ZI)
379+
/**
380+
* workaround for the ETH RMII bug in STM32F769 Cut1.0
381+
*
382+
* \param[in] netif the lwip network interface structure
383+
*/
384+
static void _rmii_watchdog(void *arg)
385+
{
386+
while(1) {
387+
/* some good packets are received */
388+
if (EthHandle.Instance->MMCRGUFCR > 0) {
389+
/* RMII Init is OK - would need service to terminate or suspend
390+
* the thread */
391+
while(1) {
392+
/* don't do anything anymore */
393+
osDelay(0xFFFFFFFF);
394+
}
395+
} else if (EthHandle.Instance->MMCRFCECR > 10) {
396+
/* ETH received too many packets with CRC errors, resetting RMII */
397+
SYSCFG->PMC &= ~SYSCFG_PMC_MII_RMII_SEL;
398+
SYSCFG->PMC |= SYSCFG_PMC_MII_RMII_SEL;
399+
EthHandle.Instance->MMCCR |= ETH_MMCCR_CR;
400+
} else {
401+
osDelay(100);
402+
}
403+
}
404+
}
405+
#endif
406+
375407
/**
376408
* This function is the ethernet IPv4 packet send function. It calls
377409
* etharp_output after checking link status.
@@ -465,6 +497,10 @@ err_t eth_arch_enetif_init(struct netif *netif)
465497
/* initialize the hardware */
466498
_eth_arch_low_level_init(netif);
467499

500+
#if defined (TARGET_NUCLEO_F767ZI)
501+
sys_thread_new("stm32_rmii_watchdog", _rmii_watchdog, netif, DEFAULT_THREAD_STACKSIZE, osPriorityLow);
502+
#endif
503+
468504
return ERR_OK;
469505
}
470506

0 commit comments

Comments
 (0)