🛠 USB OTG FS et SDIO réels : les périphériques cachés derrière les en-têtes morpho
Goals
Understand the two most misleading "features" of the Nucleo-F401RE: the board's micro-USB socket is not the MCU's USB, and the MCU's real USB 2.0 OTG FS and SDIO peripherals are only reachable on the ST morpho headers. Then plan actual wiring for both.
The trap
The board USB connector (micro-B, full-speed) is wired to the ST-LINK/V2-1 host adapter, which enumerates as SWD debugger + virtual COM port + USB mass-storage device. The STM32F401RE's USB 2.0 OTG FS pins are broken out on the morpho headers, not routed to the board connector. So Serial works with zéro USB knowledge — and any sketch that wants the MCU itself to be a USB device needs external wiring.
What the silicon actually has (Zephyr board doc)
USB 2.0 OTG FS (device/host), SDIO, DMA controller, 4× SPI, 3× I2C, 3× USART/UART, I2S, 12-bit ADC with 16 channels, RTC, 1 advanced + 7 general-purpose timers, 2 watchdogs.
Steps — OTG FS on the morpho
- Identify the OTG FS pins (DM/DP) for the F401RE on the morpho headers. >
- Wire a USB female connector: DM/DP with short traces and series resistors, VBUS from your own 5 V source (the board connector's VBUS feeds the ST-LINK side), grounds tied.
- In CubeMX enable USB_OTG_FS in device mode (e.g. the CDC class) and generate:
/* CubeMX-style skeleton: the MCU becomes the USB device */
void MX_USB_DEVICE_Init(void)
{
hpcd_USB_OTG_FS.Instance = USB_OTG_FS; /* pins live on the morpho headers */
HAL_PCD_Init(&hpcd_USB_OTG_FS);
USBD_Init(&hUsbDeviceFS, &FS_Desc, DEVICE_FS);
USBD_RegisterClass(&hUsbDeviceFS, &USBD_CDC);
USBD_Start(&hUsbDeviceFS);
}
Steps — SDIO
- Wire an SD socket to the SDIO pins (CMD, CLK, D0–D3) in the 3.3 V domain — VDD range is 1.7–3.6 V, no 5 V.
- Start from the SDIO example projects under
Projects/STM32F401RE-Nucleoin STM32CubeF4 — GPIO, ADC, USART, USB and SDIO examples for this exact board are maintained by ST. - Stream with the on-chip DMA controller so the 84 MHz Cortex-M4F stays free while blocks move to the card.
Expected result
A CDC device that appears because the MCU is the USB device — not the ST-LINK — and an SD card logging at SDIO speeds without bit-banging. Both coexist with the ST-LINK's own COM port: one design, two serial ports, zéro confusion once the two USB worlds are separated in your head.
Common mistakes
- Plugging the board connector into your USB device project and seeing only the ST-LINK COM port.
- Powering VBUS from the PC while also feeding the board externally — mind the power-selection jumpers (USB VBUS or 3.3 V / 5 V / 7–12 V external).
- Bit-banging USB or SD when the silicon has native controllers.
- Ignoring that the same F401 silicon ships on Black Pill boards (STM32F401CC) with OTG FS wired to a real connector — techniques port 1:1 if you would rather buy than solder.
Autres tutoriels pour cette carte
- Prise en main de la Nucleo-F401RE : ST-LINK, LED LD2 et alimentation
- Premier Blink Arduino sur la Nucleo-F401RE avec le core STM32duino
- Console série sur le ST-LINK VCP : printf, ADC 12 bits et piège du USB
- STM32CubeF4 et HAL : blink + UART printf générés pour la Nucleo-F401RE
- ADC 12 bits et PWM sur la Nucleo-F401RE : oversampling, millivolts et LED en fondu
- Zephyr RTOS sur la Nucleo-F401RE : west build, devicetree et west flash