Skip to content

Commit e578690

Browse files
committed
Fix semaphore usage on lpc1768 emac
The semaphore xTXDCountSem had the count to match the number of resources available, but was being used as a binary semaphore in a loop to listen for events. This patch updates the logic to make use of the resource count. With RTX5 the OS traps with an error if the a semaphore is released more times than its count with an error similar to "Semaphore 10000e6c error -17". Because xTXDCountSem is being used as a binary semaphore it triggered this trap. With this patch the semaphore is no longer used as a binary semaphore and no longer traps.
1 parent a41e08c commit e578690

File tree

1 file changed

+4
-1
lines changed
  • features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NXP

1 file changed

+4
-1
lines changed

features/FEATURE_LWIP/lwip-interface/lwip-eth/arch/TARGET_NXP/lpc17_emac.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,13 @@ static err_t lpc_low_level_output(struct netif *netif, struct pbuf *p)
604604

605605
/* Wait until enough descriptors are available for the transfer. */
606606
/* THIS WILL BLOCK UNTIL THERE ARE ENOUGH DESCRIPTORS AVAILABLE */
607-
while (dn > lpc_tx_ready(netif))
608607
#if NO_SYS == 0
608+
for (idx = 0; idx < dn; idx++) {
609609
osSemaphoreAcquire(lpc_enetif->xTXDCountSem.id, osWaitForever);
610+
}
611+
MBED_ASSERT(dn <= lpc_tx_ready(netif));
610612
#else
613+
while (dn > lpc_tx_ready(netif))
611614
osDelay(1);
612615
#endif
613616

0 commit comments

Comments
 (0)