-
Notifications
You must be signed in to change notification settings - Fork 491
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
heap and memory question ? #510
Comments
if i do this: |
Max heap can be change ? i remenber, that an update of linker from @ourairquality save a lot of RAM. (Maybe not the same RAM) |
Something interesting, the official RTOS SDK got ~70KB heap |
I think that espressif use Instruction RAM/FLASH cache ram to get more heap.
Someone know how to disable cache for this region: 0x40108000 ? if we can do this, it will allow 16KB heap more. (if we not change other things). #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 48 * 1024 ) ) |
After compare DPORT register for both SDK: Maybe we just need to setup this register to get more 16Kb more heap. |
There are some clues in the include files:
So bit 4 has changed to be zero, and the include file suggests this disables bank 0 of the spi cache ram. Bank zero is probably 0x40108000 to 0x4010c000. They use the FreeRTOS heap5 allocator which can handle separate regions, and it seems to use a region that starts at the end of the used iram (and so also uses the remaining iram) and runs to 0x4010c000 (the end of bank 0). The comments suggest some limitations using this cache ram, that it can not be a TX buffer, or task stack. The TX buffer limitation might be a hardware issue. Not sure why the task stack could not use this area. Perhaps another option would be to use it as iram, to have the linker use 0x40100000 to 0x4010c000 for iram, to be able to link some code there if an app really needed that for speed etc. Perhaps |
After do some test, i valid: They use heap5 and get more heap like 72Kb setting. They use more ram region to get this value.(where ?) . But if the RAM/CACHE is following the 32K ram region, We need really to change heap system ? or can we just increase heap size. (and linker update ) |
i found this |
After replace |
Perhaps it is not necessary to replace |
When i test the original function, put the third arg at 0 didn't change the register.
I clean and rebuild but no effect with |
The attached patch appears adequate here. With this it was possible to use 0x40108000 to 0x4010c000 as scratch ram in a simple test. |
However only aligned 32 bit memory read operations appear to work in this region. Even aligned 8 and 16 bit write operations fault. There does appear to be code in the exception handlers to deal with this, but it appears to only implement the read opcodes. So do we need to extend that exception handler to deal with store opcodes too, or is there some hardware workaround? If only 32 bit operators are efficient in this region then it might have an even bigger performance hit. |
Perhaps it's connected as instruction RAM (which only can be accessed by 32-bit store/loads)? And when it's used as cache, an external cache controller is used (otherwise it's hard to imagine how can it work both as SPI cache and RAM) |
After test, Heap is on "dram0" size. dram : 81920 . After printf "sdk_system_print_meminfo" (it is buggy, i will fix it). i got this information //Limitation of iram is do not allocate task and TX buffer. (So we can use it for queue,buffers,stream...) |
RTOS ESPRESSIF SDK information: interesting map of heap. They use additionnal 4K from this segment i think they use only this part of iram as heap too: |
@ourairquality Ty for your patch, it is work well. I dont know what is the process to allocate memory. The change above don't change the size of heap. I guess it is "malloc" from libc that allocate memory and know the limit and we need recompile libc ?
|
Much of that top 4k is still used, it is just not made available to the linker to use. The malloc area starts from the Not sure what is above that. Tried writing over the area above the Assuming it is the startup stack, then once scheduling is started it is probably no longer needed and perhaps the available heap could be increased to 0x40000000 rather that just the SP when scheduling was started? Would anyone know what that top area of RAM is used for and if we could malloc over it? |
Here's a quick patch to make all of the top area of RAM available for allocation once scheduling has started. This assumes that the area was all the start up stack and is no longer needed - an assumption not checked! |
From RTOS sdk:
Why they said "should be" ?
Now:
Its maybe normal. I didnt know well how it is work. |
the first heap is value from |
I found three interesting article about memory and FreeRTOS / Newlib. the esp-open-rtos project use the memory scheme of newlib ? f it is the case, why do not use heap_5 from Freertos ? I use PR #519 and #523 in my project. I go not memory problem for now. |
I recently update esp-open-rtos with lock implementation than use "configUSE_RECURSIVE_MUTEXES". This implementation use 1k heap. |
-official esp8266 RTOS sdk use heap_5.c memory management for freertos. esp-open-rtos too or another model ?
I got some memory problem.
The text was updated successfully, but these errors were encountered: