[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-users] Fail to get netconn lwip1.4.1+FreeRTOS+TM4C1294

From: Jin Won Seo
Subject: [lwip-users] Fail to get netconn lwip1.4.1+FreeRTOS+TM4C1294
Date: Thu, 26 Feb 2015 10:37:45 -0800



I am using tm4c1294+lwip1.4.1+FreeRTOS.

As netconn_alloc() is called for socket communication, it allocates an unused semaphore. the number of semaphore is defined as SYS_SEM_MAX, so it can not be over SYS_SEM_MAX. However, as semaphores are allocated continuously it reaches SYS_SEM_MAX and stop working since I gues sys_sem_free() does not deallocate it properly

Here is function that creates a semaphore implemented in sys_arch.c

sys_sem_new(sys_sem_t *sem, u8_t count)

  void *temp;
  u32_t i;

  /* Find a semaphore that is not in use. */
  for(i = 0; i < SYS_SEM_MAX; i++) {
    if(sems[i].queue == 0) {

if(i == SYS_SEM_MAX) {
#endif /* SYS_STATS */
    return ERR_MEM;

  /* Create a single-entry queue to act as a semaphore. */
  sem->queue = xQueueCreate(1, sizeof(void *));
  if(sem->queue == NULL) {
#endif /* RTOS_FREERTOS */

#endif /* SYS_STATS */
    return ERR_MEM;

 /* Acquired the semaphore if necessary. */
  if(count == 0) {
    temp = 0;
    xQueueSend(sem->queue, &temp, 0);

 /* Update the semaphore statistics. */
  if(lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) {
    lwip_stats.sys.sem.max = lwip_stats.sys.sem.used;
#endif /* SYS_STATS */

  /* Save the queue handle. */
  sems[i].queue = sem->queue;

  /* Return this semaphore. */
  return (ERR_OK);
Here is another function that frees semaphore implemented in sys_arch.c

void sys_sem_free(sys_sem_t *sem) { /* Clear the queue handle. */ sem->queue = 0; /* Delete Sem , By Jin */ vQueueDelete(sem->queue); /* Update the semaphore statistics. */ #if SYS_STATS STATS_DEC(sys.sem.used); #endif /* SYS_STATS */ }

Whenever netconn_free() is called sys_sem_free() deallocates the semaphore, but it does not free the semaphore assigned in sem[] array.

I added vQueueDelete(sem->queue); that was suggested by someone, but still all same.

Not only functions creates/frees semaphore but also functions handling mbox are same as functions above, so functions handling mbox could be wrong as well.

Someone already reported this issue to TI, but it seems they have not solved the problems yet.

Therefore, I may need to implement my own functions handling semaphore/mbox in sys_arch.c, but I don't have any clues so far.

Can anyone give me any ideas? or anything?

Thanks, Jin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]