STM32 gotchas
30.Only DMA2 can be used to transfer to/from GPIO in 'F4

In the 'F4 family (as well as 'F2 and 'F7), two DMA units are implemented. Both have two ports - a "Peripheral port" and a "Memory port" - and a FIFO. The internal units - called streams - can access simultaneously the two ports - while one stream accesses the Peripheral port, other can access the Memory port. Besides the respective RMs, this DMA unit is further described in AN4031.

However, even if the two DMAs are almost identical in their working and have identical registers, their connection within the system is not the same: the Peripheral port of DMA1 has no connection into the busmatrix, but is connected directly to the APB1 bus through a special dual-AHB-to-APB bridge, arbitrating between accesses from the busmatrix (through AHB1) and DMA1.

DMA2 does have this direct connection from its Peripheral port to APB2, but at the same time it has also a connection from Peripheral port to the bus-matrix; so if the peripheral address of given stream is outside of the APB2 address range but inside of any other memory or peripheral's range, that access will be steared towards the busmatrix, rather than to APB2.

The practical consequence of this fact is, that only DMA2 can perform Memory-to-Memory transfers. Those are transfers, which not only move data from one memory to another (or any other busmatrix slave, including APB1-through-AHB1, and AHB2); but they are also not triggered (requested) by any peripheral, once a stream set to M2M transfer is enabled, it will move data autonomously at a pace given by arbitration within the DMA unit itself and at its ports, until completion.

However, DMA2 allows also another practical transfers: it allows to move data from/to memory to/from GPIO. Here, normally transfers are required to be performed at some regular pace, rather than at the highest possible (and often irregular, given conflicts on buses from other busmasters, e.g. the processor) rate. As triggers (requests) are hardwired from peripherals to DMAs ('F2/'F4/'F7 predate the era of DMAMUX) and the only practically usable request source are timers, in 'F2/'F4, only TIM1 and TIM8 can be used to trigger this sort of transfers. On the other hand, using capture as source of DMA trigger, GPIO-to/from-memory transfers can be accomplished upon external signals, too. Such process is described in AN4666.

There's no way to use DMA1 for this sort of transfer, as it not only does not have connection from its Peripheral port to the busmatrix, but also the connection it has from Memory port to bus matrix does not connect to AHB2, where GPIO ports are located.

'F4 bus matrix diagram, showing routes from GPIO/AHB2 to the two DMA units

Formally, either DMA2 port can be used for the GPIO (and the remaining one for memory). As the trigger(request) always triggers the Peripheral-port-side transfer, it is logical to use Peripheral port for GPIO, where timing usually matters the most.

Of course, this sort of transfer is not constrained to GPIO. An interesting usage is a timer-paced USART or SPI Tx, where the timer (potentially together with other timers, through their internal interconnections) can generate automatic framing/latching signals.