Skip to content

Commit cd19765

Browse files
pi-anlclaude
andcommitted
ports: Auto-enable USB Network (NCM) when LWIP is enabled.
Automatically enable MICROPY_HW_NETWORK_USBNET when MICROPY_PY_LWIP is enabled, following the same pattern as WEBSOCKET and WEBREPL. This makes USB networking available by default on boards that support both USB device mode and LWIP networking, while still allowing boards to explicitly disable it by setting MICROPY_HW_NETWORK_USBNET=0. Affects: STM32, RP2, MIMXRT, and Renesas-RA ports. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]> Signed-off-by: Andrew Leech <[email protected]>
1 parent 41e667e commit cd19765

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

ports/mimxrt/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ uint32_t trng_random_u32(void);
145145
#define MICROPY_PY_WEBSOCKET (MICROPY_PY_LWIP)
146146
#define MICROPY_PY_WEBREPL (MICROPY_PY_LWIP)
147147
#define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP)
148+
#ifndef MICROPY_HW_NETWORK_USBNET
149+
#define MICROPY_HW_NETWORK_USBNET (MICROPY_PY_LWIP)
150+
#endif
148151
#ifndef MICROPY_PY_NETWORK_PPP_LWIP
149152
#define MICROPY_PY_NETWORK_PPP_LWIP (MICROPY_PY_LWIP)
150153
#endif

ports/renesas-ra/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@
128128
#define MICROPY_PY_TIME_TIME_TIME_NS (1)
129129
#define MICROPY_PY_TIME_INCLUDEFILE "ports/renesas-ra/modtime.c"
130130
#define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP)
131+
#ifndef MICROPY_HW_NETWORK_USBNET
132+
#define MICROPY_HW_NETWORK_USBNET (MICROPY_PY_LWIP)
133+
#endif
131134
#ifndef MICROPY_PY_MACHINE
132135
#define MICROPY_PY_MACHINE (1)
133136
#define MICROPY_PY_MACHINE_INCLUDEFILE "ports/renesas-ra/modmachine.c"

ports/rp2/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,9 @@
200200
#define MICROPY_SSL_MBEDTLS (1)
201201
#define MICROPY_PY_LWIP_PPP (MICROPY_PY_NETWORK_PPP_LWIP)
202202
#define MICROPY_PY_LWIP_SOCK_RAW (MICROPY_PY_LWIP)
203+
#ifndef MICROPY_HW_NETWORK_USBNET
204+
#define MICROPY_HW_NETWORK_USBNET (MICROPY_PY_LWIP)
205+
#endif
203206

204207
// Hardware timer alarm index. Available range 0-3.
205208
// Number 3 is currently used by pico-sdk alarm pool (PICO_TIME_DEFAULT_ALARM_POOL_HARDWARE_ALARM_NUM)

ports/stm32/mpconfigport.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@
152152
#define MICROPY_HW_SOFTSPI_MAX_BAUDRATE (HAL_RCC_GetSysClockFreq() / 48)
153153
#define MICROPY_PY_WEBSOCKET (MICROPY_PY_LWIP)
154154
#define MICROPY_PY_WEBREPL (MICROPY_PY_LWIP)
155+
#ifndef MICROPY_HW_NETWORK_USBNET
156+
#define MICROPY_HW_NETWORK_USBNET (MICROPY_PY_LWIP)
157+
#endif
155158
#ifndef MICROPY_PY_NETWORK
156159
#define MICROPY_PY_NETWORK (1)
157160
#endif

0 commit comments

Comments
 (0)