简体   繁体   English

STM32H7 MPU 可共享 memory 属性和强排序 memory 类型

[英]STM32H7 MPU shareable memory attribute and strongly ordered memory type

I am confused by some of the attributes of the STM32H7 MPU.我对 STM32H7 MPU 的一些属性感到困惑。

I've read several documents: STM32H7 reference and programming manual, STMicro application note on MPM, etc...我已经阅读了几篇文档:STM32H7 参考和编程手册、STMicro 关于 MPM 的应用笔记等……

I've understood that shareable is exactly equivalent to non-cacheable (at least on a single core STM32H7).我知道可共享完全等同于不可缓存(至少在单核 STM32H7 上)。 Is it correct?这是对的吗?

I need to define a MPU region for a QSPI Flash memory.我需要为 QSPI Flash memory 定义一个 MPU 区域。 A document from MicroChip (reference TB3179) indicates that the QSPI memory should be configured as Strongly Ordered. MicroChip 的一份文档(参考 TB3179)表明 QSPI memory 应配置为强排序。 I don't really understand why?我真的不明白为什么?

Question: I've understood that shareable is exactly equivalent to non-cacheable (at least on a single core STM32H7).问:我知道可共享完全等同于不可缓存(至少在单核 STM32H7 上)。 Is it correct?这是对的吗?

Here's an ST guide to MPU configuration:这是 MPU 配置的 ST 指南:

https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/STM32_MPU_tips.html https://www.st.com/content/st_com/en/support/learning/stm32-education/stm32-moocs/STM32_MPU_tips.html

If some area is Cacheable and Shareable , only instruction cache is used in STM32F7/H7如果某些区域是Cacheable 和Shareable ,则在 STM32F7/H7 中仅使用指令缓存

As STM32 [F7 and H7] microcontrollers don't contain any hardware feature for keeping data coherent, setting a region as Shareable means that data cache is not used in the region.由于 STM32 [F7 和 H7] 微控制器不包含任何用于保持数据一致性的硬件功能,将区域设置为可共享意味着该区域不使用数据缓存 If the region is not shareable, data cache can be used, but data coherency between bus masters need to be ensured by software.如果区域不可共享,可以使用数据缓存,但是总线主控之间的数据一致性需要通过软件来保证。

Shareable on STM32H7 seems to be implicitly synonymous with non-cached access when INSTRUCTION_ACCESS_DISABLED (Execute Never, code execution disabled).当 INSTRUCTION_ACCESS_DISABLED(从不执行,禁用代码执行)时,STM32H7 上的可共享似乎隐含地与非缓存访问同义

Furthermore,此外,

https://community.arm.com/developer/ip-products/processors/f/cortex-a-forum/5468/shareability-memory-attribute https://community.arm.com/developer/ip-products/processors/f/cortex-a-forum/5468/shareability-memory-attribute

The sharability attribute tells the processor it must do whatever is necessary to allow that data to be shared.共享性属性告诉处理器它必须做任何必要的事情来允许共享数据。 What that really means depends on the features of a particular processor.这真正意味着什么取决于特定处理器的功能。

On a processor with multi-CPU hardware cache coherency;在具有多 CPU 硬件缓存一致性的处理器上; the shareability attribute is a signal to engage the cache coherency logic.可共享性属性是参与高速缓存一致性逻辑的信号。 For example A57 can maintain cache-coherency of shareable data within the cluster and between clusters if connected via a coherent interconnect.例如,如果通过一致的互连连接,A57 可以在集群内和集群之间保持可共享数据的缓存一致性。

On a processor without hardware cache coherency , such as Cortex-A8, the only way to share the data is to push it out of the cache as you guessed.在没有硬件缓存一致性的处理器(例如 Cortex-A8)上,共享数据的唯一方法是如您所料将其推出缓存。 On A8 shareable, cacheable memory ends up being treated as un-cached.在 A8上,可共享、可缓存的 memory 最终被视为未缓存。

Someone, please correct me if I'm wrong - it's so hard to come by definitive and concise statements on the topic.有人,如果我错了,请纠正我——很难就这个话题做出明确而简洁的陈述。


Question: I need to define an MPU region for a QSPI Flash memory.问:我需要为 QSPI Flash memory 定义一个 MPU 区域。 QSPI memory should be configured as Strongly Ordered. QSPI memory 应配置为强排序。 I don't really understand why?我真的不明白为什么?

The MPU guide above claims at least two points: prevent speculative access and prevent writes from being fragmented (eg interrupted by reading operations).上面的 MPU 指南至少声明了两点:防止推测性访问和防止写入被碎片化(例如被读取操作中断)。

Speculative memory read may cause high latency or even system error when performed on external memories like SDRAM, or Quad-SPI.当在 SDRAM 或 Quad-SPI 等外部存储器上执行时,推测性 memory 读取可能会导致高延迟甚至系统错误。

External memories even don't need to be connected to the microcontroller, but its memory range is accessible by speculative read because by default, its memory region is set as Normal.外部存储器甚至不需要连接到微控制器,但其 memory 范围可通过推测读取访问,因为默认情况下,其 memory 区域设置为正常。

Speculative access is never made to Strongly Ordered and Device memory areas.决不会对强有序和设备 memory 区域进行推测性访问。

Strongly Ordered memory type is used in memories which need to have each write be a single transaction强有序 memory 类型用于需要每次写入为单个事务的存储器

For Strongly Ordered memory region CPU waits for the end of memory access instruction.对于强有序 memory 区域CPU 等待 memory 访问指令结束

Finally, I suspect that alignment can be a requirement from the memory side which is adequately represented by a memory type that enforces aligned read/write access.最后,我怀疑 alignment 可能是 memory 方面的要求,它由强制对齐读/写访问的 memory 类型充分表示。

https://developer.arm.com/documentation/ddi0489/d/memory-system/axim-interface/memory-system-implications-for-axi-accesses https://developer.arm.com/documentation/ddi0489/d/memory-system/axim-interface/memory-system-implications-for-axi-accesses

However, Device and Strongly-ordered memory are always Non-cacheable.但是,设备和强排序 memory 始终是不可缓存的。 Also, any unaligned access to Device or Strongly-ordered memory generates alignment UsageFault and therefore does not cause any AXI transfer.此外,对设备或强排序 memory 的任何未对齐访问都会生成 alignment UsageFault ,因此不会导致任何 AXI 传输。 This means that the access examples are given in this chapter never show unaligned accesses to Device or Strongly-ordered memory.这意味着本章中给出的访问示例从不显示对设备或强排序 memory 的未对齐访问。


UsageFault: Without explicit configuration, UsageFault defaults to calling the HardFault handler. UsageFault:没有显式配置,UsageFault 默认调用 HardFault 处理程序。 Differentiated error handling needs to be enabled in SCB System Handler Control and State Register first:首先需要在SCB System Handler Control 和 State 寄存器中启用差异化错误处理:

SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk // will also be set by HAL_MPU_Enable()
    | SCB_SHCSR_BUSFAULTENA_Msk
    | SCB_SHCSR_USGFAULTENA_Msk;

UsageFault handlers can evaluate UsageFault status register (UFSR) described in https://www.keil.com/appnotes/files/apnt209.pdf . UsageFault 处理程序可以评估https://www.keil.com/appnotes/files/apnt209.pdf中描述的 UsageFault 状态寄存器 (UFSR)。

printf("UFSR : 0x%4x\n", (SCB->CFSR >> 16) & 0xFFFF);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM