Skip to content

Commit 9f831e0

Browse files
committed
rp2/network: Add USB Network support in RPI_PICO/USB_NET variant build.
Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
1 parent 869a98e commit 9f831e0

File tree

7 files changed

+31
-0
lines changed

7 files changed

+31
-0
lines changed

ports/rp2/boards/RPI_PICO/board.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,8 @@
1515
"product": "Pico",
1616
"thumbnail": "",
1717
"url": "https://www.raspberrypi.com/products/raspberry-pi-pico/",
18+
"variants": {
19+
"USB_NET": "USB Network Adapter"
20+
},
1821
"vendor": "Raspberry Pi"
1922
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# cmake file for Raspberry Pi Pico
22
set(PICO_BOARD "pico")
33
set(PICO_PLATFORM "rp2040")
4+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
// Board and hardware specific configuration
22
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
33
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
4+
5+
#if MICROPY_PY_LWIP
6+
// Enable networking.
7+
#define MICROPY_PY_NETWORK 1
8+
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico"
9+
#endif
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
set(MICROPY_PY_LWIP OFF)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
set(MICROPY_PY_LWIP ON)
2+
3+
list(APPEND MICROPY_DEF_BOARD
4+
MICROPY_HW_NETWORK_USBNET=1
5+
)
6+
# Board specific version of the frozen manifest
7+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/../RPI_PICO_W/manifest.py)

ports/rp2/mpconfigport.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,13 @@ extern const struct _mp_obj_type_t mod_network_nic_type_wiznet5k;
250250
#define MICROPY_HW_NIC_WIZNET5K
251251
#endif
252252

253+
#if MICROPY_HW_NETWORK_USBNET
254+
extern const struct _mp_obj_type_t mod_network_nic_type_usbnet;
255+
#define MICROPY_HW_NIC_USBNET { MP_ROM_QSTR(MP_QSTR_USB_NET), MP_ROM_PTR(&mod_network_nic_type_usbnet) },
256+
#else
257+
#define MICROPY_HW_NIC_USBNET
258+
#endif
259+
253260
#ifndef MICROPY_BOARD_NETWORK_INTERFACES
254261
#define MICROPY_BOARD_NETWORK_INTERFACES
255262
#endif
@@ -258,6 +265,7 @@ extern const struct _mp_obj_type_t mod_network_nic_type_wiznet5k;
258265
MICROPY_HW_NIC_CYW43 \
259266
MICROPY_HW_NIC_NINAW10 \
260267
MICROPY_HW_NIC_WIZNET5K \
268+
MICROPY_HW_NIC_USBNET \
261269
MICROPY_BOARD_NETWORK_INTERFACES \
262270

263271
// Additional entries for use with pendsv_schedule_dispatch.

ports/rp2/mpnetworkport.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
#if MICROPY_PY_LWIP
3232

33+
#include "extmod/network_usbd_ncm.h"
3334
#include "shared/runtime/softtimer.h"
3435
#include "lwip/timeouts.h"
3536

@@ -120,6 +121,10 @@ static void mp_network_soft_timer_callback(soft_timer_entry_t *self) {
120121
#if MICROPY_PY_NETWORK_WIZNET5K
121122
wiznet5k_poll();
122123
#endif
124+
125+
#if MICROPY_HW_NETWORK_USBNET
126+
network_usbd_ncm_service_traffic();
127+
#endif
123128
}
124129

125130
void mod_network_lwip_init(void) {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy