Arduino_Core_STM32 icon indicating copy to clipboard operation
Arduino_Core_STM32 copied to clipboard

Mixing core_debug and Serial printing results in slowdown and lost output

Open matthijskooijman opened this issue 2 years ago • 4 comments

Describe the bug When using both core_debug() and Serial.println() for writing to the serial port, some conflict occurs. Serial output becomes slow, and core_debug() output gets lost.

To Reproduce

$ cat STM32SerialAndVcoreDebug.ino 
#include <core_debug.h>

void setup() {
        Serial.begin(115200);
        Serial.println("0123456789");
        core_debug("FOOBARBAZ");
}

void loop() {
}

Compiled with:

$ arduino-cli compile -v --warnings all --upload --fqbn STMicroelectronics-git:stm32:Nucleo_64:pnum=NUCLEO_WL55JC1,dbg=enable_log,opt=ogstd,upload_method=swdMethod

This results in:

Peek 2022-08-10 16-05

Expected behavior Both messages should be printed directly.

Environment:

  • OS: Linux
  • Arduino IDE version: arduino-cli git 2dd8976683f4a9f83fcee478620f1e83d11111b2 (0.25.1 with a few more commits)
  • STM32 core version: git e3808a29a49aeb57129d4a299d428850496e19f9 (2.3.0 with a bit more commits)
  • Board & settings: STMicroelectronics:stm32:Nucleo_64:pnum=NUCLEO_WL55JC1,dbg=enable_log,opt=ogstd,upload_method=swdMethod

matthijskooijman avatar Aug 10 '22 14:08 matthijskooijman

I am not so surprised as we mix Serial which make use of U(S)ART in Interrupt mode and core_debug which use U(S)ART in Polling mode. Not sure we tackled this competitive access to U(S)ART.

ABOSTM avatar Aug 11 '22 14:08 ABOSTM

Hm, would be good if this would work, since otherwise it is a lot harder for sketches to use the core_debug() logging features provided some libraries...

matthijskooijman avatar Aug 11 '22 15:08 matthijskooijman

By default core debug use the same uart than Serial but it is possible to use an other one.

fpistm avatar Aug 11 '22 16:08 fpistm

Hi @matthijskooijman I've made a PR with a fix. for this issue. Could you test it and give us a feedback, please? Don't forget to remove your patch 😉

fpistm avatar Sep 08 '22 15:09 fpistm