This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

CM4: Write buffer with enabled MPU

Hello,

I have a question regarding Memory protection unit on Cortex M4 (STM32F3 MCU). This is pretty simple single core MCU without caches. I implemented MPU based on instructions in Definitive guide to the ARM Cortex-M4. It is stated there that the bufferable attribute of the memory, if it is defined by the MPU and the MPU is enabled, has higher priority than the default condition.

So, I defined a peripheral region (addresses from 0x40000000 - 0x5FFFFFFF) as a separate MPU region (full access, execute never) with bufferable attribute set. Is there any chance to see or to distinguish the behaviour if I set bufferable attribute or not?

The same for internal SRAM. First of all, is SRAM bufferable at all? And how to see difference if I set this attribute for SRAM or not?

There is also a prefetch block which is used for instruction fetches over the ICode bus. Is this somehow connected with cacheable attribute. Do I have to define a cacheable attribute for Flash, if it is coverd by the MPU?

Thank you in advance,

Matic

Parents
  • For Cortex-M4, the bufferable attribute is observable in two aspects:

    - performance : bufferable write to a peripheral register is faster than non-bufferable write (if non-bufferable, the processor need to write for the write to complete before next instruction can execute).

    - bus fault : if accessing a invalid peripheral address, you might be able to general a bus fault. A bus error for a bufferable write is asynchronous (imprecise), and for non-bufferable write, it is synchronous (precise). The bus fault status register will have corresponding status flags to indicate if the fault is synchronous or asynchronous.

    For SRAM, you might still be able to observe the performance difference but the different could be smaller (in terms of clock cycle counts). But the SRAM accesses will not generate error so you cannot observe bus error.

    For flash accesses, I don't know if STM32's flash access accelerator will utilize the cacheable attribute or not. (The attribute is exported to the system but the system might not utilise it). Potentially you can try different setting and see if it make a different in the performance. Alternatively you can ask ST (e.g. posting the question in STM32 forum : https://community.st.com/community/stm32-community/stm32-forum/content)

    regards,

    Joseph

Reply
  • For Cortex-M4, the bufferable attribute is observable in two aspects:

    - performance : bufferable write to a peripheral register is faster than non-bufferable write (if non-bufferable, the processor need to write for the write to complete before next instruction can execute).

    - bus fault : if accessing a invalid peripheral address, you might be able to general a bus fault. A bus error for a bufferable write is asynchronous (imprecise), and for non-bufferable write, it is synchronous (precise). The bus fault status register will have corresponding status flags to indicate if the fault is synchronous or asynchronous.

    For SRAM, you might still be able to observe the performance difference but the different could be smaller (in terms of clock cycle counts). But the SRAM accesses will not generate error so you cannot observe bus error.

    For flash accesses, I don't know if STM32's flash access accelerator will utilize the cacheable attribute or not. (The attribute is exported to the system but the system might not utilise it). Potentially you can try different setting and see if it make a different in the performance. Alternatively you can ask ST (e.g. posting the question in STM32 forum : https://community.st.com/community/stm32-community/stm32-forum/content)

    regards,

    Joseph

Children