lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] lwIP on STM32H743 - memory problems


From: Christoph Schwarz
Subject: [lwip-users] lwIP on STM32H743 - memory problems
Date: Thu, 3 Dec 2020 15:35:38 +0000

Dear all,

we are currently working with a STM32H743 controller with lwIP where an local 
webserver is running (programmed with sockets) and beside this we use mqtt for 
server communication and offer a tcp/modbus interface.

We started with the example project of ST and made a lot of more configurations 
to get it running. After some weeks of unlucky debugging we may will get here 
some helpful informations.

Currently we use no pools because with pools nothing really works. The memp 
pool has a size of 15360 bytes and we increased the MEMP_NUM_TCP_PCB to 100. 
With our webserver running a file can be downloaded where we have around 200 
segments with 5k data transferring from the webserver endpoint to the browser. 
Parallel to this an heartbeat is currently checking of the connection still is 
alive.

We found out with MEM_STATS and MEMP_STATS that after transferring some 
segments either the heap memory is full (for any reason the transferred 
segments don’t get free-ed). In parallel the TCP_PCB counter also runs up to 
MAX and with LWIP_DBG messages on we get also error messages that no more 
memory is available.

All the lwIP storages were placed in SRAM3 that it is accessible via DMA. I 
will attach the lwipopts.h file at end of this message.

I merely found documentation for this and it is hard to debug it, maybe anyone 
of you got hints how to get the application running stable and with performance.

Thanks,
Christoph













/**
  ******************************************************************************
  * File Name          : Target/lwipopts.h
  * Description        : This file overrides LwIP stack default configuration
  *                      done in opt.h file.
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under Ultimate Liberty license
  * SLA0044, the "License"; You may not use this file except in compliance with
  * the License. You may obtain a copy of the License at:
  *                             www.st.com/SLA0044
  *
  ******************************************************************************
  */

/* Define to prevent recursive inclusion 
--------------------------------------*/
#ifndef __LWIPOPTS__H__
#define __LWIPOPTS__H__

#include "main.h"

/*-----------------------------------------------------------------------------*/
/* Current version of LwIP supported by CubeMx: 2.1.2 -*/
/*-----------------------------------------------------------------------------*/

/* Within 'USER CODE' section, code will be kept by default at each generation 
*/
/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

#ifdef __cplusplus
extern "C" {
#endif

/* STM32CubeMX Specific Parameters (not defined in opt.h) 
---------------------*/
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
/*----- WITH_RTOS enabled (Since FREERTOS is set) -----*/
#define WITH_RTOS 1
/*----- WITH_MBEDTLS enabled (Since MBEDTLS and FREERTOS are set) -----*/
#define WITH_MBEDTLS 1
/*----- CHECKSUM_BY_HARDWARE enabled -----*/
#define CHECKSUM_BY_HARDWARE 1
/*-----------------------------------------------------------------------------*/

/* LwIP Stack Parameters (modified compared to initialization value in opt.h) 
-*/
/* Parameters set in STM32CubeMX LwIP Configuration GUI -*/
/*----- Value in opt.h for LWIP_DHCP: 0 -----*/
#define LWIP_DHCP 1
/*----- Default value in ETH configuration GUI in CubeMx: 1524 -----*/
#define ETH_RX_BUFFER_SIZE 1524
/*----- Default Value for LWIP_IGMP: 0 ---*/
#define LWIP_IGMP 1
/*----- Value in opt.h for LWIP_DNS: 0 -----*/
#define LWIP_DNS 1
/*----- Value in opt.h for MEM_ALIGNMENT: 1 -----*/
#define MEM_ALIGNMENT 4
/*----- Default Value for H7 devices: 0x30044000 -----*/
#define LWIP_RAM_HEAP_POINTER 0x30044000
/*----- Default Value for MEMP_NUM_SYS_TIMEOUT: 7 ---*/
#define MEMP_NUM_SYS_TIMEOUT 10
/*----- Value supported for H7 devices: 1 -----*/
#define LWIP_SUPPORT_CUSTOM_PBUF 1
/*----- Default Value for ETHARP_SUPPORT_VLAN: 0 ---*/
#define ETHARP_SUPPORT_VLAN 1
/*----- Value in opt.h for LWIP_ETHERNET: LWIP_ARP || PPPOE_SUPPORT -*/
//#define LWIP_ETHERNET 1
/*----- Value in opt.h for LWIP_DNS_SECURE: (LWIP_DNS_SECURE_RAND_XID | 
LWIP_DNS_SECURE_NO_MULTIPLE_OUTSTANDING | LWIP_DNS_SECURE_RAND_SRC_PORT) -*/
//#define LWIP_DNS_SECURE 7
/*----- Default Value for TCP_SND_QUEUELEN: 9 ---*/
//#define TCP_SND_QUEUELEN 2
/*----- Value in opt.h for TCP_SNDLOWAT: LWIP_MIN(LWIP_MAX(((TCP_SND_BUF)/2), 
(2 * TCP_MSS) + 1), (TCP_SND_BUF) - 1) -*/
//#define TCP_SNDLOWAT 1071
/*----- Value in opt.h for TCP_SNDQUEUELOWAT: LWIP_MAX(TCP_SND_QUEUELEN)/2, 5) 
-*/
//#define TCP_SNDQUEUELOWAT 5
/*----- Value in opt.h for TCP_WND_UPDATE_THRESHOLD: LWIP_MIN(TCP_WND/4, 
TCP_MSS*4) -----*/
//#define TCP_WND_UPDATE_THRESHOLD 536
/*----- Default Value for LWIP_NETIF_HOSTNAME: 0 ---*/
#define LWIP_NETIF_HOSTNAME 1
/*----- Default Value for LWIP_NETIF_STATUS_CALLBACK: 0 ---*/
#define LWIP_NETIF_STATUS_CALLBACK 1
/*----- Value in opt.h for LWIP_NETIF_LINK_CALLBACK: 0 -----*/
#define LWIP_NETIF_LINK_CALLBACK 1
/*----- Default Value for LWIP_NETIF_REMOVE_CALLBACK: 0 ---*/
#define LWIP_NETIF_REMOVE_CALLBACK 1
/*----- Default Value for LWIP_NUM_NETIF_CLIENT_DATA: 0 ---*/
#define LWIP_NUM_NETIF_CLIENT_DATA 1
/*----- Value in opt.h for TCPIP_THREAD_STACKSIZE: 0 -----*/
#define TCPIP_THREAD_STACKSIZE 1024
/*----- Value in opt.h for TCPIP_THREAD_PRIO: 1 -----*/
#define TCPIP_THREAD_PRIO osPriorityHigh
/*----- Value in opt.h for TCPIP_MBOX_SIZE: 0 -----*/
#define TCPIP_MBOX_SIZE 6
/*----- Value in opt.h for SLIPIF_THREAD_STACKSIZE: 0 -----*/
//#define SLIPIF_THREAD_STACKSIZE 4096
/*----- Value in opt.h for SLIPIF_THREAD_PRIO: 1 -----*/
//#define SLIPIF_THREAD_PRIO 3
/*----- Value in opt.h for DEFAULT_THREAD_STACKSIZE: 0 -----*/
#define DEFAULT_THREAD_STACKSIZE 500
/*----- Value in opt.h for DEFAULT_THREAD_PRIO: 1 -----*/
//#define DEFAULT_THREAD_PRIO 3
/*----- Value in opt.h for DEFAULT_UDP_RECVMBOX_SIZE: 0 -----*/
#define DEFAULT_UDP_RECVMBOX_SIZE 6
/*----- Value in opt.h for DEFAULT_TCP_RECVMBOX_SIZE: 0 -----*/
#define DEFAULT_TCP_RECVMBOX_SIZE 6
/*----- Value in opt.h for DEFAULT_ACCEPTMBOX_SIZE: 0 -----*/
#define DEFAULT_ACCEPTMBOX_SIZE 6
/*----- Default Value for LWIP_TCPIP_TIMEOUT: 0 ---*/
#define LWIP_TCPIP_TIMEOUT 1
/*----- Default Value for LWIP_NETCONN_FULLDUPLEX: 0 ---*/
//#define LWIP_NETCONN_FULLDUPLEX 1
/*----- Value in opt.h for RECV_BUFSIZE_DEFAULT: INT_MAX -----*/
//#define RECV_BUFSIZE_DEFAULT 2000000000
/*----- Value in opt.h for LWIP_USE_EXTERNAL_MBEDTLS: 0 -----*/
#define LWIP_USE_EXTERNAL_MBEDTLS 1
/*----- Default Value for LWIP_HTTPD: 0 ---*/
#define LWIP_HTTPD 1
/*----- Default Value for LWIP_HTTPD_SUPPORT_POST: 0 ---*/
#define LWIP_HTTPD_SUPPORT_POST 1
/*----- Value in opt.h for HTTPD_USE_CUSTOM_FSDATA: 0 -----*/
#define HTTPD_USE_CUSTOM_FSDATA 1
/*----- Default Value for LWIP_SNTP: 0 ---*/
#define LWIP_SNTP 1
/*----- Default Value for SNTP_MAX_SERVERS: 1 ---*/
#define SNTP_MAX_SERVERS 5
/*----- Default Value for LWIP_MDNS: 0 ---*/
#define LWIP_MDNS 1
/*----- Default Value for LWIP_MDNS_RESPONDER: 0 ---*/
#define LWIP_MDNS_RESPONDER 1
/*----- Default Value for MDNS_MAX_SERVICES: 0 ---*/
#define MDNS_MAX_SERVICES 1
/*----- Value in opt.h for LWIP_STATS: 1 -----*/
#define LWIP_STATS 1
/*----- Value in opt.h for CHECKSUM_GEN_IP: 1 -----*/
#define CHECKSUM_GEN_IP 0
/*----- Value in opt.h for CHECKSUM_GEN_UDP: 1 -----*/
#define CHECKSUM_GEN_UDP 0
/*----- Value in opt.h for CHECKSUM_GEN_TCP: 1 -----*/
#define CHECKSUM_GEN_TCP 0
/*----- Value in opt.h for CHECKSUM_GEN_ICMP: 1 -----*/
#define CHECKSUM_GEN_ICMP 0
/*----- Value in opt.h for CHECKSUM_GEN_ICMP6: 1 -----*/
#define CHECKSUM_GEN_ICMP6 0
/*----- Value in opt.h for CHECKSUM_CHECK_IP: 1 -----*/
#define CHECKSUM_CHECK_IP 0
/*----- Value in opt.h for CHECKSUM_CHECK_UDP: 1 -----*/
#define CHECKSUM_CHECK_UDP 0
/*----- Value in opt.h for CHECKSUM_CHECK_TCP: 1 -----*/
#define CHECKSUM_CHECK_TCP 0
/*----- Value in opt.h for CHECKSUM_CHECK_ICMP: 1 -----*/
#define CHECKSUM_CHECK_ICMP 0
/*----- Value in opt.h for CHECKSUM_CHECK_ICMP6: 1 -----*/
#define CHECKSUM_CHECK_ICMP6 0
/*----- Default Value for ETHARP_DEBUG: LWIP_DBG_OFF ---*/
#define ETHARP_DEBUG LWIP_DBG_OFF
/*----- Default Value for NETIF_DEBUG: LWIP_DBG_OFF ---*/
#define NETIF_DEBUG LWIP_DBG_OFF
/*----- Default Value for PBUF_DEBUG: LWIP_DBG_OFF ---*/
#define PBUF_DEBUG LWIP_DBG_OFF
/*----- Default Value for API_LIB_DEBUG: LWIP_DBG_OFF ---*/
#define API_LIB_DEBUG LWIP_DBG_OFF
/*----- Default Value for API_MSG_DEBUG: LWIP_DBG_OFF ---*/
#define API_MSG_DEBUG LWIP_DBG_OFF
/*----- Default Value for SOCKETS_DEBUG: LWIP_DBG_OFF ---*/
#define SOCKETS_DEBUG LWIP_DBG_OFF
/*----- Default Value for IP_DEBUG: LWIP_DBG_OFF ---*/
#define IP_DEBUG LWIP_DBG_OFF
/*----- Default Value for IP_REASS_DEBUG: LWIP_DBG_OFF ---*/
#define IP_REASS_DEBUG LWIP_DBG_OFF
/*----- Default Value for RAW_DEBUG: LWIP_DBG_OFF ---*/
#define RAW_DEBUG LWIP_DBG_OFF
/*----- Default Value for SYS_DEBUG: LWIP_DBG_OFF ---*/
#define SYS_DEBUG LWIP_DBG_OFF
/*----- Default Value for TCP_DEBUG: LWIP_DBG_OFF ---*/
#define TCP_DEBUG LWIP_DBG_OFF
/*----- Default Value for TCP_INPUT_DEBUG: LWIP_DBG_OFF ---*/
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
/*----- Default Value for DHCP_DEBUG: LWIP_DBG_OFF ---*/
#define DHCP_DEBUG LWIP_DBG_OFF
/*-----------------------------------------------------------------------------*/
/* USER CODE BEGIN 1 */



#define MEMP_STATS     1
#define LWIP_DEBUG      LWIP_DBG_ON
#define LWIP_DBG_MIN_LEVEL LWIP_DBG_LEVEL_ALL
#define LWIP_DBG_TYPES_ON LWIP_DBG_ON
#define MEMP_DEBUG    LWIP_DBG_ON


/*----- Default Value for LWIP_SO_RCVTIMEO: 0 ---*/

#define LWIP_SO_RCVTIMEO        1
#define MQTT_DEBUG              LWIP_DBG_OFF
#define MEM_DEBUG               LWIP_DBG_ON
//#define MEMP_DEBUG              LWIP_DBG_ON
#define MQTT_CYCLIC_TIMER_INTERVAL 1
#define SNTP_UPDATE_DELAY       60000
#define LWIP_SSDP               1
#define LWIP_ALTCP              1
#define LWIP_ALTCP_TLS          1
#define LWIP_ALTCP_TLS_MBEDTLS  1
#define MEM_SIZE                (15*1024) // greater value leads to a 
hardfault...
#define MEM_SANITY_CHECK        0
#define MEMP_MEM_INIT           1
#define MEMP_SANITY_CHECK       0
#define MEMP_OVERFLOW_CHECK     2

//#define MEM_USE_POOLS           1
//#define MEMP_USE_CUSTOM_POOLS   1
//#define MEM_USE_POOLS_TRY_BIGGER_POOL 1
#define MEMP_NUM_NETCONN        16
#define NO_SYS                  0
//#define MEM_LIBC_MALLOC         0
//#define MEMP_MEM_MALLOC         0
#define MEMP_NUM_PBUF           10
#define MEMP_NUM_UDP_PCB        60
#define MEMP_NUM_TCP_PCB        100
#define MEMP_NUM_TCP_PCB_LISTEN 5
#define MEMP_NUM_TCP_SEG        16
#define PBUF_POOL_SIZE          8
#define PBUF_POOL_BUFSIZE       1528 
//LWIP_MEM_ALIGN_SIZE(TCP_MSS+40+PBUF_LINK_ENCAPSULATION_HLEN+PBUF_LINK_HLEN)


/* LWIP_SUPPORT_CUSTOM_PBUF == 1: to pass directly MAC Rx buffers to the stack
   no copy is needed */
#define LWIP_SUPPORT_CUSTOM_PBUF      1

/* 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                 (1500 - 40)     /* TCP_MSS = (Ethernet MTU - IP 
header size - TCP header size) */

/* TCP sender buffer space (bytes). */
#define TCP_SND_BUF             (4*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        (4* TCP_SND_BUF/TCP_MSS)

/* TCP receive window. */
#define TCP_WND                 (8*TCP_MSS)


/* ---------- UDP options ---------- */
#define LWIP_UDP                1
#define UDP_TTL                 255


/*
   ----------------------------------------------
   ---------- Sequential layer options ----------
   ----------------------------------------------
*/
/**
* LWIP_NETCONN==1: Enable Netconn API (require to use api_lib.c)
*/
#define LWIP_NETCONN                    1

/*
   ------------------------------------
   ---------- Socket options ----------
   ------------------------------------
*/
/**
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
*/
#define LWIP_SOCKET                     1


#define MQTT_VAR_HEADER_BUFFER_LEN 4096
#define MQTT_OUTPUT_RINGBUF_SIZE 4096



/* USER CODE END 1 */

#ifdef __cplusplus
}
#endif
#endif /*__LWIPOPTS__H__ */

/************************* (C) COPYRIGHT STMicroelectronics *****END OF 
FILE****/
Bitte beachten Sie unsere Betriebsruhe von 24.12.2020 bis einschließlich 
08.01.2021.

In diesem Zeitraum findet keinerlei Warenannahme oder Versand statt.
Letzter Anliefertag: Fr. 18.12.2020
Erster Anliefertag: Mo. 11.01.2021
Ab 11.01.2021 sind wir wieder wie gewohnt für Sie da!

reply via email to

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