Skip to content

ports/rp2: Enable PPP for Pico W. #16445

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

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Gadgetoid
Copy link
Contributor

@Gadgetoid Gadgetoid commented Dec 18, 2024

Enables MICROPY_PY_NETWORK_PPP_LWIP for Pico W so that it can take advantage of PPP-supporting networking modules.

This would probably be too onerous for a regular Pico build. Even though it could work, I suspect the networking stack will blow the tight firmware allocation.

Edit: Woof! That's quite a bit more code bloat than I'd expected!

Copy link

github-actions bot commented Dec 18, 2024

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2: +24896 +2.698% RPI_PICO_W[incl +752(bss)]
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

// Enable PPP networking.
#define MICROPY_PY_NETWORK_PPP_LWIP (1)
extern const struct _mp_obj_type_t mp_network_ppp_lwip_type;
#define MICROPY_BOARD_NETWORK_INTERFACES { MP_ROM_QSTR(MP_QSTR_PPP), MP_ROM_PTR(&mp_network_ppp_lwip_type) },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to add this entry, it's done automatically in extmod/modnetwork.c.

@@ -8,6 +8,11 @@
#define MICROPY_PY_NETWORK 1
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "PicoW"

// Enable PPP networking.
#define MICROPY_PY_NETWORK_PPP_LWIP (1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could probably put this line in mpconfigport.h as:

define MICROPY_PY_NETWORK_PPP_LWIP (MICROPY_PY_NETWORK)

Then it's available on all network-enabled boards, eg Pico 2 W.

@Gadgetoid
Copy link
Contributor Author

Gadgetoid commented Aug 13, 2025

Update to enable in mpconfigport.h by default, with the option to set MICROPY_PY_NETWORK_PPP_LWIP and disable it.

Looks like there's a significant code size overhead, though!

Edit: Looks like I need to limit to ports with LWIP enabled 🤦

[  2%] Generating genhdr/pins.h, pins_ARDUINO_NANO_RP2040_CONNECT.c
[  2%] Generating genhdr/qstr.i.last
/home/runner/work/micropython/micropython/micropython repo/extmod/network_ppp_lwip.c:38:10: fatal error: lwip/dns.h: No such file or directory
   38 | #include "lwip/dns.h"
      |          ^~~~~~~~~~~~

Actually or maybe I have an order of operations thing going on in the header.

Edit: I think this is the classic disagreement in patterns between:

  1. Include all source files and use .h defines to determine whether their contents are enabled
  2. Conditionally include things based on CMake options and then set a define, eg:
    if (MICROPY_PY_LWIP)
    target_link_libraries(${MICROPY_TARGET} micropy_lib_lwip)
    target_include_directories(${MICROPY_TARGET} PRIVATE
    lwip_inc
    )
    target_compile_definitions(${MICROPY_TARGET} PRIVATE
    MICROPY_PY_LWIP=1
    )
    endif()

@Gadgetoid
Copy link
Contributor Author

Wait a minute, what's the diference between:

MICROPY_PY_LWIP_PPP - https://github.com/search?q=repo%3Amicropython%2Fmicropython%20MICROPY_PY_LWIP_PPP&type=code

and

MICROPY_PY_NETWORK_PPP_LWIP - https://github.com/search?q=repo%3Amicropython%2Fmicropython+MICROPY_PY_NETWORK_PPP_LWIP&type=code

The latter seems to be set just for lwipopts_common.h -

#if MICROPY_PY_LWIP_PPP

mpconfigport.h: Default MICROPY_PY_NETWORK_PPP_LWIP to 1.

Signed-off-by: Phil Howard <github@gadgetoid.com>
MICROPY_PY_LWIP_PPP is used in only one place and is generally set to
the value of MICROPY_PY_NETWORK_PPP_LWIP. Remove the former.

extmod/lwip-include/lwipopts_common.h: Replace MICROPY_PY_LWIP_PPP
                                  with MICROPY_PY_NETWORK_PPP_LWIP.
ports/mimxrt/mpconfigport.h: Remove redundant MICROPY_PY_LWIP_PPP.
ports/rp2/mpconfigport.h: Remove redundant MICROPY_PY_LWIP_PPP,
                          default MICROPY_PY_NETWORK_PPP_LWIP to
                          MICROPY_PY_LWIP.
ports/stm32/mpconfigport.h: Remove redundant MICROPY_PY_LWIP_PPP.

Signed-off-by: Phil Howard <github@gadgetoid.com>
Copy link

codecov bot commented Aug 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.38%. Comparing base (744270a) to head (27cb448).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #16445   +/-   ##
=======================================
  Coverage   98.38%   98.38%           
=======================================
  Files         171      171           
  Lines       22295    22295           
=======================================
  Hits        21936    21936           
  Misses        359      359           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants