About cache problems when write data in memory-mapped mode
sudashannon opened this issue · 5 comments
sudashannon commented
Hi koendv, thank you for your repo. It helps me to deal with the OSPI psram.
To solve the cache problems when write, I take the stm32's AN5050 for an example and it says:
So I change my OSPI configuration to:
And rerun the memtest without cache_invalidate and cache_clean operation, it succeed!
F.Y.I
sudashannon commented
Besides, I also change this region to MPU_ACCESS_NOT_BUFFERABLE.
koendv commented
On Sun, 01 Jan 2023 23:28:09 -0800 Leon Shan ***@***.***> wrote:
Hi koendv, thank you for your repo. It helps me to deal with the OSPI
psram. To solve the cache problems when write, I take the stm32's
AN5050 for an example and it says:
![image](https://user-images.githubusercontent.com/18300567/210203717-4420e09c-4f09-4571-b872-ee4f2e5545b7.png)
![image](https://user-images.githubusercontent.com/18300567/210203748-ab73424d-c775-4595-a15d-1f2964ffdbcc.png)
![image](https://user-images.githubusercontent.com/18300567/210203766-7b6a83df-f170-4b0f-8e4a-21d17a70c5be.png)
So I change my OSPI configuration to:
![image](https://user-images.githubusercontent.com/18300567/210203791-0b376278-0a19-4333-9747-103af21d3322.png)
And rerun the memtest without cache_invalidate and cache_clean
operation, it succeed!
![image](https://user-images.githubusercontent.com/18300567/210203861-8586c7ad-c95c-4cdf-8f8e-efb59d28f29c.png)
![image](https://user-images.githubusercontent.com/18300567/210203880-5fd6ccec-17ee-497f-9960-7679b9eeb801.png)
F.Y.I
This is very good news. I think this means large, cheap memory for micropython.
I have some questions.
What spi ram chip you are using?
What happens if you do not set MPU_ACCESS_NOT_BUFFERABLE?
Can you open a Pull Request, with the changes you made and mentioning your name in README.md?
best,
koen
sudashannon commented
Hi koen:
These days I have been tested different ospi configuration and MPU configuration and come the conclusion that:
koendv commented
On Tue, 10 Jan 2023 17:13:15 -0800 Leon Shan ***@***.***> wrote:
Hi koen:
These days I have been tested different ospi configuration and MPU
configuration and come the conclusion that: 1. OSPI configuraion is
not the key to solve the cache problems. 2. Aceess to memory-mapped
memory will be valid only if the MPU is set to write-through or
undefined, but when MPU is set to undefined, the memory-mapped memory
will not support unaligned access:
![image](https://user-images.githubusercontent.com/18300567/211695037-8d3f863b-3d35-4706-bfc2-0ba1225f0129.png)
BRs Leon
Hi Leon.
At least the ospi ram can be used.
Without cache memory access will be slower; I think memory access will
be 8 times slower. But the cache problem may be solved in other
processor models.
A question: Does ospi ram memory work with micropython?
If, in the linker script, you replace the line
RAM (xrw) : ORIGIN = 0x20010000, LENGTH = 192K
with
RAM (xrw) : ORIGIN = 0x90000000, LENGTH = 8M /* spi ram */
does micropython work?
If ospi memory works with micropython, then a way should be found for
micropython to use both the ram inside the mcu, and the ospi ram.
A possible solution would be to change malloc.c so small amounts of
memory are taken from internal ram, big amounts of memory from ospi ram.
And if everything works, then open a pull request so the new code
becomes part of micropython?
你用中文写没问题。
best,
koen
koendv commented
I wanted to say:
你用汉字写没问题。