nxp-mcuxpresso / mcux-sdk

MCUXpresso SDK
BSD 3-Clause "New" or "Revised" License
323 stars 142 forks source link

[BUG] Application freeze in DbgConsole_Flush when many bigger messages are sent #28

Closed Hadatko closed 2 years ago

Hadatko commented 3 years ago

Describe the bug Here is modified example for imx7ulp erpc_matrix_multiply_rpmsg_rtos_imxcm4.zip. Changes are in source/main_core1.c and cmake related files (flags for release target -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ -DPRINTF_ADVANCED_ENABLE=1 \ -DFILENAME='\"$(notdir $(abspath $<))\"' ) Zip file contains also release dir with built binaries. If few printf are removed from modification, program is working. But with all modification program will freeze.

To Reproduce image described above

Expected behavior To not freeze at printf function.

Screenshots and console output image

Hadatko commented 3 years ago

Without this modification -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING \ demo works. So combination usage of this macro and a many large prints usage result in app freeze.

Hadatko commented 3 years ago

I think putting DbgConsole_Flush after printf when this macro is used made it freezing too.

mcuxsusan commented 3 years ago

Hi @Hadatko, thank you for reporting the issue. To summarize the situation, do you mean that:

  1. The demo in package works fine.
  2. With modification of flags.cmake for release target, adding macro definition -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING -DPRINTF_ADVANCED_ENABLE=1 -DFILENAME='"$(notdir $(abspath $<))"' ), the application run to freeze.
  3. Without modification of -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING in flags.cmake, the demo works.

So, the key point may be: using -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING in flags.cmake makes the demo run to freeze. And when uses -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING, reduce use of printf or adding DbgConsole_Flush after printf both could improve the situation and demo works. Please help clarify if my understanding is correct. Appreciate for your energetic contribution. For your information, you could also follow the guide in https://github.com/NXPmicro/mcux-sdk/#overview to obtain the whole GitHub SDK distribution via zephyr west tool, then you could be able to also get the examples delivery in https://github.com/NXPmicro/mcux-sdk-examples/ and no need to MCUXpresso SDK package to reproduce your issue.

Hadatko commented 3 years ago

Hi @mcuxsusan , The main issue is combination of -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING and many printf function in main_core1.c. Using DbgConsole_Flush freezing too may be additional or same issue. Not sure, but in current state not important.

mcuxsusan commented 3 years ago

@lylezhu2014, may you please help comment on the situation?

Hadatko commented 2 years ago

Any news here?

mcuxsusan commented 2 years ago

Hi @Hadatko, thanks for your patience. @lylezhu2014, please help update your progress here.

lylezhu2014 commented 2 years ago

Hi Hadatko,

The PRINTF and DbgConsole_Flush should be called in task context. Because FreeRTOS resource is used by debug console.

Hadatko commented 2 years ago

Thank you very much. I moved more context into tasks and rest i removed. This is working well.