Hi. This post is rather a problem report. CubeMX for the mentioned processor (and probably for the family of which the processor is a member) does not generate RCC clock initialization for EXT0:
I think that the problem is that the other processors (like STM32F1...) do have a bit
RCC_APB2ENR_AFIOEN inside register RCC->APB2ENR to enable the EXT module and STM32F407 does not. Hope that it will be fixed in one of the next versions of CubeMX.