If I wish to place a static definition such as a string in PSRAM, what should I do? This doc vaguely mentions EXT_RAM_ATTR but is that the correct keyword? They mention "additional data" and BSS so I want to be clear.
Also, how do I malloc from external PSRAM? I know there is a threshold but I wish to allocate only a couple hundred bytes and don't wish to change the threshold. Is there a special malloc() function that only allocates PSRAM? Thank you! My next question will be how to switch banks but that requires me to know how to allocate first
How to use PSRAM for static definitions and malloc()?
- shabtronic
- Posts: 49
- Joined: Sun Nov 03, 2019 1:33 pm
Re: How to use PSRAM for static definitions and malloc()?
Don't know about the static allocation - but spiram malloc is done with
heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
https://docs.espressif.com/projects/es ... l-ram.html
all depends how you've menuconfig'd it!
heap_caps_malloc(size, MALLOC_CAP_SPIRAM)
https://docs.espressif.com/projects/es ... l-ram.html
all depends how you've menuconfig'd it!
Re: How to use PSRAM for static definitions and malloc()?
Thanks! That function worked! On the other hand, EXT_RAM_ATTR causes panic. If I add it to this def, it causes panic.
static const char *request="adfadfa";
How do I use this attribute word properly? Thanks.
static const char *request="adfadfa";
How do I use this attribute word properly? Thanks.
- shabtronic
- Posts: 49
- Joined: Sun Nov 03, 2019 1:33 pm
Re: How to use PSRAM for static definitions and malloc()?
I think you can only use the EXT_RAM_ATTR on zero'd var's. I think the reason is - the system would have to copy the init data to spiram - making it more complex under the hood as such.
Re: How to use PSRAM for static definitions and malloc()?
Thanks again! That makes a lot of sense. I'll keep all my zero-filled arrays there to save regular memory space.
Who is online
Users browsing this forum: Baidu [Spider], martins, MicroController, Siuyqe and 94 guests