cancel
Showing results for 
Search instead for 
Did you mean: 

MQTT pbuf_free: p->ref > 0 error

cleonb322
Associate III

I am working on an STM32f767 project with LWIP and MQTT. Everything seemed to work for a while but eventually, I received the following assert:  "pbuf_free: p->ref > 0..." which caused it to crash sometimes; but sometimes it will continue to work without any issue.  Has anyone had a similar issue?

According to LWIP_IAP example, memory location 0x20048000 is labeled as ethernet rx buffer location; however, I could not find where this location is linked to the ethernet rx buffer. for example, 0x2007C000 memory location in the linker file for RxDescripSection & TxDecripSection. And does the size of the MPU region have to be equal to or greater than MEM_SIZE defined in opt.h?

 

My settings: 

LinkerScript.ld

Memory_B1(xrw) : ORIGIN = 0x2004C000, LENGTH = 0xA0

Memory_B2(xrw) : ORIGIN = 0x2004C0A0, LENGTH = 0xA0

 

.RxDecripSection (NOLOAD) : { *(.RxDescripSection) } >Memory_B1

.TxDecripSection (NOLOAD) : { *(.DMATxDscrTab_section) } >Memory_B2

.ARM.attributes 0 : { *(.ARM.attributes) }

 

main.c 

 

/* Configure the MPU as Normal Non Cacheable for Ethernet Buffers in the SRAM2 */

MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x20048000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL1;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;

HAL_MPU_ConfigRegion(&MPU_InitStruct);

 

/* Configure the MPU as Device for Ethernet Descriptors in the SRAM2 */
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x2004C000;
MPU_InitStruct.Size = MPU_REGION_SIZE_1KB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE

HAL_MPU_ConfigRegion(&MPU_InitStruct);

 

0 REPLIES 0