fsl_enet.c ENET_CommonFrame0IRQHandler() bug?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

fsl_enet.c ENET_CommonFrame0IRQHandler() bug?

Jump to solution
1,196 Views
mjbcswitzerland
Specialist V

Hi

I am testing the fsl_enet.c driver on the i.MX RT 1021 and have a crash in a normal use situation which looks like a bug rather than by design.

1. The common interrupt handler ENET_CommonFrame0IRQHandler() is called whenever there is an Ethernet interrupt, which can be due to various reasons - such as frame reception, frame transmission, errors, or time stamps.

2. For basic operation there is only the need to handle reception interrupts, whereby this is performed by enabling the particular interrupt flag(s) which enables this interrupt source and automatically assigns a handling routine (ENET_ReceiveIRQHandler() in the case of frame reception).

Eg.

config.interrupt = ENET_EIR_RXF_MASK; // we hand to use reception frame interrupts
ENET_Init(ENET, &g_handle, &config, &buffConfig[0], macAddr, sysClock); // perform initialisation

3. The problem is that the common interrupt handler handles any, and all, flags set in the Ethernet interrupt register, irrespective of whether they are actually enabled or registered.

void ENET_CommonFrame0IRQHandler(ENET_Type *base)
{
uint32_t event = base->EIR;
uint32_t instance = ENET_GetInstance(base);

if (0U != (event & ((uint32_t)kENET_TxBufferInterrupt | (uint32_t)kENET_TxFrameInterrupt)))
{
#if FSL_FEATURE_ENET_QUEUE > 1
s_enetTxIsr(base, s_ENETHandle[instance], 0);
#else
s_enetTxIsr(base, s_ENETHandle[instance]);
#endif /* FSL_FEATURE_ENET_QUEUE > 1 */
}

if (0U != (event & ((uint32_t)kENET_RxBufferInterrupt | (uint32_t)kENET_RxFrameInterrupt)))
{
#if FSL_FEATURE_ENET_QUEUE > 1
s_enetRxIsr(base, s_ENETHandle[instance], 0);
#else
s_enetRxIsr(base, s_ENETHandle[instance]);
#endif /* FSL_FEATURE_ENET_QUEUE > 1 */
}

 

I the case in question s_enetRxIsr() is called when there is a reception interrupt, which is correct and works as long as no transmission was performed beforehand.

 

In the case of a reception following a transmission (which has set kENET_TxFrameInterrupt in the interrupt event register but doesn't need or use a handler) the code calls s_enetTxIsr, which is a NUL pointer and so immediate fails.

The same is the case if a time stamp event were to occur (without interrupt handling enabled) or various misc. error interrupts.

 

This suggests that one has to enable all possible interrupts so that it won't fail, even when they don't need to be handled - or none. Trying to just handle specific ones will fail.

 

A solution is to change

uint32_t event = base->EIR;

to

uint32_t event = (base->EIR & base->EIMR); // enabled interrupt events to be handled

at the start of the common interrupt handler so that only actually enabled interrupt sources are handled.

 

Are fsl_XXX.c drivers still used productively or have they been replaced by new ones nowadays?

Regards

Mark

 

 

 

 

0 Kudos
Reply
1 Solution
1,174 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Mark, 

Thanks for reporting this! I already passed your feedback to the SDK team. Regarding your question, fsl drivers are still used productively. 

Regards,
Victor 

View solution in original post

1 Reply
1,175 Views
victorjimenez
NXP TechSupport
NXP TechSupport

Hi Mark, 

Thanks for reporting this! I already passed your feedback to the SDK team. Regarding your question, fsl drivers are still used productively. 

Regards,
Victor