Skip to content
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

ports/rp2: PSRAM linker script. #6

Open
wants to merge 30 commits into
base: feature/psram-and-wifi
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
94c594b
rp2: Fix USB sleep on 2350.
peterharperuk Oct 1, 2024
3fd5bbe
rp2: CMakeLists: Add components required by bootrom.h.
Gadgetoid Sep 25, 2024
ff20a50
rp2: Sleep changes.
peterharperuk Sep 30, 2024
7745037
rp2: Add mp_hal_is_pin_reserved.
peterharperuk Oct 9, 2024
d9e1be3
rp2: Add RPI_PICO2_W.
peterharperuk Oct 9, 2024
64d2c2a
tests/ports/rp2: Put back lightsleep/machine_idle test for RP2350.
peterharperuk Oct 21, 2024
366116a
lib/pico-sdk: Use develop version.
peterharperuk Oct 21, 2024
4ee4fa0
rp2: Define cyw43 pins.
peterharperuk Oct 23, 2024
ce3c405
extmod/network_cyw43.c: Make new overrideable.
peterharperuk Oct 22, 2024
aace525
rp2: Support for dynamic pins.
peterharperuk Sep 25, 2024
036ec83
rp2: Allow extra arguments in Makefile.
peterharperuk Oct 10, 2024
a002353
rp2: Put cyw43 config in separate files.
peterharperuk Oct 10, 2024
f727c4a
rp2: Allow pins.csv filename to be configured.
peterharperuk Oct 10, 2024
80b1559
rp2: Allow pico to use cyw43.
peterharperuk Oct 10, 2024
8fa6e28
rp2: Move cyw43 code from main.
peterharperuk Nov 4, 2024
c945672
ports/rp2: PSRAM support.
Gadgetoid Aug 6, 2024
9a15f1f
ports/rp2: PSRAM: Fix RP2040/Pico build.
Gadgetoid Aug 9, 2024
245c529
ports/rp2: Re-init PSRAM on CPU freq change.
Gadgetoid Aug 9, 2024
607ffa4
ports/rp2: Make split-heap optional.
Gadgetoid Aug 9, 2024
f401fb3
ports/rp2: Compute QMI timing based on system clock.
MichaelBell Aug 11, 2024
405d1d1
ports/rp2: Fix garbage collection with large heap.
MichaelBell Aug 11, 2024
af1a22d
ports/rp2: Remove flash timing control from PSRAM.
MichaelBell Aug 11, 2024
5884d37
ports/rp2: Set flash divisor appropriately.
MichaelBell Aug 11, 2024
153ca96
ports/rp2: Reset flash timing before PSRAM timing.
MichaelBell Aug 15, 2024
e49da69
ports/rp2: Move PSRAM init earlier in startup.
Gadgetoid Sep 30, 2024
14dca1f
ports/rp2: Further PSRAM setup tweaks.
MichaelBell Oct 13, 2024
84ba667
ports/rp2: Better fix to cache cleaning.
MichaelBell Oct 28, 2024
4d5899f
rp2: Set MICROPY_PY_NETWORK_HOSTNAME_DEFAULT.
peterharperuk Nov 8, 2024
a48c6df
rp2: Put back soft_timer_init.
peterharperuk Nov 8, 2024
22e04e2
ports/rp2: PSRAM linker script.
MichaelBell Nov 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions extmod/network_cyw43.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,29 @@ static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
);
}


mp_obj_t network_cyw43_get_interface(mp_int_t type) {
if (type == MOD_NETWORK_STA_IF) {
return MP_OBJ_FROM_PTR(&network_cyw43_wl_sta);
} else {
return MP_OBJ_FROM_PTR(&network_cyw43_wl_ap);
}
}

// Allow network_cyw43_make_new to be overridden
#ifndef MICROPY_PY_NETWORK_CYW43_MAKE_NEW
#define MICROPY_PY_NETWORK_CYW43_MAKE_NEW network_cyw43_make_new
static mp_obj_t network_cyw43_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
mp_arg_check_num(n_args, n_kw, 0, 1, false);
if (n_args == 0 || mp_obj_get_int(args[0]) == MOD_NETWORK_STA_IF) {
return MP_OBJ_FROM_PTR(&network_cyw43_wl_sta);
return network_cyw43_get_interface(MOD_NETWORK_STA_IF);
} else {
return MP_OBJ_FROM_PTR(&network_cyw43_wl_ap);
return network_cyw43_get_interface(MOD_NETWORK_AP_IF);
}
}
#else
mp_obj_t MICROPY_PY_NETWORK_CYW43_MAKE_NEW(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
#endif

static mp_obj_t network_cyw43_send_ethernet(mp_obj_t self_in, mp_obj_t buf_in) {
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);
Expand Down Expand Up @@ -558,7 +573,7 @@ MP_DEFINE_CONST_OBJ_TYPE(
mp_network_cyw43_type,
MP_QSTR_CYW43,
MP_TYPE_FLAG_NONE,
make_new, network_cyw43_make_new,
make_new, MICROPY_PY_NETWORK_CYW43_MAKE_NEW,
print, network_cyw43_print,
locals_dict, &network_cyw43_locals_dict
);
Expand Down
3 changes: 3 additions & 0 deletions extmod/network_cyw43.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@

extern const mp_obj_type_t mp_network_cyw43_type;

// Get the interface, where type is either MOD_NETWORK_STA_IF or MOD_NETWORK_AP_IF
mp_obj_t network_cyw43_get_interface(mp_int_t type);

#endif // MICROPY_INCLUDED_EXTMOD_NETWORK_CYW43_H
2 changes: 1 addition & 1 deletion lib/pico-sdk
Submodule pico-sdk updated 181 files
32 changes: 29 additions & 3 deletions ports/rp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ set(MICROPY_SOURCE_PORT
${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c
)

if(MICROPY_HW_ENABLE_PSRAM)
list(APPEND MICROPY_SOURCE_PORT
rp2_psram.c
)
target_compile_definitions(${MICROPY_TARGET} PRIVATE
MICROPY_HW_ENABLE_PSRAM=1
)
endif()

set(MICROPY_SOURCE_QSTR
${MICROPY_SOURCE_PY}
${MICROPY_DIR}/shared/readline/readline.c
Expand All @@ -195,7 +204,14 @@ set(MICROPY_SOURCE_QSTR
${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c
)

if (MICROPY_PY_NETWORK_CYW43)
list(APPEND MICROPY_SOURCE_QSTR
${MICROPY_PORT_DIR}/rp2_network_cyw43.c
)
endif()

set(PICO_SDK_COMPONENTS
boot_bootrom_headers
hardware_adc
hardware_base
hardware_boot_lock
Expand All @@ -222,6 +238,7 @@ set(PICO_SDK_COMPONENTS
pico_base_headers
pico_binary_info
pico_bootrom
pico_flash
pico_multicore
pico_platform
pico_platform_compiler
Expand Down Expand Up @@ -401,6 +418,7 @@ if (MICROPY_PY_NETWORK_CYW43)

list(APPEND MICROPY_SOURCE_PORT
machine_pin_cyw43.c
rp2_network_cyw43.c
)

target_link_libraries(${MICROPY_TARGET}
Expand Down Expand Up @@ -591,7 +609,11 @@ if (PICO_ON_DEVICE AND NOT PICO_NO_FLASH AND NOT PICO_COPY_TO_RAM)
if(PICO_RP2040)
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp_rp2040.ld)
elseif(PICO_RP2350)
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp_rp2350.ld)
if (MICROPY_HW_ENABLE_PSRAM)
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp_rp2350_psram.ld)
else()
pico_set_linker_script(${MICROPY_TARGET} ${CMAKE_CURRENT_LIST_DIR}/memmap_mp_rp2350.ld)
endif()
endif()
endif()

Expand Down Expand Up @@ -631,8 +653,12 @@ if(NOT PICO_NUM_EXT_GPIOS)
set(PICO_NUM_EXT_GPIOS 10)
endif()

if(EXISTS "${MICROPY_BOARD_DIR}/pins.csv")
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARD_DIR}/pins.csv")
if (NOT PICO_PINS_CSV_NAME)
set(PICO_PINS_CSV_NAME pins.csv)
endif()

if(EXISTS "${MICROPY_BOARD_DIR}/${PICO_PINS_CSV_NAME}")
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARD_DIR}/${PICO_PINS_CSV_NAME}")
set(GEN_PINS_CSV_ARG --board-csv "${GEN_PINS_BOARD_CSV}")
endif()

Expand Down
12 changes: 6 additions & 6 deletions ports/rp2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,26 @@ endif

$(VERBOSE)MAKESILENT = -s

CMAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"
override CMAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"

ifdef USER_C_MODULES
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
override CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
endif

ifneq ($(FROZEN_MANIFEST),)
CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
override CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
endif

ifeq ($(DEBUG),1)
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
endif

ifdef BOARD_VARIANT
CMAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
override CMAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
endif

ifdef MICROPY_PREVIEW_VERSION_2
CMAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
override CMAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
endif

HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"
Expand Down
7 changes: 7 additions & 0 deletions ports/rp2/boards/RPI_PICO/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is only used if cyw43 is enabled
include("$(PORT_DIR)/boards/manifest.py")

require("bundle-networking")

# Bluetooth
require("aioble")
6 changes: 6 additions & 0 deletions ports/rp2/boards/RPI_PICO/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# cmake file for Raspberry Pi Pico
set(PICO_BOARD "pico")
set(PICO_PLATFORM "rp2040")

if (PICO_CYW43_SUPPORTED)
include(enable_cyw43.cmake)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
set(PICO_PINS_CSV_NAME pins_cyw43.csv)
endif()
9 changes: 9 additions & 0 deletions ports/rp2/boards/RPI_PICO/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"

#if MICROPY_PY_NETWORK_CYW43
// we have to reduce the flash storage if cyw43 is enabled or else the firmware gets overwritten
#define MICROPY_HW_FLASH_STORAGE_BYTES (848 * 1024)
#include "enable_cyw43.h"
#define CYW43_PIN_WL_DYNAMIC 1
#define CYW43_PIO_CLOCK_DIV_DYNAMIC 1
#else
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
#endif
31 changes: 31 additions & 0 deletions ports/rp2/boards/RPI_PICO/pins_cyw43.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
WL_GPIO0,EXT_GPIO0
WL_GPIO1,EXT_GPIO1
WL_GPIO2,EXT_GPIO2
7 changes: 7 additions & 0 deletions ports/rp2/boards/RPI_PICO2/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file is only used if cyw43 is enabled
include("$(PORT_DIR)/boards/manifest.py")

require("bundle-networking")

# Bluetooth
require("aioble")
6 changes: 6 additions & 0 deletions ports/rp2/boards/RPI_PICO2/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ set(PICO_BOARD "pico2")

# To change the gpio count for QFN-80
# set(PICO_NUM_GPIOS 48)

if (PICO_CYW43_SUPPORTED)
include(enable_cyw43.cmake)
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
set(PICO_PINS_CSV_NAME pins_cyw43.csv)
endif()
6 changes: 6 additions & 0 deletions ports/rp2/boards/RPI_PICO2/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico2"
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024)

#if MICROPY_PY_NETWORK_CYW43
#include "enable_cyw43.h"
#define CYW43_PIN_WL_DYNAMIC 1
#define CYW43_PIO_CLOCK_DIV_DYNAMIC 1
#endif
31 changes: 31 additions & 0 deletions ports/rp2/boards/RPI_PICO2/pins_cyw43.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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
WL_GPIO0,EXT_GPIO0
WL_GPIO1,EXT_GPIO1
WL_GPIO2,EXT_GPIO2
21 changes: 21 additions & 0 deletions ports/rp2/boards/RPI_PICO2_W/board.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"deploy": [
"../deploy.md"
],
"docs": "",
"features": [
"BLE",
"Dual-core",
"External Flash",
"USB",
"WiFi"
],
"images": [
"rp2-pico2-w.jpg"
],
"mcu": "rp2350",
"product": "Pico 2 W",
"thumbnail": "",
"url": "https://www.raspberrypi.com/products/raspberry-pi-pico-2/",
"vendor": "Raspberry Pi"
}
6 changes: 6 additions & 0 deletions ports/rp2/boards/RPI_PICO2_W/manifest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
include("$(PORT_DIR)/boards/manifest.py")

require("bundle-networking")

# Bluetooth
require("aioble")
11 changes: 11 additions & 0 deletions ports/rp2/boards/RPI_PICO2_W/mpconfigboard.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# cmake file for Raspberry Pi Pico 2 W

set(PICO_BOARD "pico2_w")

# To change the gpio count for QFN-80
# set(PICO_NUM_GPIOS 48)

include(enable_cyw43.cmake)

# Board specific version of the frozen manifest
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
7 changes: 7 additions & 0 deletions ports/rp2/boards/RPI_PICO2_W/mpconfigboard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Board and hardware specific configuration
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico 2 W"
#define MICROPY_HW_FLASH_STORAGE_BYTES (PICO_FLASH_SIZE_BYTES - 1024 * 1024)

#define MICROPY_PY_NETWORK_HOSTNAME_DEFAULT "Pico2W"

#include "enable_cyw43.h"
30 changes: 30 additions & 0 deletions ports/rp2/boards/RPI_PICO2_W/pins.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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
GP26,GPIO26
GP27,GPIO27
GP28,GPIO28
WL_GPIO0,EXT_GPIO0
WL_GPIO1,EXT_GPIO1
WL_GPIO2,EXT_GPIO2
LED,EXT_GPIO0
8 changes: 1 addition & 7 deletions ports/rp2/boards/RPI_PICO_W/mpconfigboard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

set(PICO_BOARD "pico_w")

set(MICROPY_PY_LWIP ON)
set(MICROPY_PY_NETWORK_CYW43 ON)

# Bluetooth
set(MICROPY_PY_BLUETOOTH ON)
set(MICROPY_BLUETOOTH_BTSTACK ON)
set(MICROPY_PY_BLUETOOTH_CYW43 ON)
include(enable_cyw43.cmake)

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