Skip to content

Commit

Permalink
Merge pull request #947 from pimoroni/test/network-ppp
Browse files Browse the repository at this point in the history
PPP-enabled Pico build.
  • Loading branch information
Gadgetoid authored Oct 31, 2024
2 parents fd4b292 + ef936ba commit 1495805
Show file tree
Hide file tree
Showing 13 changed files with 327 additions and 43 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/micropython.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ jobs:
board: RPI_PICO
- name: pico_usb
board: RPI_PICO_USB
- name: pico_ppp
board: RPI_PICO_PPP
- name: picow
board: RPI_PICO_W
- name: tiny2040_8mb
Expand Down
20 changes: 20 additions & 0 deletions micropython/board/RPI_PICO_PPP/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"Breadboard friendly",
"Castellated Pads",
"Micro USB"
],
"id": "rp2-pico",
"images": [
"rp2-pico.jpg"
],
"mcu": "rp2040",
"product": "Pico",
"thumbnail": "",
"url": "https://www.raspberrypi.com/products/raspberry-pi-pico/",
"vendor": "Raspberry Pi"
}
7 changes: 7 additions & 0 deletions micropython/board/RPI_PICO_PPP/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include("$(PORT_DIR)/boards/manifest.py")

require("bundle-networking")

include("../manifest_pico.py")

freeze("../../modules_py", "lte.py")
9 changes: 9 additions & 0 deletions micropython/board/RPI_PICO_PPP/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# cmake file for Raspberry Pi Pico
set(PICO_BOARD "pico")

set(MICROPY_PY_LWIP ON)

# Board specific version of the frozen manifest
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)

set(MICROPY_C_HEAP_SIZE 4096)
16 changes: 16 additions & 0 deletions micropython/board/RPI_PICO_PPP/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
#define MICROPY_HW_FLASH_STORAGE_BYTES (1024 * 1024)

// Enable networking.
#define MICROPY_PY_NETWORK 1
#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico"

#define MICROPY_PY_NETWORK_PPP_LWIP 1

#define MICROPY_HW_NIC_PPP { MP_ROM_QSTR(MP_QSTR_PINT), MP_ROM_PTR(&mp_network_ppp_lwip_type) },

#define MICROPY_BOARD_NETWORK_INTERFACES \
MICROPY_HW_NIC_PPP

#define MICROPY_PY_SOCKET_EXTENDED_STATE 1
28 changes: 28 additions & 0 deletions micropython/board/RPI_PICO_PPP/pins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
GP0,GPIO0
GP1,GPIO1
GP2,GPIO2
GP3,GPIO3
GP4,GPIO4
GP5,GPIO5
GP6,GPIO6
GP7,GPIO7
GP8,GPIO8
GP9,GPIO9
GP10,GPIO10
GP11,GPIO11
GP12,GPIO12
GP13,GPIO13
GP14,GPIO14
GP15,GPIO15
GP16,GPIO16
GP17,GPIO17
GP18,GPIO18
GP19,GPIO19
GP20,GPIO20
GP21,GPIO21
GP22,GPIO22
GP25,GPIO25
GP26,GPIO26
GP27,GPIO27
GP28,GPIO28
LED,GPIO25
3 changes: 3 additions & 0 deletions micropython/modules/micropython-enviro.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ include(wakeup/micropython)
# Configure wakeup for Enviro
target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_HAS_RTC=1
-DWAKEUP_PIN_MASK=0b01000100
-DWAKEUP_PIN_DIR=0b01000100
-DWAKEUP_PIN_VALUE=0b01000100
)

# LEDs & Matrices
Expand Down
3 changes: 3 additions & 0 deletions micropython/modules/micropython-inky_frame.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ include(wakeup/micropython)
target_compile_definitions(usermod_wakeup INTERFACE
-DWAKEUP_HAS_RTC=1
-DWAKEUP_HAS_SHIFT_REGISTER=1
-DWAKEUP_PIN_MASK=0b01000100
-DWAKEUP_PIN_DIR=0b01000100
-DWAKEUP_PIN_VALUE=0b01000100
)

# LEDs & Matrices
Expand Down
16 changes: 16 additions & 0 deletions micropython/modules/micropython-pico_ppp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
include_directories(${CMAKE_CURRENT_LIST_DIR}/../../)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/../../")

set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

include(micropython-common)

# C++ Magic Memory
include(cppmem/micropython)

# Disable build-busting C++ exceptions
include(micropython-disable-exceptions)
1 change: 0 additions & 1 deletion micropython/modules/wakeup/micropython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ add_library(usermod_${MOD_NAME} INTERFACE)
target_sources(usermod_${MOD_NAME} INTERFACE
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.c
${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.cpp
#${CMAKE_CURRENT_LIST_DIR}/${MOD_NAME}.S
)

target_include_directories(usermod_${MOD_NAME} INTERFACE
Expand Down
36 changes: 0 additions & 36 deletions micropython/modules/wakeup/wakeup.S

This file was deleted.

24 changes: 18 additions & 6 deletions micropython/modules/wakeup/wakeup.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
#include "hardware/gpio.h"
#include "wakeup.config.hpp"

extern uint32_t runtime_wakeup_gpio_state;

namespace {
struct Wakeup {
public:
uint8_t shift_register_state = 0b0;
uint32_t gpio_state = 0;

Wakeup() {
// Assert wakeup pins (indicator LEDs, VSYS hold etc)
//gpio_init_mask(WAKEUP_PIN_MASK);
//gpio_set_dir_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_DIR);
//gpio_put_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_VALUE);
gpio_init_mask(WAKEUP_PIN_MASK);
gpio_set_dir_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_DIR);
gpio_put_masked(WAKEUP_PIN_MASK, WAKEUP_PIN_VALUE);

// Init all GPIOS not specified in the wakeup mask
#if PICO_RP2350
gpio_init_mask(~WAKEUP_PIN_MASK);
gpio_set_dir_in_masked(~WAKEUP_PIN_MASK);
#endif
gpio_state = gpio_get_all();
sleep_ms(5);
gpio_state |= gpio_get_all();
#if PICO_RP2350
gpio_init_mask(~WAKEUP_PIN_MASK);
#endif

#if WAKEUP_HAS_RTC==1
// Set up RTC I2C pins and send reset command
Expand Down Expand Up @@ -59,11 +71,11 @@ extern "C" {
#include "wakeup.h"

mp_obj_t Wakeup_get_gpio_state() {
return mp_obj_new_int(runtime_wakeup_gpio_state);
return mp_obj_new_int(wakeup.gpio_state);
}

mp_obj_t Wakeup_reset_gpio_state() {
runtime_wakeup_gpio_state = 0;
wakeup.gpio_state = 0;
return mp_const_none;
}

Expand Down
Loading

0 comments on commit 1495805

Please sign in to comment.