Closed ghost closed 1 year ago
Hi Tom, the only reason is that the SAME5x support was never really finished. I had planned to use the chips in a project at work to replace some unobtainable STM32 but they also went out of stock back then. Feel free to open a PR to enable the data cache, if you like.
Hi Chris, thanks for the reply. Actually I was thinking more ot the instruction cache, but before I would attempt a PR I have some questions (and bear in mind that I am no guru).
Sorry to hammer you with so many questions. If it were just me I would enable it and be done with it; but if I submit a PR I want it to fit the quality of the project.
BTW, thanks for the work you did on the SAM D51/E5x. I made a lame attempt at it myself, but I am not in the same league!
On Fri, Jun 2, 2023 at 10:43 AM Christopher Durand @.***> wrote:
Hi Tom, the only reason is that the SAME5x support was never really finished. I had planned to use the chips in a project at work to replace some unobtainable STM32 but they also went out of stock back then. Feel free to open a PR to enable the data cache, if you like.
— Reply to this email directly, view it on GitHub https://github.com/modm-io/modm/issues/1033#issuecomment-1573852782, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBESCU7FP4GJTCAH6QMLETXJH3ZBANCNFSM6AAAAAAYXVT2AI . You are receiving this because you authored the thread.Message ID: @.***>
I'm going to answer my own questions :-)
2 and 4. When (if) my Feather M4 BSP PR gets approved and merged, I believe I will submit a PR for 'board.hpp' that turns on the cache in the 'initialization()' function. I don't think it should go in core:cortex-m because the cache was not an ARM option in the M4 boards; it was an add-on done by some vendors and thus vendor specific. Any boards with the SAMD51/SAME5x could also add something to their initialization if desired; but if not, it should probably be mentioned in the docs that the cache is not enabled by default. At some point it may be useful to have a platform/cache/(vendor) module to handle enabling/disabling, invalidating entries, locking, and other assorted functions of a cache controller.
Having the cache enabled does NOT affect the delay_ns() function. I did a test with interrupts disabled, and reading the SysTick value immediately before and after the delay_ns() wrapper call (four 16-bit thumb instructions). Delaying for 50000ns, the result should have been ~6000 clock ticks: with cache off, it was 6067; cache on, 6064; and those numbers were consistent, loop after loop. I interpret that to mean that delay_ns() was running about 1% long with the tuning parameters in the sam platform:core module.lb, and that cache is not faster than modm_fastcode in RAM.
A corollary to the previous item is that using the cache memory as TCM with a linker script entry would not be worthwhile.
To 4: If you want to enable the cache we could put that code into the platform-specific core module, e.g here.
Enabling the cache should be unproblematic for D51/E5x because we don't support any feature yet that could interfere with caching, like DMA.
If you think that wouldn't be too early, then I'll try it there. I just wasn't sure what effect that might have on initializing the memory. (The opening comment in that file sounds so ominous! :-)
While debugging a program I wrote for a Feather M4 example, I determined that the cache controller was not enabled. I could find nothing in the SAMD51/SAME5x startup code relating to it.
Is this just an oversight, or is there a reason for it?
(Edited earlier post for brevity.)
Thanks, Tom Rush