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

Conversation

MichaelBell
Copy link

The main aim of this change is to expose a PSRAM data section from the linker, but (IMO) it also tidies up some things, especially only compiling the rp2_psram module in PSRAM builds.

However, this does require that the board config sets MICROPY_HW_ENABLE_PSRAM to ON in the cmake, instead of defining it to 1 in the C header, so there is some impact on existing builds.

Currently variables put in the .psram_data section are uninitialized, but that could potentially be fixed.

Additionally, because there's now a separate linker script for the PSRAM build, the requirement for 128kB GC heap in the non-PSRAM build could potentially be re-instated, but I haven't done that here.

peterharperuk and others added 30 commits November 5, 2024 16:25
Signed-off-by: Peter Harper <[email protected]>
Stop using soft timer for mp_wfe_or_timeout. Now uses the alarm pool
again as issues with this code have been fixed. This resolves the "sev"
issue that stops the rp2 port going idle.

Change the sleep code to use the hardware timer library and alarm 2 as
alarm 3 is used by the alarm pool

Signed-off-by: Peter Harper <[email protected]>
As cyw43 pins might be dynamic, add a function that returns if a pin is
reserved. This is used by MICROPY_HW_PIN_RESERVED

Signed-off-by: Peter Harper <[email protected]>
Signed-off-by: Peter Harper <[email protected]>
The cyw43 pins used to be hardcoded and CYW43_PIN_WL_HOST_WAKE and
CYW43_PIN_WL_REG_ON were in the pico_w.h board header.

This has been changed so the board header just defines the "default
version of the pins, e.g. CYW43_DEFAULT_PIN_WL_HOST_WAKE,
CYW43_DEFAULT_PIN_WL_REG_ON etc.

Set the pin values in cyw43_configport.h so cyw43-driver sees them and
allow them to be changed at runtime (dynamic) if required.

Signed-off-by: Peter Harper <[email protected]>
Support configuring wireless on arbitrary GPIO pins.

e.g.

import network
wlan = network.WLAN(network.STA_IF, pin_on=2, pin_cs=3, pin_dat=4,
pin_clock=5, div_int=3)

Signed-off-by: Peter Harper <[email protected]>
When building allow the port to be configured on the command line by
passing a value for CMAKE_ARGS.

Signed-off-by: Peter Harper <[email protected]>
The "init" code can now be added to rp2_network_cyw43_make_new.

Signed-off-by: Peter Harper <[email protected]>
Add PSRAM support with auto detection.

Performs a best-effort attempt to detect attached PSRAM,
configure it and *add* it to the MicroPython heap.

If PSRAM is not present, should fall back to use internal
RAM.

Introduce two new port/board defines:

* MICROPY_HW_ENABLE_PSRAM to enable PSRAM.
* MICROPY_HW_PSRAM_CS_PIN to define the chip-select pin.

Changes:

ports/rp2/rp2_psram.c/h: Add new PSRAM module.
ports/rp2/main.c: Add optional PSRAM support.
ports/rp2/CMakeLists.txt: Include rp2_psram.c.
ports/rp2/rp2_flash.c: Add buffered write to avoid reads from PSRAM.
ports/rp2/mpconfigport.h: Enable MICROPY_GC_SPLIT_HEAP
for boards that set MICROPY_HW_ENABLE_PSRAM.

Co-authored-by: Kirk Benell <[email protected]>
Co-authored-by: Mike Bell <[email protected]>
Signed-off-by: Phil Howard <[email protected]>
My tests found issues when PSRAM is combined with the existing
RAM in a split-heap configuration. Since this option is not
enabled by default on RP2 I have changed it to be optional.

PSRAM will be used exclusively if MICROPY_GC_SPLIT_HEAP == 0,
it will be added to RAM if MICROPY_GC_SPLIT_HEAP == 1,
and the system will fall back to RAM only if it's not detected.

Signed-off-by: Phil Howard <[email protected]>
Try to avoid causing an upset with USB startup by
detecting PSRAM as early as possible.

Signed-off-by: Phil Howard <[email protected]>
Move PSRAM setup to immediately after flash timing setup.
Disable interrupts while setting up PSRAM.

Signed-off-by: Mike Bell <[email protected]>
For pico_w and pico2_w. This had inadvertently been removed.

Signed-off-by: Peter Harper <[email protected]>
or else nothing will work!

Signed-off-by: Peter Harper <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants