On further inspection, probably just changing the define from STM32F407VG to STM32F401xE would fix the problem, at least for me.
I'd suggest using the massive define in lines 71-73 straight from mbed/TARGET_NUCLEO_F401RE/stm32f4xx.h
snippet from stm32f4xx.h
/** @addtogroup Library_configuration_section
64 * @{
65 */
66
67 /* Uncomment the line below according to the target STM32 device used in your
68 application
69 */
70
71 #if !defined (STM32F405xx) && !defined (STM32F415xx) && !defined (STM32F407xx) && !defined (STM32F417xx) && \
72 !defined (STM32F427xx) && !defined (STM32F437xx) && !defined (STM32F429xx) && !defined (STM32F439xx) && \
73 !defined (STM32F401xC) && !defined (STM32F401xE) && !defined (STM32F411xE)
74 /* #define STM32F405xx */ /*!< STM32F405RG, STM32F405VG and STM32F405ZG Devices */
75 /* #define STM32F415xx */ /*!< STM32F415RG, STM32F415VG and STM32F415ZG Devices */
76 /* #define STM32F407xx */ /*!< STM32F407VG, STM32F407VE, STM32F407ZG, STM32F407ZE, STM32F407IG and STM32F407IE Devices */
77 /* #define STM32F417xx */ /*!< STM32F417VG, STM32F417VE, STM32F417ZG, STM32F417ZE, STM32F417IG and STM32F417IE Devices */
78 /* #define STM32F427xx */ /*!< STM32F427VG, STM32F427VI, STM32F427ZG, STM32F427ZI, STM32F427IG and STM32F427II Devices */
79 /* #define STM32F437xx */ /*!< STM32F437VG, STM32F437VI, STM32F437ZG, STM32F437ZI, STM32F437IG and STM32F437II Devices */
80 /* #define STM32F429xx */ /*!< STM32F429VG, STM32F429VI, STM32F429ZG, STM32F429ZI, STM32F429BG, STM32F429BI, STM32F429NG,
81 STM32F439NI, STM32F429IG and STM32F429II Devices */
82 /* #define STM32F439xx */ /*!< STM32F439VG, STM32F439VI, STM32F439ZG, STM32F439ZI, STM32F439BG, STM32F439BI, STM32F439NG,
83 STM32F439NI, STM32F439IG and STM32F439II Devices */
84 /* #define STM32F401xC */ /*!< STM32F401CB, STM32F401CC, STM32F401RB, STM32F401RC, STM32F401VB and STM32F401VC Devices */
85 #define STM32F401xE /*!< STM32F401CD, STM32F401RD, STM32F401VD, STM32F401CE, STM32F401RE and STM32F401VE Devices */
86 /* #define STM32F411xE */ /*!< STM32F411CD, STM32F411RD, STM32F411VD, STM32F411CE, STM32F411RE and STM32F411VE Devices */
87 #endif
On further inspection, probably just changing the define from STM32F407VG to STM32F401xE would fix the problem, at least for me. I'd suggest using the massive define in lines 71-73 straight from mbed/TARGET_NUCLEO_F401RE/stm32f4xx.h
snippet from stm32f4xx.h