Debug Console using fsl_component_serial_port_usb

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Debug Console using fsl_component_serial_port_usb

1,188 Views
microcris
Contributor III

Hello!

 

As stated in the subject, I'm using the USB virtual com to output the debug console contents. And it works almost great.

It is almost because, when there is no open serial terminal session, the task that is using the PRINTF function will be stuck in here:

 

 

#if ((SDK_DEBUGCONSOLE > 0U) ||                                                   \
     ((SDK_DEBUGCONSOLE == 0U) && defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING) && \
      (defined(DEBUG_CONSOLE_TX_RELIABLE_ENABLE) && (DEBUG_CONSOLE_TX_RELIABLE_ENABLE > 0U))))
DEBUG_CONSOLE_FUNCTION_PREFIX status_t DbgConsole_Flush(void)
{
#if defined(DEBUG_CONSOLE_TRANSFER_NON_BLOCKING)

#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_BM) && defined(OSA_USED)

    if (s_debugConsoleState.writeRingBuffer.ringHead != s_debugConsoleState.writeRingBuffer.ringTail)
    {
        return (status_t)kStatus_Fail;
    }

#else

    while (s_debugConsoleState.writeRingBuffer.ringHead != s_debugConsoleState.writeRingBuffer.ringTail)
    {
#if (DEBUG_CONSOLE_SYNCHRONIZATION_MODE == DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS)
        if (0U == IS_RUNNING_IN_ISR())
        {
            if (taskSCHEDULER_RUNNING == xTaskGetSchedulerState())
            {
                vTaskDelay(1);
            }
        }
        else
        {
            return (status_t)kStatus_Fail;
        }
#endif
    }

#endif

#endif
    return (status_t)kStatus_Success;
}
#endif

 

 

until a new serial terminal session is open.

As a workaround I have set the DEBUG_CONSOLE_TX_RELIABLE_ENABLE symbol to 0 and the task that is using PRINTF is working correctly when there is no serial terminal session open.

 

My question is:
Is it the normal behaviour (PRINTF function to be forever waiting in the DbgConsole_Flush function until a new serial terminal session is available)?

My project symbols:

 

 

<name>CPU_MIMXRT1064DVL6A</name><value/>
</macro>
<macro>
<name>FSL_RTOS_FREE_RTOS</name><value/>
</macro>
<macro>
<name>XIP_EXTERNAL_FLASH</name><value>1</value>
</macro>
<macro>
<name>USB_DEVICE_CONFIG_CDC_ACM</name><value>1</value>
</macro>
<macro>
<name>DEBUG_CONSOLE_TRANSFER_NON_BLOCKING</name><value/>
</macro>
<macro>
<name>BOARD_USE_VIRTUALCOM</name><value>1</value>
</macro>
<macro>
<name>SERIAL_PORT_TYPE_USBCDC</name><value>1</value>
</macro>
<macro>
<name>PRINTF_FLOAT_ENABLE</name><value>1</value>
</macro>
<macro>
<name>XIP_BOOT_HEADER_ENABLE</name><value>0</value>
</macro>
<macro>
<name>DEBUG_CONSOLE_TX_RELIABLE_ENABLE</name><value>0</value>
</macro>

 

 

 

Labels (1)
0 Kudos
3 Replies

1,175 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,
Thank you for your interest in NXP Semiconductor products and for the opportunity to serve you.
I was wondering if you can describe the demo project you used, in addition, what's the version of the SDK library?
Looking forward to your reply.
Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,172 Views
microcris
Contributor III

Hello!

Thank you for your reply

My project is a mix between "evkmimxrt1064_freertos_hello" and "evkmimxrt1064_hello_world_virtual_com"

But you can check with "evkmimxrt1064_hello_world_virtual_com" it also happens there. You can configure a blinking led, print something from time to time (let us say 100ms) and after some time (I'm assuming that is when the ring buffer gets full) the led will stop to blink (of course that it is with the USB cable unplugged or with no serial terminal open). Then, if you pause the debugger, you will see the program was waiting inside the while loop that is in "DbgConsole_Flush" funcion. 

SDK version 2.9.2 and earlier versions (at least 2.8.6)

 

 

0 Kudos

1,151 Views
jeremyzhou
NXP Employee
NXP Employee

Hi,

Sorry for reply late.
I run the evkmimxrt1064_freertos_hello for test and I find that the code will stuck at DbgConsole_ReadOneCharacter(uint8_t *ch) function instead of DbgConsole_Flush(void) fucntion, as the below figure shows.

jeremyzhou_0-1622012613655.png


Have a great day,
TIC

-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos