2022-10-05 04:54 AM
Hello,
I'm on a STM32H743 (nucleo-H743ZI2), and I got LWIP (no OS) to "work", as in it receives ip packets and reads them. The problem is with allocating on the heap. I didn't use the libc_malloc option, the heap pointer is at 0x30044000 and is 1600 bytes long, and I configured the MPU for this area as follows:
MPU_InitStruct.Number = MPU_REGION_NUMBER2;
MPU_InitStruct.BaseAddress = 0x30044000;
MPU_InitStruct.Size = MPU_REGION_SIZE_16KB;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_CACHEABLE;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
The problems I encounter are:
mem_malloc: could not allocate 60 bytes
etharp_raw: could not allocate pbuf for ARP request.
The ram stats before it shows
MEM HEAP
avail: 1600
used: 0
max: 0
err: 0
(And after it, it's the same but with the error counted)
Is my config ok?
2022-10-07 07:24 AM
I think I found the reason: the HEAP isn't initialized with zeros
2022-10-07 10:17 AM
This is a really small heap for lwIP. The input driver will allocate enough space to handle a full ethernet frame, and then you have buffers need for outgoing traffic. In my experience, you should start with about 8k worth of memory and go higher if your application requires it. ( lwipopts.h MEM_SIZE )
I've got an lwIP device on my desk that uses about 2k of heap (max) with trivial network activity.