-
Notifications
You must be signed in to change notification settings - Fork 176
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
Modify CHIP to support PSRAM platform allocator on ESP32 (CON-1517) #1248
Comments
This it the CHIP_CONFIG_MEMORY_MGMT_PLATFORM option. For example STM32 has replaced the memory allocator. |
I tracked down that DMA buffer (in a Lua driver) which was preventing me from enabling 'malloc from PSRAM' and I was able to enable it. But it didn't do nearly as much as I though it would, it only recovered around 30KB. CHIP is still allocaing 40,136 from internal RAM and there should not be a reason for it to allocate anything from internal RAM. Three obvious things to work on:
1 and 3 are likely the same. Maybe setting 'malloc from PSRAM' doesn't move C++ new? Can you ask the IDF team about that?
|
I tried replacing the new operator, but this has no effect. Maybe I am not doing it right? I put this in a .cpp file and linked it in.
|
I went through every allocation over 1KB. 198KB total. #2 is the lua stack with is impacted by #1249 #14,#15,#16,#52 are FreeRTOS queues which are easily moved. and finally BLE. BLE is using A LOT of memory : 11436 + 6144 + 4096 + 3056 + 1868 + 1260 + 1080 = 28,960 I only need BLE in observer role in my code. So my next experiment will be to tell CHIP to shut down BLE and then my code will restart it in observer role. Of all of these allocations, the only one which is in code I wrote is the LCD DMA buffer, #37. The task memory display is needs some interpreting:
That says MDNS has no internal memory, but I can see from the allocs that it has 4KB memory, but that memory is assigned to the CHIP task since it was initialized from the CHIP task. With similar logic, it may be that 23KB of the 40KB in CHIP actually belongs to BLE. The BLE task only claims 7580 bytes. |
I've managed to get 40KB of internal memory free now so my LCD based device is working again. |
@jonsmirl would this #1123 (comment) help? This moves the bss of |
Can you please implement a platform version of this memory code which moves these allocs into PSRAM?
https://github.com/project-chip/connectedhomeip/blob/master/src/lib/support/CHIPMem-Malloc.cpp#L93
All of these are CHIP and they are using internal RAM, and I keep running out of internal RAM over and over and I have 1.8MB of free PSRAM. I tried turning on the menuconfig option which makes malloc use PSRAM, but some buffers are doing DMA. So I would need to track those down and force them back into internal RAM.
It would be a useful exercise to work out the maximal amount of free internal RAM possible for the demos when PSRAM is available. To do that you would force every alloc into PSRAM and then see what breaks (mainly DMA buffers and interrupt code). Then fix up those DMA buffers and interrupt code to use caps alloc from internal RAM.
The text was updated successfully, but these errors were encountered: