Hello,
I would like to protect the DMA transactions with DMA built in MPU. For example, DMA may only read from address S, S+1, S+2, and S+3. It shall not read from any other region. It may only write the data to the address D, D+1, D+2, and D+3. It shall not write to any other region. My idea is to configure Region S as read only source region, region D as write only destination, and all other regions as no accessible (region F, starting at 0 and ending at 0xFFFFFFFF, no access).
I have done the following test on a TMS570LS1213 device.
1. Define two 32 bits words src_01 and src_02 as source. Configure MPU region 0 to start at &src_01 and end at &src_01 + 3. Configure region 0 as read only. Thus the 4 bytes (&src_01, ..., &src_01+3) are readable. Enable the MPU IRQ for region 0.
2. Define two 32 bits words dst_01 and dst_02 as destination. Configure MPU region 1 to start at &dst_01 and end at &dst_01 + 1. Configure region 1 as write only. Thus the 2 bytes (&dst_01, &dst_01+1) are writable. Enable the MPU IRQ for region 1.
3. Configure region 3 ( the last region) to start at 0 and end at 0xFFFFFFFF. Configure region 3 as "No Access". Thus region 3 is kind of "background" region. DMA has access to only region 0 and region 1. All accesses to the addresses outside region 0 and region are not allowed. Enable the MPU IRQ for region 3.
4. Configure DMA channel 0 to transfer 4 byte from &src_01 to &dst_01 (read element size = 1 byte, write element size = 1 byte, element count = 4, frame count = 1).
5. Start the transfer by enabling the register SWCHENA to 0x1.
I expect that a DMA MPU error will be triggered based on the following consideration: region 1 ends at &dst_01 + 1, the transfer will write 4 bytes, so DMA will try to write data to the addresses &dst_01+2, +3 which are outside the region 1 and region 0, but inside the region 3, and TRM states that
"
If the regions defined by the start and end addresses overlap, the region defined first in the
register space determines the access privilege. For example, if region 0 and region 1
overlap, the access permissions defined for region 0 will take precedence since region 0
registers are before region 1.
"
But no error is triggered. Could you please check why no error is triggered?
Moreover, the register description for DMAMPR0E (TRM Section 16.3.1.60) reads that
"End Address defines the address at which the region ends. The end address usually is larger than the start address for this region; otherwise, the region will wrap around at the end of the address space."
What if the end address is equal to start address? I suppose only one byte is protected with the corresponding region, right?
Thank you and best regards,
Libo