extmod: Place lwIP memory in a dedicated section. by iabdalkader · Pull Request #19138 · micropython/micropython · GitHub
Skip to content

extmod: Place lwIP memory in a dedicated section.#19138

Open
iabdalkader wants to merge 1 commit intomicropython:masterfrom
iabdalkader:lwip_reloc
Open

extmod: Place lwIP memory in a dedicated section.#19138
iabdalkader wants to merge 1 commit intomicropython:masterfrom
iabdalkader:lwip_reloc

Conversation

@iabdalkader
Copy link
Copy Markdown
Contributor

@iabdalkader iabdalkader commented Apr 22, 2026

Summary

Place lwIP memory in its own section to allow to relocating it via the linker script. This macro also aligns the memory without adding trailing padding bytes. See comments in src/include/lwip/arch.h this is how this macro is intended to be used:

You can declare your own version here e.g. to enforce alignment without adding trailing padding bytes (see LWIP_MEM_ALIGN_BUFFER) or your own section placement requirements.

Testing

Tested relocating lwIP memory to DRAM, with MBs of buffers, works well.

Generative AI

I did not use generative AI tools when creating this PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Code size report:

Reference:  extmod/moductypes: Be more defensive with uctypes_struct_agg_size args. [8a56be6]
Comparison: extmod: Place lwIP memory in a dedicated section. [merge of 565dda6]
  mpy-cross:    +0 +0.000% 
   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
      esp32:    +0 +0.000% ESP32_GENERIC
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +0 +0.000% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

Place lwIP memory in its own section to allow to relocating it via
the linker script. This macro also aligns the memory without adding
trailing padding bytes. See comments in src/include/lwip/arch.h

Signed-off-by: iabdalkader <i.abdalkader@gmail.com>
@iabdalkader
Copy link
Copy Markdown
Contributor Author

I realized I can just override this from our custom mpconfigport.h so feel free to close it, however it might be useful for upstream boards with SDRAM.

@dpgeorge
Copy link
Copy Markdown
Member

If you can do it from mpconfigboard.h (or mpconfigport.h) then that would probably be best. Because it means we don't need to have the config option MICROPY_PY_LWIP_SECTION, and you'd have more control over how the LWIP macro is configured.

@iabdalkader
Copy link
Copy Markdown
Contributor Author

If you can do it from mpconfigboard.h (or mpconfigport.h)

Yes, it works from our custom mpconfigport.h, though it has to be added to every port that needs it. This is generic enough to be useful to any port/board, sure you don't want it? We don't actually have any board that uses this, but we do have extra DRAM.

@dpgeorge
Copy link
Copy Markdown
Member

I need to understand more, why is it actually needed, what is the reason to put it in a dedicated section?

@iabdalkader
Copy link
Copy Markdown
Contributor Author

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

Successfully merging this pull request may close these issues.

2 participants