Skip to main content
Explorer II
August 6, 2024
Solved

STM32G0 USBCPD: Debug issue and hard reset of PE instead of negotiation

  • August 6, 2024
  • 2 replies
  • 3697 views

//EDIT: Please go to the my last reply since this represents the current state of the investigations

 

This is kind of a follow-up post, but a totally different topic than yesterday.

So, after following the video step by step for a USBCPD sink "project with a custom board" (video minute 13:04)

https://www.youtube.com/watch?v=cbdFHmMOMwk

I was successful is the sense that "STM32CubeMonitor for USB Type-C PD" does indeed recognise my custom board based on the STM32G0B1CBT6. I can connect and see that there is a explicit contract for a fixed 5V.

However, despite reading through different USBCPD related documents, I am not really sure which kind of functionality the demo / the full stack from ST provides and what is left to the user. For example: after connecting the CubeMonitor to the board, I am not able to send any Messages to the board or do any configuration. No matter which mesage I seelct from the "Message Selector" Tab or the "Port Communication", I always get "Message rejected for this port configuration". Not even the ping mesage is working. Is this to be expected? I somehow expected that the Messages that are exposed in the GUI and the settings that one can do in the "Port Communication/ Configuration" are already "built-into" the stack?

Thanks!

    This topic has been closed for replies.
    Best answer by Nicolas P.

    Hello @Franz.1 

    Nice to see some progress.

    Could you share the full trace as .cpd trace please ?

    The trace mechanism is very useful to help debugging, because the power delivery protocol has some timing constraints. And if you don't fulfill them, you could ger hard resets. That is why it is not recommended to put breakpoints in the code, but use trace instead.

    Looking quickly at your trace, IN (= incoming) messages are missing. It could be that the hard reset occurs, because there is no incoming message from the source that is supposed to tell which capabilities it has. We see in the trace that the state is "wait for capabilities", as you also noticed.

    Here you don't seem to have bidirectional communication. We don't reach the "explicit contract".

    Have you ever reached once the explicit contract ?

    2 replies

    Technical Moderator
    August 6, 2024

    Hi @Franz.1 

     

    Could you please check in predefined symbols are activated?

    _TRACE
    _GUI_INTERFACE

     

    Franz.1Author
    Explorer II
    August 6, 2024

    Hi @FBL ,

    Yes, it seems they are (see screenshot below from CubeIDE)

    Franz1_0-1722958746793.png

     

    Am I right that your answer suggests that the Messages exposed in the GUI should be already handled by the Example/Demo Firmware as setup in the mentioned tutorial?

    Thanks! 

    //Edit: I was not sure whether with “activated” you mean “just defined” as they are in the screenshot or also set to a value like “1”? But I tried both, did not make a difference.

    //EDIT2: At least (by scope) I can tell there is data on both the RX and TX lines of the LPUART when I try to send a Message from GUI to the board and the board seems to answer... generally the MonitorTool and/or stack seems incredibly unstable. I can as I said issue no messages beside of Soft Reset and hard Reset . Sometimes, but only sometimes and as a first action after board reset the "Get Status" Message at least blinks "green" in the Gui, but even then this only works once until I reset the board again. All other Messages are broken "all the time".

    ST Employee
    August 7, 2024

    Hello @Franz.1 

    An easy way to know if you have some code to write, is the keyword "ADVICE" in the trace, like in below example.

     

     

    793	DEBUG	5483	1	ADVICE: Update BSP_USBPD_PWR_SetRole

     

     

    Look for the function after the ADVICE in you code. You need to code there to fit your needs.

    Once your code has been filled, you can remove the ADVICE trace.
    Have a look on how these sections are completed in our examples.

    Messages can be rejected if what you request are not in line with the current status of the stack. For example, enter in some VDM modes, if discovery was not done previously.

    See also this thread.

    Can you share your .cpd file ?

    Regards,

    Nicolas

    Technical Moderator
    September 19, 2024

    Hi @Franz.1 

    Would you attach trace files in compressed format .7z for example?

    Edit /: I successfully read traces
    Would share your schematics? Do you use CC line protection circuit?

    Could you implement logging in the firmware to monitor the source to ensure it reacts correctly to hard reset message?


    Edit/2: According to section 4.2.4 Hard reset in UM2552 , it seems your source is ignoring hard reset: something is going wrong with your source. Could you provide more information about your source? 

    ST Employee
    September 20, 2024

    Hi @Franz.1 ,

    from the last comment I gave end of August, I see no news. Hard reset seems not seen by the Source.

    In the "2024_08_26_13_06_08_USBCPD_Debug_target_reset.hex" trace we see a detach at the very end, after the HR. Are you reseting the MCU again at that time ?

    As @FBL said : do you have CC line protections in place ? What is your PD source model/brand ?

    Regards,

    Nicolas

    Franz.1Author
    Explorer II
    September 28, 2024

     

    Hi @Nicolas P.  and @FBL 

    Sorry for the late reply! Actually, I did not notice that you edited the post while I waited for an anwer ;)

    Good news is: After some more investigations, it seems that i solved the problem (hope this is really the case) and that the USB PD stack was not the cause of the "second" reset but some other FW related side effect - I highly appreciated your help and wanted to thank you both for your comments and the support throughout this thread!

     

    One last and (more or less) related question to that topic; What is the reason that in CubeMX GUI, I can select fixed voltage PDOs for 5V, 9V, 15V and 20V, but not 12V? That voltage is missing in the predefined options of the GUI. What is the reason for that?

    Thanks and all the Best!