cancel
Showing results for 
Search instead for 
Did you mean: 

lwIP and SYS_LIGHTWEIGHT_PROT

ntfreak
Associate II
Posted on May 27, 2016 at 11:08

Hi,

Just been testing some software that uses the STM32CubeF4 version of lwIP 1.4.1 stack.

With asserts enabled we were very occasionally seeing one triggered in pbuf.c:950.

LWIP_ASSERT(''pbuf_free: p->ref > 0'', p->ref > 0);

For info this part of code is enclosed in a SYS_ARCH_PROTECT/SYS_ARCH_UNPROTECT block, but as SYS_LIGHTWEIGHT_PROT was 0 it was not protected.

Looking into the lwIP docs I see that when using an OS/interrupts you should really define SYS_LIGHTWEIGHT_PROT to 1 so that the relevant block is protected.

If I define SYS_LIGHTWEIGHT_PROT to 1 in our code we see no more asserts.

A quick grep of ST sample code and I see that SYS_LIGHTWEIGHT_PROT is always 0. Is this really correct ?

Did a quick check of an older project that used another vendor Cortex-M3 product and they actually checked that SYS_LIGHTWEIGHT_PROT was 1 in the driver code.

Regards

#lwip
0 REPLIES 0