DMA error when SRAM1 mapped at 0x00 address space in STM32L4
When SRAM1 is remapped at 0x00000000 address space using SYSCFG_MEMRMP register, SRAM1 cannot be accessed by DMA by its remapped zero-based address. DMA error occurs at the very first transfer and DMA channel becomes disabled.
Steps to reproduce:
1. Use SYSCFG memory remap register (SYSCFG_MEMRMP) to map SRAM1 at 0x00000000.
Write 0x03 to SYSCFG_MEMRMP register.
Bits 2:0 MEM_MODE[2:0]: Memory mapping selection: 011: SRAM1 mapped at 0x00000000.
2. Use DMA to access SRAM1 using 0x00000000 as SRAM1 base address:
// to access SRAM1 at 0x20000400:
DMA1_Channel1->CMAR = 0x400;
// DMA1_Channel1->CPAR can be pointing onto ADC, SPI, etc data register.
// DMA error occures at the first transfer.
Background
SRAM1 usually remapped to zero address space for higher performance. Less instructions required to access data and run code. LD script is normally used to tell linker about this relocation. But then all data pointers generated by linker are also become remapped to the new space and hence cannot be passed directly to the DMA without re-adjustment, which now has to be aware about re-mapping too.
MCU: STM32L496
