cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F427VI = Assertion "sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty"

As.51
Associate III

Hi all,

I am using a STM32F427VI MCU.

I developed an application using LWIP library.

I am trying to run an application that I finished to develop and test in three boards.

This application works as expected in all of them. When I burn the application to a fourth board I can see that the app stopts in this function:

void HandleEthernet()
{
	/* Read a received packet from the Ethernet buffers and send it 
	    to the lwIP for handling */
	ethernetif_input(&gnetif);
	
					/* Handle timeouts */
	sys_check_timeouts();
	
}

I got this errors in the debug console:

Assertion "sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty" failed at line 212 in C:/Users/alex_s/STM32Cube/Repository/STM32Cube_FW_F4_V1.24.1/Middlewares/Third_Party/LwIP/src/core/timeouts.c

Assertion "pbuf_alloc: pbuf p->payload properly aligned" failed at line 297 in C:/Users/alex_s/STM32Cube/Repository/STM32Cube_FW_F4_V1.24.1/Middlewares/Third_Party/LwIP/src/core/pbuf.c

Assertion "check p->payload + p->len does not overflow pbuf" failed at line 304 in C:/Users/alex_s/STM32Cube/Repository/STM32Cube_FW_F4_V1.24.1/Middlewares/Third_Party/LwIP/src/core/pbuf.c

The problems is here. I think that somehow the application can't allocate the memory

sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)
#endif /* LWIP_DEBUG_TIMERNAMES */
{
  struct sys_timeo *timeout, *t;
  u32_t now, diff;
 
  timeout = (struct sys_timeo *)memp_malloc(MEMP_SYS_TIMEOUT);
  if (timeout == NULL) {
    LWIP_ASSERT("sys_timeout: timeout != NULL, pool MEMP_SYS_TIMEOUT is empty", timeout != NULL);
    return;
  }

 LWIPOPTS.h configuration

#ifndef __LWIPOPTS__H__
#define __LWIPOPTS__H__
 
#include "main.h"
 
 
 
#ifdef __cplusplus
extern "C" {
#endif
 
 
#define LWIP_TIMEVAL_PRIVATE 0
 
#define SYS_LIGHTWEIGHT_PROT    0
 
 
#define NO_SYS                  1
	
 
#define MEM_ALIGNMENT           4
 
 
#define MEM_SIZE      (16*1024)
 
 
#define MEMP_NUM_PBUF           16
/* MEMP_NUM_UDP_PCB: the number of UDP protocol control blocks. One per active UDP "connection". */
#define MEMP_NUM_UDP_PCB        6
/* MEMP_NUM_TCP_PCB: the number of simulatenously active TCP connections. */
#define MEMP_NUM_TCP_PCB        10
/* MEMP_NUM_TCP_PCB_LISTEN: the number of listening TCP connections. */
#define MEMP_NUM_TCP_PCB_LISTEN 6
/* MEMP_NUM_TCP_SEG: the number of simultaneously queued TCP segments. */
#define MEMP_NUM_TCP_SEG        TCP_SND_QUEUELEN
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */
#define MEMP_NUM_SYS_TIMEOUT    11
 
/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#define PBUF_POOL_SIZE          16
 
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#define PBUF_POOL_BUFSIZE       2500
 
/* ---------- TCP options ---------- */
#define LWIP_TCP                1
#define TCP_TTL                 255
 
/* Controls if TCP should queue segments that arrive out of
order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ         0
 
/* TCP Maximum segment size. */
#define TCP_MSS                 (2500 - 40)	  /* TCP_MSS = (Ethernet MTU - IP header size - TCP header size) */
 
/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF (16*TCP_MSS)
 
/*  TCP_SND_QUEUELEN: TCP sender buffer space (pbufs). This must be at least
as much as (2 * TCP_SND_BUF/TCP_MSS) for things to work. */
#define TCP_SND_QUEUELEN        (8* TCP_SND_BUF/TCP_MSS)
 
/* TCP receive window. */
#define TCP_WND     (8*TCP_MSS)
	
/* ---------- ICMP options ---------- */
#define LWIP_ICMP                       1
 
/* ---------- DNS options ---------- */
#define LWIP_DNS                       1
	
 
#define LWIP_DHCP               1
 
/* ---------- UDP options ---------- */
#define LWIP_UDP                1
#define UDP_TTL                 255
 
/* ---------- Statistics options ---------- */
#define LWIP_STATS 0
#define LWIP_PROVIDE_ERRNO 1
	
 
#define LWIP_NETIF_LINK_CALLBACK        1
#define LWIP_NETIF_STATUS_CALLBACK		1
	
 
#if (NO_SYS==0)
#define LWIP_NETCONN                    1
#else
#define LWIP_NETCONN                    0
#endif
 
#define LWIP_SOCKET                     0
	
#ifdef __cplusplus
}
#endif
#endif /*__LWIPOPTS__H__ */
 

Any idea how can I avoid this? and why this is happening only in one MCU?

1 REPLY 1
ktrofimo
Senior III

Default number of simultaneously active timeouts is defined in opt.h as:

#define LWIP_NUM_SYS_TIMEOUT_INTERNAL  (LWIP_TCP + IP_REASSEMBLY + LWIP_ARP + (2*LWIP_DHCP) + LWIP_AUTOIP + LWIP_IGMP + LWIP_DNS + PPP_NUM_TIMEOUTS + (LWIP_IPV6 * (1 + LWIP_IPV6_REASS + LWIP_IPV6_MLD)))

For my SNTP client I ran out of available timeouts and was able to fix it adding +1 to this macro.

Why one of your MCU acts differently - sorry couldn't help you