-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serial USB not working on STM32u575 #339
Comments
USB support for STM32U5 was not available in the official Mbed OS. |
Is there a plan to create a merge request for adding those feature in the mbed-os master branch? I think this is a common use case. Later I also want to use the same usb connection for firmware upgrades. If I can get it working maybe we can create a branch for it? |
And is there a way to use this virtual com port as the default uart (std::printf)? |
Yes, it is but you have to use an app with auto control of DTR signal. https://forums.mbed.com/t/hitchhikers-guide-to-printf-in-mbed-6/12492/1 |
I'm still struggeling with the error |
Yes, you should link your application to the mbed-usb library: target_link_libraries(mbed-app mbed-os mbed-usb) |
Wow this looks better. Is there a reason that you need to link only this library and not others for SPI, IIC, storage, etc?
|
In general it is not a part of MbedOS core but it is an Mbed library - https://github.com/mbed-ce/mbed-os/wiki/MbedOS-configuration#mbed-libraries. |
I created a branch for testing. After some small modifications in the clock settings file it's already working but there is:
|
It is VCP so the baudrate should be changed only on PC side. |
Ah ok. I also see that the firnware is blocking until you open a terminal. I was searching on the internet for better examples how to dynamically load/unload the driver when connecting the cable, but examples are very poor. In the real world, the user will connect the USB cable and must see the logging information without resetting the device. Is there any example how you can connect when cable is attached/detached without blocking the firmware? |
My colleague used it like this
|
Looks nice. I will test this. In my case, the printf should be 'routed' to the usb (for debug in the field) and other serial port is used for commands (application board connector). I wil also check for a way to upload the FW trough the same usb cable without using a programmer. Do you suggest one of the upload methods described on mbed ce (like using cube programmer) or can I use the 'default' bootloader from ST and use a dedicated tool like you have with an arduino board? |
I understand, and i believe you can achieve that via combination of the code above and the method mentioned in topic what i posted few post above via. mbed-os/platform/include/platform/mbed_retarget.h Lines 124 to 140 in 5354079
|
I will check it in detail tomorrow. Thanks for all this useful information. |
I couldn't resist to check this, seems to need the following setting in the USBPhy_STM32.cpp under USE_USB_OTG_FS:
|
Because the USB is automatically connecting when I enable vbus sensing with resistor divider I don't need the connect call.
However I was searching for a way to give a welcome text as soon as the terminal is connected, because you cannot connect the terminal first and startup the board secondly like you can do with a hardware serial port. Because it's USB the terminal connection breaks after each reset. I tried something like this in the MyConsole class, but this is doing nothing:
Alternatively I could create a new thread and wait for connected(). Secondly, to create a firmware upload method over usb, how do you see that? Is it creating a virtual drive where you copy paste the hex file like you have with nucleo boards? Or is it a protocol? Or do you expose the sd card as a drive? Is there any example of this or are there some more hints? |
Yeah, that is strange but I am not USB expert so I am not able say what is wrong. However my logic says this is not normal. About Bootloader: Maybe some points from discussing about - ARMmbed#15156 About transfer and storage of binary: |
This is working in my case:
I did also some tests with available(), but the strange thing is that if you don't use _getc() the number always stays at 1. If you fastly type characters and to _getc() in a loop then the number increases and decreases by one after each _getc(). It looks like this counter is not 'the buffer' but maybe something that is filled after you do _getc() and new characters arrive. Because this is fuzzy, unclear, not specified and may be buggy I don't use it. For the FW update let me further investigate. |
Is there any option to forward crash info also to that virtual serial port? |
I started some tests with the serial USB (OTG) on the STM32u575 to get a virtual com port on a Windows PC.
After fixing some issues with the clock config file (because it was never used and tested before), I have the following situation:
In main.cpp I include the driver:
And I always get:
/home/sam/git/hmipanel/source/main.cpp:10:10: fatal error: USBSerial.h: No such file or directory
In the custom targets file I use:
I'm not sure if I have to add also something in the "components" section?
Is this anywhere described?
I also tried to add this in the mbed_app.json:
But in that case I get:
The text was updated successfully, but these errors were encountered: