STMicroelectronics / STM32CubeF4

STM32Cube MCU Full Package for the STM32F4 series - (HAL + LL Drivers, CMSIS Core, CMSIS Device, MW libraries plus a set of Projects running on all boards provided by ST (Nucleo, Evaluation and Discovery Kits))
Other
827 stars 409 forks source link

[ETH] TX/RX Semaphores #127

Closed DedkovArtem closed 1 year ago

DedkovArtem commented 2 years ago

Describe the set-up

Describe the bug The first packet sent is released without waiting for the end of sending.

How To Reproduce In the ethernetif.c file in the procedure _static err_t low_leveloutput(struct netif netif, struct pbuf p) cycle while(osSemaphoreAcquire(TxPktSemaphore, TIME_WAITING_FOR_INPUT)!=osOK); passes instantly, because semaphore TxPktSemaphore created with initialization value = 1, and there is no interrupt waiting on sending the first packet

Additional context It seems to me more correct when creating a semaphore in a procedure _static void low_levelinit(struct netif *netif) create a semaphore with initialization value = 0 TxPktSemaphore = osSemaphoreNew(1, 0, NULL);

The RxPktSemaphore semaphore has a similar problem. The semaphore must be released by the received frame, not by the procedure that creates the semaphore. Respectively, it is more correct to create a semaphore for receiving, with initialization value = 0 RxPktSemaphore = osSemaphoreNew(1, 0, NULL);

ASELSTM commented 2 years ago

ST Internal Reference: 128000

ASELSTM commented 1 year ago

Hi @DedkovArtem,

There is actually no use of the osSemaphoreAcquire() within the function err_t low_level_output() as part of the ethernetif.c, the below instruction is rather used:

https://github.com/STMicroelectronics/STM32CubeF4/blob/52757b5e33259a088509a777a9e3a5b971194c7d/Projects/STM32F429ZI-Nucleo/Applications/LwIP/LwIP_HTTP_Server_Netconn_RTOS/Src/ethernetif.c#L294

Moreover, TxPktSemaphore and RxPktSemaphore are by default set to 0, we have double checked and low_level_output() and low_level_input() are not passing instantly.

I guess you are not using the newest version of the STM32CubeF4. Would you please try to the latest one and check if you are still having the same issue. Meanwhile, please allow me to close this thread. You may reopen it at anytime if you have any details to share with us in order to help you to solve the issue. Thank you for your comprehension.

With regards,