- Notifications
You must be signed in to change notification settings - Fork 13.3k
PoC cache configuration control #7060
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
Changes from 1 commit
Commits
Show all changes
89 commits Select commit Hold shift + click to select a range
fc63320 PoC cache configuration control
mhightower83 57043bd Style corrections
mhightower83 17ceceb Merge branch 'master' into poc-cache-config
mhightower83 7424aed Added detailed description for Cache_Read_Enable.
mhightower83 56306d3 Merge branch 'master' into poc-cache-config
mhightower83 0645923 Style and MMU_SEC_HEAP corrections.
mhightower83 a6bb5a1 Improved asm register usage.
mhightower83 5bb3e19 Merge branch 'master' into poc-cache-config
mhightower83 b443e43 Interesting glitch in boards.txt after github merge. A new board in
mhightower83 0c661db Support for 2nd Heap, excess IRAM, through umm_malloc.
mhightower83 c6eabc5 Merge branch 'master' into poc-cache-config
mhightower83 70842de Post push CI cleanup.
mhightower83 f35290b Cleanup part II
mhightower83 71e36cb Cleanup part III
mhightower83 edf008a Updates to support platformio, maybe.
mhightower83 161e7bc Added exception C wrapper replacement.
mhightower83 5ac46f7 Merge branch 'master' into poc-cache-config
mhightower83 91fc391 CI Cleanup
mhightower83 eb9882e CI Cleanup II
mhightower83 1422b8d Changes to exc-c-wrapper-handler.S to assemble under platformio.
mhightower83 b921e11 For platformio, Correction to toolchain-xtensa include path.
mhightower83 cfb3826 Temporarily added --print-memory-usage to ld parameters for cross-che…
mhightower83 a1cd3a2 Merge branch 'master' into poc-cache-config
mhightower83 352a2ed Merge branch 'poc-cache-config' of github.com:mhightower83/Arduino in…
mhightower83 062f8dc Merge branch 'master' into poc-cache-config
mhightower83 69fdd5b Merge branch 'master' into poc-cache-config
mhightower83 d5dac93 Merge branch 'master' into poc-cache-config
mhightower83 9d3a7de Merge branch 'poc-cache-config' of github.com:mhightower83/Arduino in…
mhightower83 ecd826c undo change to platform.txt
mhightower83 a9b92e2 correct merge conflict. take 1
mhightower83 5a99afc Merge branch 'master' into poc-cache-config
mhightower83 f51dd82 Merge branch 'master' into poc-cache-config
mhightower83 71ef229 Merge branch 'master' into poc-cache-config
mhightower83 1a9d909 Fixed #if... for building umm_get_oom_count. It was not building when…
mhightower83 7b4a8d4 Commented out XMC support. Compatibility issues with PoC when using 1…
mhightower83 d9ab27e Merge branch 'master' into poc-cache-config
mhightower83 6d18190 Corrected size.py, DRAM bracketing changed to not include ICACHE with…
mhightower83 50fe8a3 Merge branch 'master' into poc-cache-config
mhightower83 f62ff0a Merge branch 'master' into poc-cache-config
mhightower83 1847a72 Merge branch 'master' into poc-cache-config
mhightower83 d3ace64 Added additional _context for support of use of UMM_INLINE_METRICS.
mhightower83 a43a2a8 Merge branch 'master' into poc-cache-config
mhightower83 2f47516 Merge branch 'master' into poc-cache-config
mhightower83 fd8f942 Merge branch 'master' into poc-cache-config
mhightower83 74df810 Changes to clear errors and warnings from toolchain 10.1
mhightower83 b767a5d Isolated incompatable definitions related to _xtos_set_exception_hand…
mhightower83 e7402d8 Update tools/platformio-build.py
mhightower83 51ea542 Merge branch 'master' into poc-cache-config
mhightower83 3ff489c Merge branch 'master' into poc-cache-config
devyte 232dce4 Requested changes
mhightower83 a3c9e02 Corrected comment. And added missing include.
mhightower83 fc5f611 Improve comment.
mhightower83 bbdf166 style and comment correction
mhightower83 b88d197 Added draft mmu.rst file and updated index.
mhightower83 b058f17 Updated mmu.rst
mhightower83 5e31ed5 Add a default MMU_IRAM_SIZE value for a new CI test to pass.
mhightower83 a4d28e2 CI appeasement
mhightower83 d45ceb0 CI appeasement with comment correction.
mhightower83 4831410 Ensure SYS always runs with DRAM Heap selected.
mhightower83 f64a7d0 Add/move heap stack overflow/underflow check to Esp.cpp where the eve…
mhightower83 2238535 Improved comment clarity of purpose for IramReserve.ino. Clean up MMU…
mhightower83 c070657 Added missing #include
mhightower83 be71429 Corrected usage of warning
mhightower83 50ea394 Merge branch 'master' into poc-cache-config
mhightower83 4d7e1e9 Merge branch 'poc-cache-config' of github.com:mhightower83/Arduino in…
mhightower83 61afce0 CI appeasement and use #message not #pragma message
mhightower83 d828d76 Merge branch 'master' into poc-cache-config
mhightower83 7d4a600 Updated git version of eboot.elf to match build version.
mhightower83 20d39ee Merge branch 'master' into poc-cache-config
mhightower83 f33ed95 Merge branch 'master' into poc-cache-config
mhightower83 53894c7 Merge branch 'master' into poc-cache-config
mhightower83 5ee2136 Merge branch 'master' into poc-cache-config
devyte 3f415f8 Remove conditional build option USE_ISR_SAFE_EXC_WRAPPER, always inst…
mhightower83 addb149 Merge branch 'master' into poc-cache-config
mhightower83 d7fb4ab Updated mmu.rst
mhightower83 c8412a8 Merge branch 'master' into poc-cache-config
mhightower83 5786ec1 Merge branch 'master' into poc-cache-config
mhightower83 86c4e5a Merge branch 'master' into poc-cache-config
mhightower83 0c9ae16 Merge branch 'master' into poc-cache-config
mhightower83 2f88e7b Merge branch 'master' into poc-cache-config
mhightower83 6c324c1 Merge branch 'master' into poc-cache-config
mhightower83 929e79b Merge branch 'master' into poc-cache-config
mhightower83 1875c73 Merge branch 'master' into poc-cache-config
mhightower83 d3f9a0a Expanded and clarified comments.
mhightower83 e48d95e Style fixes and more cleanup
mhightower83 3ab791b Merge branch 'master' into poc-cache-config
mhightower83 a3bf35c Style fix
mhightower83 1ff2aef Remove unnessasary IRAM_ATTR from install_non32xfer_exception_handler
mhightower83 9f9e206 Merge branch 'master' into poc-cache-config
devyte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Added draft mmu.rst file and updated index.
Updated example HeapMetric.ino to also illustrate use of IRAM Improved comments in exc-c-wrapper-handler.S. Added insurance IRQ disable.
- Loading branch information
commit b88d1975a6ea89a93157b09fcbf383f84ef8029d
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,216 @@ | ||
| MMU - Adjust the Ratio of ICACHE to IRAM | ||
| ======================================== | ||
| | ||
| Overview | ||
| -------- | ||
| | ||
| The ESP8266 has a total of 64K of instruction memory, IRAM. This 64K of | ||
| IRAM is composed of one dedicated 32K block of IRAM and two 16K blocks | ||
| of IRAM. The last two 16K blocks of IRAM are flexible in the sense that | ||
| it can be used as a transparent cache for external flash memory. These | ||
| blocks can either be used for IRAM or an instruction cache for executing | ||
| code out of flash, ICACHE. | ||
| | ||
| The instructions generated for a sketch are divided up into two groups | ||
| ICACHE and IRAM. IRAM offers faster access/execution. It is commonly | ||
| used for interrupt service routines, exception handling, and | ||
| time-critical code. ICACHE allows for the execution of up to 1MB of code | ||
| in flash. On a cache miss, a delay occurs as the instructions are read | ||
| from flash via the SPI bus. | ||
| | ||
| There is 96KB of DRAM space. This memory can be accessed as byte, short, | ||
| or a 32-bit word. Access must be aligned according to the data element | ||
| size. A 16bit short must be on a multiple of 2-byte address boundary, | ||
| likewise, a 32-bit word must be on a multiple of 4-byte address | ||
| boundary. In contrast, data access to IRAM or ICACHE must always be a | ||
| full 32-bit word and aligned. We will introduce a non32-bit exception | ||
| handler for this later. | ||
| | ||
| Option Summary | ||
| -------------- | ||
| | ||
| **The Arduino IDE Tools menu option, ``MMU`` allows for the following | ||
| selections:** | ||
| | ||
| 1. ``32KB cache + 32KB IRAM (balanced)`` | ||
| | ||
| - This is the legacy ratio. | ||
| - Try this option 1st. | ||
| | ||
| 2. ``16KB cache + 48KB IRAM (IRAM)`` | ||
| | ||
| - With just 16KB cache, execution of code out of flash may be slowed | ||
| by more cache misses when compared to 32KB. The slowness will vary | ||
| with the sketch. | ||
| - Use this if you need a little more IRAM space and you are good on | ||
| DRAM space. | ||
| | ||
| 3. ``16KB cache + 48KB IRAM and 2nd Heap (shared)`` | ||
| | ||
| - This option builds on the previous option and builds a 2nd Heap | ||
| made with IRAM. | ||
| - The 2nd Heap size will vary with free IRAM. | ||
| - This option is flexible. IRAM usage for code can overflow into the | ||
| additional 16KB IRAM region shrinking the 2nd Heap below 16KB. Or | ||
| IRAM can be under 32KB allowing the 2nd Heap to be larger than | ||
| 16KB. | ||
| - Installs a Non-32-Bit Access handler for IRAM. This allows for | ||
| byte and 16-bit aligned short access. | ||
| - This 2nd Heap is supported by the standard ``malloc`` APIs. | ||
| - Heap selection is handled through a ``HeapSelect`` class. This | ||
| allows a specific heap selection for the duration of a scope. | ||
| - Use this option, if you are still running out of DRAM space after | ||
| you have moved as many of your constant strings/data elements that | ||
| you can to PROGMEM. | ||
| | ||
| 4. ``16KB cache + 32KB IRAM + 16KB 2nd Heap (not shared)`` | ||
| | ||
| - Not managed by the ``umm_malloc`` heap library | ||
| - Non-32-Bit Access for IRAM must be enabled separately | ||
| - A 16KB block of unmanaged memory. | ||
| - Data persist across reboots, but not deep sleep. | ||
| - This may be best for when you just need a large chunk of memory. | ||
| This option will free up the additional resources needed by | ||
| ``umm_malloc`` to support managing the 2nd Heap. | ||
| | ||
| MMU related build defines and possible values.These values change as | ||
| indicated with the menu options above: | ||
| | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ``#define`` | balanced | IRAM | shared (IRAM and Heap) | not shared (IRAM and Heap) | | ||
| +=========================+==============+==============+====================================+==============================+ | ||
| | ``MMU_IRAM_SIZE`` | ``0x8000`` | ``0xC000`` | ``0xC000`` | ``0x8000`` | | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ``MMU_ICACHE_SIZE`` | ``0x8000`` | ``0x4000`` | ``0x4000`` | ``0x4000`` | | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ``MMU_IRAM_HEAP`` | -- | -- | defined, enables\ ``umm_malloc`` | -- | | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ``MMU_SEC_HEAP`` | -- | \*\* | \*\* | ``0x40108000`` | | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ``MMU_SEC_HEAP_SIZE`` | -- | \*\* | \*\* | ``0x4000`` | | ||
| +-------------------------+--------------+--------------+------------------------------------+------------------------------+ | ||
| | ||
| \*\* This define is to an inline function that calculates the value, | ||
| based on unused code space. | ||
| | ||
| **The Arduino IDE Tools menu option, ``Non-32-Bit Access`` allows for | ||
| the following selections:** | ||
| | ||
| - ``Use pgm_read macros for IRAM/PROGMEM`` | ||
| - ``Byte/Word access to IRAM/PROGMEM (very slow)`` | ||
| | ||
| - This option adds a non32-bit exception handler to your build. | ||
| - Handles read/writes to IRAM and reads to ICACHE. | ||
| - Supports short and byte access to IRAM. | ||
| - Not recommended for high-frequency access data, use DRAM if you | ||
| can. | ||
| - Expect it to be slower than DRAM, each character access will | ||
| require a complete save and restore of all 16+ registers. | ||
| - Processing an exception uses 256 bytes of stack space just to get | ||
| started. The actual handler will add a little more. | ||
| - This option is implicitly enabled and required when you select MMU | ||
| option ``16KB cache + 48KB IRAM and 2nd Heap (shared)``. | ||
| | ||
| IRAM, unlike DRAM, must be accessed as aligned full 32-bit words, no | ||
| byte or short access. The pgm\_read macros are an option; however, the | ||
| store operation remains an issue. For a block copy ets\_memcpy - appears | ||
| to work well as long as the byte count is rounded up to be evenly | ||
| divided by 4 and source and destination addresses are 4 bytes aligned. | ||
| | ||
| A word of caution, I have seen one case with the new toolchain 10.1 | ||
| where code that reads a 32-bit word to extract a byte was optimized away | ||
| to be a byte read. Using ``volatile`` on the pointer stopped the | ||
| over-optimization. | ||
| | ||
| To get a sense of how memory access time is effected, see examples | ||
| ``MMU48K`` and ``irammem`` in ``ESP8266``. | ||
| | ||
| Miscellaneous | ||
| ------------- | ||
| | ||
| For calls to ``umm_malloc`` with interrupts disabled. | ||
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| | ||
| - ``malloc`` will always allocate from the ``DRAM`` heap when called | ||
| with interrupts disabled. | ||
| - ``realloc`` with a NULL pointer will use ``malloc`` and return a | ||
| ``DRAM`` heap allocation. Note, calling ``realloc`` with interrupts | ||
| disabled is **not** officially supported. You are on your own if you | ||
| do this. | ||
| - If you must use IRAM memory in your ISR, allocate the memory ahead of | ||
| time. And avoid non32-bit access that would trigger the exception | ||
| handler. | ||
| | ||
| I think this block should go away and we always use | ||
| ``USE_ISR_SAFE_EXC_WRAPPER`` with the exception handler. | ||
| | ||
| - ``realloc`` will fail if not built with | ||
| ``USE_ISR_SAFE_EXC_WRAPPER`` defined. | ||
| - The current build has ``USE_ISR_SAFE_EXC_WRAPPER`` defined in | ||
| ``mmu_iram.h``. | ||
| | ||
| .. rubric:: ISR/Exception Handler Issue | ||
| :name: isrexception-handler-issue | ||
| | ||
| The non-32-bit exception handler is called by a "C" wrapper function | ||
| in ROM. This ROM function enables interrupts before calling our | ||
| registered handler. Defining ``USE_ISR_SAFE_EXC_WRAPPER`` in | ||
| ``mmu_iram.h`` will install a replacement that does not enable | ||
| interrupts (now default). The effects on Network performance are | ||
| unknown. | ||
| | ||
| To keep ISR execution time with interrupts disabled at a minimum, | ||
| avoid the use of IRAM from ISRs. Especially the use of non-32-bit | ||
| read/writes on IRAM. | ||
| | ||
| How to Select Heap | ||
| ~~~~~~~~~~~~~~~~~~ | ||
| | ||
| The ``MMU`` selection ``16KB cache + 48KB IRAM and 2nd Heap (shared)`` | ||
| allows you to use the standard heap API function calls (``malloc``, | ||
| ``calloc``, ``free``, ... ). to allocate memory from DRAM or IRAM. The | ||
| selection can be made by instantiating the class ``HeapSelectIram`` or | ||
| ``HeapSelectDram``.The usage is similar to that of the ``InterruptLock`` | ||
| class. The default/initial heap source is DRAM. The class is in | ||
| ``umm_malloc/umm_heap_select.h`` | ||
| | ||
| :: | ||
| | ||
| ... | ||
| char *bufferDram; | ||
| bufferDram = (char *)malloc(33); | ||
| char *bufferIram; | ||
| { | ||
| HeapSelectIram ephemeral; | ||
| bufferIram = (char *)malloc(33); | ||
| } | ||
| ... | ||
| free(bufferIram); | ||
| free(bufferDram); | ||
| ... | ||
| | ||
| ``free`` will always return memory to the correct heap. There is no need | ||
| for tracking and selecting before freeing. | ||
| | ||
| ``realloc`` with a non-NULL pointer will always resize the allocation | ||
| from the original heap it was allocated from. When the supplied pointer | ||
| is NULL, then the current heap selection is used. | ||
| | ||
| Low level primatives for selecting a heap. These are used by the above | ||
| Classes: | ||
| | ||
| - ``umm_get_current_heap_id()`` | ||
| - ``umm_set_heap_by_id( ID value )`` | ||
| - Possible ID values | ||
| - ``UMM_HEAP_DRAM`` | ||
| - ``UMM_HEAP_IRAM`` | ||
| | ||
| Also, an alternate stack select based API is available. This is not as | ||
| easy as the class method; however, for some small set of cases it may | ||
| provide some additional control: | ||
| | ||
| - ``ESP.setIramHeap()`` Pushes current heap ID onto a stack and sets | ||
| Heap API for an IRAM selection. | ||
| - ``ESP.setDramHeap()`` Pushes current heap ID onto a stack and sets | ||
| Heap API for a DRAM selection. | ||
| - ``ESP.resetHeap()`` Restores previously pushed heap. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.