rp2: Fix PPP/lwIP build and runtime failures when MICROPY_PY_NETWORK_PPP_LWIP is enabled#19369
Closed
jouellnyc wants to merge 1 commit into
Closed
rp2: Fix PPP/lwIP build and runtime failures when MICROPY_PY_NETWORK_PPP_LWIP is enabled#19369jouellnyc wants to merge 1 commit into
jouellnyc wants to merge 1 commit into
Conversation
…PPP_LWIP is enabled Three bugs prevent PPP from building or running on rp2 even in custom builds with MICROPY_PY_NETWORK_PPP_LWIP=1: 1. lwip_inc/lwipopts.h: PPP_SUPPORT and PPPOS_SUPPORT both default to 0 in lwIP's ppp_opts.h and were not set for rp2, causing pppos_create() to fail at runtime with OSError: pppos_create failed. 2. CMakeLists.txt: network_lwip.c was not added to MICROPY_SOURCE_EXTMOD when MICROPY_PY_LWIP is enabled, causing a link failure on mp_mod_network_prefer_dns_use_ip_version. 3. mpnetworkport.c: sys_untimeout_all_with_arg() is called in the lwIP netif status callback but does not exist in lwIP 2.2.1. Added a #ifndef guarded no-op stub. Tested on Raspberry Pi Pico and Pico W with full PPP negotiation and HTTP connectivity confirmed over UART against a Linux pppd peer. Fixes prerequisite build issues for micropython#16445.
|
Code size report: |
Member
|
LLM hallucinations. Please don't waste our time. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes three bugs that prevent PPP from building or running on rp2 when
MICROPY_PY_NETWORK_PPP_LWIPis enabled. These bugs affect any custom build, including the Pico W scenario described in #16445.Bug 1 —
lwip_inc/lwipopts.h: PPP stack compiled out of lwIPPPP_SUPPORTandPPPOS_SUPPORTboth default to0in lwIP'sppp_opts.hand were not set in the rp2lwipopts.h. Result at runtime:Bug 2 —
CMakeLists.txt:network_lwip.cnot compilednetwork_lwip.cwas not added toMICROPY_SOURCE_EXTMODwhenMICROPY_PY_LWIPis enabled. This file definesmp_mod_network_prefer_dns_use_ip_versionwhichmodlwip.creferences at link time. Result at build time:Bug 3 —
mpnetworkport.c:sys_untimeout_all_with_argundefinedCalled in the lwIP netif status callback but does not exist in lwIP 2.2.1. Added a
#ifndefguarded no-op stub — will be superseded automatically when lwIP is updated. Result at build time:Without these three fixes, #16445 would merge but still fail to build and run for all users.
Testing
Custom firmware built with
MICROPY_PY_NETWORK=1,MICROPY_PY_LWIP=1,MICROPY_PY_NETWORK_PPP_LWIP=1on Raspberry Pi Pico (RP2040) and Raspberry Pi Pico W (RP2040).PPP peer: Raspberry Pi Zero 2W running pppd over UART (providing NAT/DNS etc).
Full PPP negotiation, IP assignment, DNS resolution, and end-to-end HTTP confirmed:
tcpdump on the Pi Zero confirming full TCP handshake and HTTP response over ppp0:
Also ran 10 consecutive HTTP requests on Pico W with 5 second intervals, all successful (this was not true prior).
Note on ppp.poll()
During testing, socket.recv() hangs without manually calling ppp.poll() after sending.
A poll loop is required in userspace:
Root cause:
network_ppp_stream_uart_irq_enable()is not called in thePPPERR_NONEcase of the status callback, so the UART IRQ is not re-armed after handshake completes. Noted here for visibility.Trade-offs and Alternatives
PPP_SUPPORTandPPPOS_SUPPORTadd lwIP's PPP stack to the build. This only affects boards that explicitly enableMICROPY_PY_NETWORK_PPP_LWIP— no impact on default builds.Generative AI
I used generative AI tools when creating this PR, but a human has checked the code and is responsible for the code and the description above.
Note
My original intention was to get my own Pi Pico H to use ppp behind a real Linux OS to piggy back on it's ability to use WPA2 Enterprise in that setting. In trying to get ppp on the the rp2, I tried to build but got errors. Then I pursued those errors with AI and landed here. I genuinely hope these changes are helpful as user of micropython and hobbyist.