2013-03-18 04:32 AM
I have an STM32F4 based board, and I'd like to (for better or for worse) use the USB port as a console port to my board.
I've already modified the CDC (VCP) Full Speed example, and have RX, TX, and VBUS sensing working as I'd like. However, one problem with this approach is the USB bulk transfers from device to host are done via interrupt I/O. So, if I want to print Joseph Yui's famous hard fault handler, it's not gonna happen because the hard fault interrupt will always be a higher priority than the USB port's interrupt. So, what I'd like to do is modify the CDC (VCP) example to send data to the host using polling I/O, just like one would do if using the USART. I've spent the last couple of days studying the USB OTG Library code, but I just don't know enough about USB, and I'm wondering if this approach is completely incompatible with the USB protocol. Is this even possible? Do you know of a way to make this work? P.S. I realize there are other (better?) ways of making a console port with USARTs, Ethernet, 2nd Processor, etc..., but I want to explore this idea. #usb-vcp-cdc-hard-fault2013-03-18 04:56 AM
Your time might be better applied to adding checks into your code so it doesn't fault.
The issue is complicated, you have a system in a compromised situation, unless you can unwind some of that and get into a safe/known state, you're going to have additional problems. If I couldn't use a serial port, would probably try SWV