I started from an example of NXP SDK for LPC546xx MCUs. I'm using baremetal (NO_SYS=1) and I found the following warning in enet_ethernetif_lpc.c, function ethernetif_tx_release():

---
#if NO_SYS
#if defined(LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT) && LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT
        pbuf_free(p);
#else
#error "Bare metal requires LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT=1 because pbuf_free() is being called from an ISR"
#endif /* LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT */
...
---

It seems NXP code calls pbuf_free() inside ISR and this behaviour must be known to lwip by setting 1 to this macro. However it seems this macro is checked only in mem.c, if MEM_USE_POOLS is defined.

In my application I don't define MEM_USE_POOLS, so it is set to 0 by default in opt.h.

Does it mean I can avoid setting LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEX? I would like to set it to 0, because of the following warning found in opt.h:

---
 * ATTENTION: As you can see from the above description, this leads to dis-/  * enabling interrupts often, which can be slow! Also, on low memory, mem_malloc
 * can need longer.
---

However NXP code uses #error if this macro is not set, so I suspect there's a real risk to avoid setting it.



_______________________________________________
lwip-users mailing list
lwip-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/lwip-users

Reply via email to