cancel
Showing results for 
Search instead for 
Did you mean: 

iMemory Leak Issue on STM32H723 with LwIP Stack

GTrin.2
Associate
Hello everyone,
 
I am experiencing an intermittent memory leak issue when using LwIP on an STM32H723VG. I have an application where the Ethernet interface exchanges data periodically and over time I notice an increase in lwip_stats.mem.used and lwip_stats.mem.max, which indicates a possible memory leak.
 
I have already reviewed the heap and stack settings, but the issue persists. Additionally, the system is configured to use D2 RAM, which is not cached, and the MPU is configured to protect certain memory regions.
 
I would like to know if anyone has faced a similar issue and found a solution or has any suggestions on how to solve this.
 
Here are some details of my setup:
 
*** main.c ***
 
  /** Initializes and configures the Region and the memory to be protected
  */
  MPU_InitStruct.Number = MPU_REGION_NUMBER9;
  MPU_InitStruct.BaseAddress = 0x30000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_32KB;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
 
  /** Initializes and configures the Region and the memory to be protected
  */
  MPU_InitStruct.Number = MPU_REGION_NUMBER10;
  MPU_InitStruct.BaseAddress = 0x30000000;
  MPU_InitStruct.Size = MPU_REGION_SIZE_512B;
  MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
  MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
  MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
  MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
  MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
 
  HAL_MPU_ConfigRegion(&MPU_InitStruct);
  
*** STM32H723_FLASH.ID ***
 
    /* Modification start */
  .lwip_sec (NOLOAD) : {
    
. = ABSOLUTE(0x30000000);
    *(.RxDecripSection) 
 
    . = ABSOLUTE(0x30000100);
    *(.TxDecripSection)
    
    . = ABSOLUTE(0x30000200);
    *(.Rx_PoolSection)
    
    . = ABSOLUTE(0x30005000);
    *(.lwip_ram_base)
 
  } >RAM_D2
  /* Modification end */
  
*** ethernetif.c ***
 
typedef struct
{
  struct pbuf_custom pbuf_custom;
  uint8_t buff[(ETH_RX_BUFFER_SIZE + 31) & ~31] __ALIGNED(32);
} RxBuff_t;
 
ETH_DMADescTypeDef DMARxDscrTab[ETH_RX_DESC_CNT] __attribute__((section(".RxDecripSection"))); /* Ethernet Rx DMA Descriptors */
ETH_DMADescTypeDef DMATxDscrTab[ETH_TX_DESC_CNT] __attribute__((section(".TxDecripSection")));   /* Ethernet Tx DMA Descriptors */
 
__attribute__((section(".Rx_PoolSection"))) extern u8_t memp_memory_RX_POOL_base[];
 
*** lwipopts.h ***
 
#define ETH_RX_BUFFER_SIZE 1536
#define MEM_SIZE 8*1024
 
We do not define LWIP_RAM_HEAP_POINTER and instead in mem.c we define HEAP.
__attribute__((section(".lwip_ram_base"))) LWIP_DECLARE_MEMORY_ALIGNED(ram_heap, MEM_SIZE_ALIGNED + (2U * SIZEOF_STRUCT_MEM));
 
I checked several issues already opened on the forum:
 
 
 
 
 
 
gvivian
0 REPLIES 0