Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to provide custom memory allocation for LWIP #1762

Open
Memotech-Bill opened this issue Jul 8, 2024 · 0 comments
Open

Add ability to provide custom memory allocation for LWIP #1762

Memotech-Bill opened this issue Jul 8, 2024 · 0 comments
Milestone

Comments

@Memotech-Bill
Copy link

In order to resolve an issue that has been raised against the Pico version of BBC BASIC, I would like to be able to provide my own memory allocation for LWIP, replacing the routines in either ${PICO_LWIP_PATH}/src/core/mem.c and / or ${PICO_LWIP_PATH}/src/core/memp.c, however I cannot find any way to do this.

While there are CPP macro definitions such as MEMP_MEM_MALLOC and MEM_LIBC_MALLOC which select different memory allocators, there does not seem to be anything that allows providing user routines.

Using #define macros in lwipopts.h (or another include file) to rename the functions does not work since it renames both the function calls and the function definitions.

I have tried using the linker --wrap=... option, but that does not work as the symbols are defined in object files that are explicitly included in the link command, rather than being undefined symbols to be found by a library search.

Since the compilation of the lwip code is controlled by pico-sdk/src/rp2_common/pico_lwip/CMakeLists.txt it should be possible to add this feature to the SDK without requiring any modification to the lwip sub-module.

One possible approach would be to define three extra import libraries:

  • pico_lwip_nomem - Omits mem.c and memp.c
  • pico_lwip_mem - Provides mem.c
  • pico_lwip_memp - Provides memp.c

Another option would be to define CMake variables PICO_LWIP_NO_MEM and PICO_LWIP_NO_MEMP to control the inclusion / exclusion of mem.c and memp.c in the pico_lwip library.

@kilograham kilograham added this to the 2.1.0 milestone Aug 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants