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

Question: How can store CircularBuffer in PSRAM on ESP32? #26

Closed
debsahu opened this issue Feb 4, 2020 · 5 comments
Closed

Question: How can store CircularBuffer in PSRAM on ESP32? #26

debsahu opened this issue Feb 4, 2020 · 5 comments
Assignees

Comments

@debsahu
Copy link

debsahu commented Feb 4, 2020

I would like to not use the RAM on ESP32, but rather use PSRAM attached using SPI interface. Data can be stored directly on PSRAM using ps_malloc() as per esp32-hal-psram.c.

I declare CircularBuffer<time_t, 2880> logTimeBuffer; globally that stores stuff in regular RAM. So is there a way to call ps_malloc() to use the PSRAM?

There is a good reference on doing this for ArduinoJson is here

@rlogiacco
Copy link
Owner

You can either change the source code for your case or use a macro switch to switch to a different implementation: I might consider accepting a pull request which uses the latter, but you need to test it also against AVR8 platforms as I don't want to break the library to support a corner case.

@debsahu
Copy link
Author

debsahu commented Feb 6, 2020

https://github.com/debsahu/CircularBuffer

@rlogiacco I changed the array T buffer[S] to pointer T buffer* and used malloc() for all other boards and heap_caps_malloc() for ESP32 with PSRAM. I am not an expert in C/C++, but gave it a shot. I need help with why it is crashing.

@rlogiacco
Copy link
Owner

rlogiacco commented Apr 8, 2020

Sorry, I'm not an expert on ESP32, but if you found a solution I'll be very willing to publish your solution.
On a second thought, after looking at your code, why didn't you just instantiate the CircularBuffer on PSRAM instead of declaring it globally?

I mean, why didn't you simply:

psramInit();
CircularBuffer<time_t, 2880> logTimeBuffer = (CircularBuffer)heap_caps_malloc(...)

@debsahu
Copy link
Author

debsahu commented Apr 9, 2020

Thank you will try that, my testing ESP32 unit with PSRAM is stuck at work (future me: due to a global pandemic). I will test it out next week.

@rlogiacco
Copy link
Owner

closing this as we got no feedback from the OP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants