@@ -46,6 +46,9 @@ static sys_mutex_t tx_lock_mutex;
46
46
/* function */
47
47
static void _eth_arch_rx_task (void * arg );
48
48
static void _eth_arch_phy_task (void * arg );
49
+ #if defined (TARGET_NUCLEO_F767ZI )
50
+ static void _rmii_watchdog (void * arg );
51
+ #endif
49
52
50
53
#if LWIP_IPV4
51
54
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)
372
375
}
373
376
}
374
377
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
+
375
407
/**
376
408
* This function is the ethernet IPv4 packet send function. It calls
377
409
* etharp_output after checking link status.
@@ -465,6 +497,10 @@ err_t eth_arch_enetif_init(struct netif *netif)
465
497
/* initialize the hardware */
466
498
_eth_arch_low_level_init (netif );
467
499
500
+ #if defined (TARGET_NUCLEO_F767ZI )
501
+ sys_thread_new ("stm32_rmii_watchdog" , _rmii_watchdog , netif , DEFAULT_THREAD_STACKSIZE , osPriorityLow );
502
+ #endif
503
+
468
504
return ERR_OK ;
469
505
}
470
506
0 commit comments