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

SparkFun updates for the PSRAM draft/work #3

Open
wants to merge 88 commits into
base: feature/psram
Choose a base branch
from

Conversation

gigapod
Copy link

@gigapod gigapod commented Aug 30, 2024

Hi Pimoroni -

This repo:branch looks like the best path to get our updates in the discussion around the PSRAM PR on the micropython/micropython repo.

This PR contains updates that reflect the work we've done to support PSRAM and continues on the discussion/work that took place prior to the RP2350 announcement. We

Updates of note:

  • The frequency of the PSRAM depends on the VDD to the IC (noted in data sheet) - so added a define for that, and made it a parameter to the PSRAM setup/timing functions
  • Separated out the timing setup logic into a separate function - this is called the system clock is changed and after flash is written/erased.
  • Removed all the magic numbers we had in our code - created a variety of constants based on the PSRAM datasheet ..etc
  • Add a variety of comments and supporting links to outline what is taking place ...etc
  • Added board file for our Pro Micro RP2350

-Kirk

dpgeorge and others added 30 commits August 22, 2024 15:11
Signed-off-by: Phil Howard <[email protected]>
Signed-off-by: Damien George <[email protected]>
Remove references to hardware_rtc for rp2350
Reimplement time functioniality
Use hardware_powman instead
Define PICO_PLATFORM for RPI_PICO
move PICO_TINYUSB_PATH until PICO_PLATFORM is defined
PICO_TINYUSB_PATH has to be defined before calling pico_sdk_init
Make sure powerman timer is using xosc
ports/rp2: Updates for powman changes.
Probably another change coming to remove powman and use the new aon
    timer that supports both rp2040 and rp2350
ports/rps: Use aon_timer module.
ports/rp2: Remove rp2350 specific source.
ports/rp2: Use correct CMSIS header for rp2350.
ports/rp2: Add hardware_resets.
ports/rp2: For rp2350 just use aon timer
For rp2040 there's a workaround for RTC having only 1s resolution. This
    is not needed for rp2350
Stop setting PICO_RP2040_B* for rp2350
Only set PICO_RP2040_USB_DEVICE_ENUMERATION_FIX for rp2040

Signed-off-by: Damien George <[email protected]>
Check a target exists before accessing properties.

Usermod_gather_sources would recurse into garbage property names and
break.

Signed-off-by: Phil Howard <[email protected]>
Changes:
- NUM_BANK0_GPIOS > pins defined in pins.csv = hardfault
- make-pins.py: NUM_GPIOS is hard-coded in make-pins.py, make it bigger
- machine_pin.h: Pin "ID" must be six bits, not five (breaks bit packing?)
- mphalport.h/machine_pin.c: open drain mask must be 64bits.

Signed-off-by: Phil Howard <[email protected]>
Add support for 32 and 48 pin variants of RP2350.

Add new gpio_base, mirroring the Pico SDK.

Signed-off-by: Phil Howard <[email protected]>
NUM_GPIOS amd NUM_EXT_GPIOS is currently hardcoded in this python
script.

Pass the count in via the new parameters num-gpios and num-ext-gpios.
These default to the current values supported by Pico 30/10. This can be
changed with PICO_NUM_GPIOS and PICO_NUM_EXT_GPIOS in
mpconfigboard.cmake. Without this you will get a build error because
NUM_BANK0_GPIOS can be too small.

Signed-off-by: Damien George <[email protected]>
Fix the gpio_irq function so that it looks at all six
iobank0_hw->intr[n] registers, for up to 48 IOs.

Signed-off-by: Phil Howard <[email protected]>
Note: This might be a tempoarary measure until we might fix this
properly to avoid copying code.

Signed-off-by: Damien George <[email protected]>
dpgeorge and others added 25 commits August 30, 2024 15:18
To test construction of UART instances.

Signed-off-by: Damien George <[email protected]>
Provide stub implementations of localtime_r() and mktime() to avoid
code size increase.

Reported upstream at raspberrypi/pico-sdk#1810

This work was funded through GitHub Sponsors.

Signed-off-by: Angus Gratton <[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]>
@Gadgetoid Gadgetoid force-pushed the feature/psram branch 2 times, most recently from 2fae3a9 to 3cd6781 Compare September 5, 2024 08:24
@Gadgetoid Gadgetoid force-pushed the feature/psram branch 2 times, most recently from b504e66 to c98c139 Compare September 27, 2024 13:39
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.

8 participants