I’m trying to send basic UDP packets to my PC with the zero-copy sendto(…) method on the STM32F4. I’m using the example given on the FreeRTOS website. I noticed that everytime I run the sendto function xTXDescriptorSemaphore will be taken but are never released. While examening the code I found the only place that releases xTXDescriptorSemaphore is in the vClearTXbuffers, which is never called because
( ulISREvents & EMAC_IF_TX_EVENT ) != 0 is never true because tx interrupts are not implemented.
/* Bit map of outstanding ETH interrupt events for processing. Currently only
the Rx interrupt is handled, although code is included for other events to
enable future expansion. */
If TX interrupt is for future expansion, how should I release xTXDescriptorSemaphore? It feels wrong to modify STM32Fxx/Networkinterface.c directly
xTXDescriptorSemaphore is a so-called counting semaphore. The count represents the number of descriptors that are active in transmission.
Normally, when the transfer is ready,
HAL_ETH_IRQHandler() is triggered, which in turn calls
HAL_ETH_TxCpltCallback(), an application hook.
Now I am curious why in your case, the
ETH_DMA_FLAG_T interrupt doesn’t seem to occur? Or does it occur and is the call-back not called?
Does any of the error flags in
HAL_ETH_ErrorCallback occur? Is
Is there a DMA error?
If TX interrupt is for future expansion, how should
I release xTXDescriptorSemaphore?
I am sorry about the confusion: the comment should be updated.
PS. the latest driver for STM32Fx can be found on github here.
There is sometimes confusion about the ST HAL sources files: the FreeRTOS drivers provides its own version of
stm32fxx_hal_eth.h. They should be used.
Thank you for your quick response.
If TX interrupt is for future expansion, how should I release xTXDescriptorSemaphore?
Sorry, I mean that the semaphore is only released when ulISREvents contains the EMAC_IF_TX_EVENT flag. But ulISREvents description in the code says that they only implemented RX interrupts. I never saw this being addressed on their website, this gave me the impression that I should not have to free the semaphores myself. I have looked into the things you told me. The
ETH_IRQHandler() is never called. The ETH_DMASR (0x006984c5) says the transmission is finished, but that the Transmit buffer is unavailable or has an underflow. NIS and NISE are high, so I expected an interrupt to happen.
ETH_DMASR (0x006984c5): TS: 1 , TBUS: 1 ETS: 1 NIS: 1, TPS: 110.
ETH_DMAIER (0x000163fb): TIE: 1, TPSIE: 1, TUIE 1, NIS:1.
I fixed the issue. The NVIC ISER register was not correctly configured for ethernet interrupts. The TX semaphore is now freed as expected. Thanks for your help htibosch!
Very good, and thanks for reporting back. It may help other users.