Hello,
I am working with Ethernet on an S32K344, using the S32K344 Mini EVB as the base board. The project uses the RTD Eth_43_GMAC driver, without lwIP. The application is based on the NXP ethernet_no_lwip example, but adapted to our board
The hardware uses a Microchip/Micrel KSZ8091RND PHY in RMII mode. The PHY receives a 50 MHz clock on the XI pin, according to our schematic. In the KSZ8091RND PHY Control 2 register, bit 7, RMII Reference Clock Select, is 0. We understand this to be consistent with the RND mode using a 50 MHz clock on XI.
The interface between the MCU and the PHY is configured as RMII, 100 Mbps, full-duplex.
In the .mex file, the GMAC/EMAC pins are configured as follows:
PTD16, pin 34: RMII_MDIO, emac_mii_rmii_mdio
PTD17, pin 31: RMII_MDC, emac_mii_rmii_mdc
PTB5, pin 47: RMII_TX0, emac_mii_rmii_txd0
PTB4, pin 48: RMII_TX1, emac_mii_rmii_txd1
PTE9, pin 36: RMII_TX_EN, emac_mii_rmii_tx_en
PTC0, pin 62: RMII_TX_CLK, emac_mii_rmii_tx_clk
PTD9, pin 63: RMII_RX0, emac_mii_rmii_rxd0
PTD8, pin 64: RMII_RX1, emac_mii_rmii_rxd1
PTC15, pin 68: RMII_RX_DV, emac_mii_rmii_rx_dv
PTC16, pin 66: RMII_RX_ER, emac_mii_rmii_rx_er
PTC1, pin 61: RMII_RX_CLK, emac_mii_rx_clk
PTE21, pin 153: ENET_RESET
Relevant Ethernet configuration in the .mex file:
EthCtrlMacLayerType = ETH_MAC_LAYER_TYPE_XMII
EthCtrlMacLayerSubType = REDUCED
EthCtrlMacLayerSpeed = ETH_MAC_LAYER_SPEED_100M
EthDuplexMode = ETH_FULL_DUPLEX
EthCtrlEnableRxInterrupt = false
EthCtrlEnableTxInterrupt = false
Relevant GMAC configuration generated by RTD:
miiMode = GMAC_RMII_MODE
speed = GMAC_SPEED_100M
duplex = GMAC_FULL_DUPLEX
We also checked that the driver selects the RMII interface before resetting the controller. In Eth_43_GMAC_Ipw.c, when the mode is GMAC_RMII_MODE, it writes DCMRWF1 MAC_CONF_SEL with value 2U.
So, based on the generated code, MAC_CONF_SEL appears to be configured for RMII.
Regarding clocks, the .mex file shows:
external_clocks.emac_mii_rmii_tx.outFreq = 50 MHz
EMAC_MII_RMII_TX.outFreq = 50 MHz
EMAC0_RX_CLK.outFreq = 25 MHz
EMAC0_TX_CLK.outFreq = 25 MHz
EMAC0_TS_CLK.outFreq = 50 MHz
The EMAC clock muxes use EMAC_MII_RMII_TX_CLK as their source:
McuCgm0ClockMux7_Source = EMAC_MII_RMII_TX_CLK
McuCgm0ClockMux8_Source = EMAC_MII_RMII_TX_CLK
McuCgm0ClockMux9_Source = EMAC_MII_RMII_TX_CLK
When comparing this with NXP example .mex files, we saw that they also show EMAC_MII_RMII_TX at 50 MHz and EMAC0_RX_CLK / EMAC0_TX_CLK at 25 MHz, so we assume this may be normal in the tool, but we would like to confirm.
The application transmits and receives Ethernet frames directly through Eth_43_GMAC, without lwIP.
For TX, we use this sequence:
Eth_43_GMAC_ProvideTxBuffer
Eth_43_GMAC_Transmit
Eth_43_GMAC_TxConfirmation
For RX, we use polling, since RX/TX interrupts are disabled:
ETH_43_GMAC_RX_IRQ_ENABLED = STD_OFF
ETH_43_GMAC_TX_IRQ_ENABLED = STD_OFF
The RX code repeatedly calls Eth_43_GMAC_Receive with CtrlIdx, FifoIdx, and receiveStatus.
We also monitor EthIf_RxIndications[0], because the driver only calls EthIf_RxIndication when the received frame has no error.
The observed behavior is:
TX is confirmed successfully several times.
On the other side, some frames appear to be received.
RX on the S32K344 receives something, but then all frames are discarded by the driver.
receiveStatus may indicate that a frame was received.
However, EthIf_RxIndication is not called because the driver detects an error in the frame.
When inspecting Eth_43_GMAC_Ipw_axRxFrameInfo[0][0].ErrMask, the observed value is:
ErrMask = 0x01080000
According to the driver header, this corresponds to:
GMAC_RX_ERR_CRC_ERROR = 0x01000000
GMAC_RX_ERR_DRIBBLE_ERROR = 0x00080000
So the frame reaches the GMAC, but it is marked with CRC and dribble errors.
The main question is: considering that the GMAC is configured as RMII 100M full-duplex, the KSZ8091RND PHY receives a 50 MHz clock on XI, and the driver selects MAC_CONF_SEL value 2U, what could cause simultaneous CRC and dribble errors on RX?
We would especially like to confirm:
For S32K344 plus GMAC plus RMII, is it expected that the .mex file shows EMAC_MII_RMII_TX = 50 MHz, but EMAC0_RX_CLK and EMAC0_TX_CLK as 25 MHz?
In RMII mode on S32K344, is it expected to configure both emac_mii_rmii_tx_clk on PTC0 and emac_mii_rx_clk on PTC1, or should one of these signals not be used or routed in this mode?
Is any additional configuration required in DCM_GPR, the clock tree, or pin mux for RMII besides MAC_CONF_SEL value 2U?
Is the KSZ8091RND with bit 7 of PHY Control 2 set to 0 and an external 50 MHz clock on XI compatible with this GMAC configuration?
In cases of CRC_ERROR plus DRIBBLE_ERROR on RX, which RMII signals would you recommend checking first with an oscilloscope or logic analyzer? REF_CLK, CRS_DV, RXD0, RXD1, RX_ER?
Is there any official NXP example for S32K344 using a KSZ8091RND PHY in RMII mode without lwIP?
Summary: the link comes up, TX is confirmed, and RX detects frames, but the frames are discarded due to CRC_ERROR plus DRIBBLE_ERROR. We are trying to determine whether this points to an RMII clock issue, pin mux/physical signal issue, or some additional GMAC/RTD configuration requirement.
Thank you in advance for your support and guidance.