I want to connect a keyboard on the USB-A, populated on the breakout board.
So, I know this:
USB-A is available: it is a USB-FS (compared to USB-HS already in use for USB-C) - OK
so, no problem: MCU has USB-HS and USB-FS peripheral pins, so, creating a USB Host HID
in order to connect a keyboard on second USB (with breakout board as USB-A USB-FS)
can potentially work (based on MCU features)
But I am confused: it cannot work!
Before I have started to write any code (e.g. to initialize USB-FS as Host and HID) - I've just checked the schematics:
There is NOT any power provided as VBUS on this USB-A connector
How should my keyboard be powered if no power is provided on USB-A?
So, it looks like:
the USB-A on breakout board is just useful in order to:
use BOOT option and STM bootloader in order to flash FW from a host (PC) master
or to use the USB-A as a Device - but not as a Master (which means to provide also power)
Why the design team has decided to go this path?
OK, maybe to avoid that Portenta H7 would not be able to provide so much power that external USB devices can be connected, on USB-A acting as master and proving also 500 mA
power when it draws already 400 mA via USB-C itself (1A via the board in total required to do so).
But it means also: any USB memory stick on USB-A will not work (no power, also Portenta H7 as a MSC master will NOT provide power).
What a HW design? ("rrrrr")
Can we solve it? (e.g. by bring power to VBUS pin, but how to wire a tiny wire from where to where?). Do we need an external power supply in order to let act the Portenta H7 also as a USB Master? (and provide also 500 mA power on USB-A whereby the board itself drains 400 mA from USB-C itself ...)
Upps, I take it back:
There is U1 as voltage regulator, plus PG3 (GPIO 5) as USBA_VBUS_EN, PD4 (GPIO 3) as USBA_VBUS_FLAG.
It needs at least one jumper on J12 (GPIO 5) to enable power on USB_A.
These jumpers are on the header with the TRACE signals, next to the debugger header.
The USB-A (on main board) is not initialized, not used, when you do not have any code for it in your project.
The USB-A works only with the bootloader.
I want to use this USB-A as a HID device (for a keyboard). So, I have to initialize the FS USB, provide a Host implementation for HID (still in process to do).
When you want to have USB-A as a UART device (VCP), you had to initialize the MCU FS USB as Device with VCP (MSC) enumeration (descriptors and driver). It has to be part of your project.
There might be some examples in Arduino mbed repository (but I use native STM32 HAL drivers, not Arduino).
Do you need a second VCP (USB UART)?
The USB-C connector provides it already.
Not my intention to use USB-A for VCP UART. But do you need example how to do?
(maybe I try for fun...)
I would prefer to use this USB-A as Memory Stick or as keyboard (as I would need, in addition to use USB-C for display out).
Or: USB-A as USB to host PC to access the SD card (might make sense, even I have TFTP working to access Portenta H7 SD card) - see the Portenta H7 SD Card like an external memory stick (and transfer files).
Or: audio (I2S) via USB-A... (like a sound card)
VCP UART is not my main focus: already there and network access works fine, even like a "TELNET" session.
What do you want to do with this (second) USB connection (via USB-A and FS)?
Because I thought the USB-A works the same as the main USB-C port so when we designed the PCB we designed the serial comms via the USB-A. Do you have any example codes that can initialise the USB-A as a serial port? We can re-design and re-make the PCB to use the USB-C but it would be nice if we can use the USB-A.
When I browse my Arduino repository...
There is a file "Serial.cpp"
It has a macro to be defined as "SERIAL_CDC".
It uses then "USB/PluggableUSBSerial.h"
I would assume, it does what you want to get: VCP UART via USB-A. But not sure.
As I know: the VCP via USB-C is already the standard UART via USB-C ("Serial").
So, I assume, this SERIAL_CDC is a second UART via "PluggableUSB", using USB-A (and MCU USB FS)
There is also a folder "USB" in it, with some files like "USBCDC.cpp" and "USBSerial.cpp" : no idea which file is for what.
I assume: there is a VCP UART on USB-A, when you initialize properly.
BTW:
To make life easier: the Portenta H7 provides also UART1 TX and UART1 RX, on D14, D13: you could initialize UART1 (as a regular UART) and connect an external tiny board as USB-to-UART (e.g. via a SiliconLabs CP210x chip) :
this one: CP210x USB-UART-Module