Skip to content

Add ability to reserve psram #6667

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

Merged
merged 1 commit into from
Aug 5, 2022

Conversation

jepler
Copy link

@jepler jepler commented Jul 29, 2022

.. the primary user of which will be the camera, since the framebuffers must be allocated via esp-idf allocation function and never from the gc heap.

A board can have a default value, and the value can also be set in the /.env file using the key CIRCUITPY_RESERVED_PSRAM with the value being the reserved size in bytes.

This may also help with the allocation of memory for dot clock framebuffers, so giving @kmatch98 a ping.

@jepler jepler marked this pull request as ready for review July 29, 2022 17:29
@kmatch98
Copy link

kmatch98 commented Jul 31, 2022

If I understand this correctly, this may be a benefit to the FrameBuffer code for the dot clock display. I ran into a likely related issue that since CircuitPython claims all the ESP32-s3’ s PSRAM, there is no PSRAM available for ESP-IDF allocations. I needed to initialize a big FrameBuffer for the dot clock display, usually allocated by the ESP-IDF RGB panel init function. To make it work, I chose to hack the ESP-IDF so that the RGB display init function can be called with a pre-allocated FrameBuffer (allocated from CircuitPython-land from the CP heap). My original plan was to request this capability to be added into the ESP-IDF. But perhaps this code will allow the the FrameBuffer to be allocated by the ESP-IDF functions without modifications to the ESP-IDF.

(Note for posterity related to #6049 : This may overcome one ESP-IDF related issue for the RGB display. There is at at least one other change required to the ESP-IDF related to triggering the refresh from CircuitPython. There are other changes to the ESP-IDF related to the “bounce buffer” that were merged in the main branch but may not have yet been back ported to v4.4)

jepler - special thanks for the ping.

@kmatch98
Copy link

kmatch98 commented Aug 1, 2022

One question: to preserve a display framebuffer when code.py finishes, Scott mentioned that the memory needs to be copied over somewhere else. Will this PR allow for that capability to move the FrameBuffer even if it’s allocated by the ESP-IDF?

@jepler
Copy link
Author

jepler commented Aug 1, 2022

The memory that is allocated by the esp-idf remains forever, even over resets of the interpreter.

@jepler jepler force-pushed the esp-reserve-heap-for-idf branch 4 times, most recently from 2ffef58 to 83b0620 Compare August 2, 2022 20:40
Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good but I did not test. Two suggestions.

.. the primary user of which will be the camera, since the framebuffers
must be allocated via esp-idf allocation function and never from the
gc heap.

A board can have a default value, and the value can also be set in the
/.env file using the key CIRCUITPY_RESERVED_PSRAM with the value being
the reserved size in bytes.

Co-authored-by: Dan Halbert <[email protected]>
@jepler jepler force-pushed the esp-reserve-heap-for-idf branch from c87d017 to 82be75a Compare August 3, 2022 21:19
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.

4 participants