Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mixing core_debug and Serial printing results in slowdown and lost output #1789

Closed
matthijskooijman opened this issue Aug 10, 2022 · 4 comments · Fixed by #1826
Closed

Mixing core_debug and Serial printing results in slowdown and lost output #1789

matthijskooijman opened this issue Aug 10, 2022 · 4 comments · Fixed by #1826
Assignees
Labels
Milestone

Comments

@matthijskooijman
Copy link
Contributor

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 e3808a2 (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
@ABOSTM
Copy link
Contributor

ABOSTM commented Aug 11, 2022

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.

@matthijskooijman
Copy link
Contributor Author

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...

@fpistm
Copy link
Member

fpistm commented Aug 11, 2022

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

@fpistm fpistm added this to To do in STM32 core based on ST HAL via automation Aug 23, 2022
matthijskooijman added a commit to stm32duino/STM32LoRaWAN that referenced this issue Sep 6, 2022
The workaround is not perfect, but makes debug output reasonbly
workable. See See stm32duino/Arduino_Core_STM32#1789
@fpistm fpistm self-assigned this Sep 8, 2022
@fpistm fpistm added the Bug 🐛 label Sep 8, 2022
@fpistm fpistm added this to the 2.4.0 milestone Sep 8, 2022
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 8, 2022
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
@fpistm
Copy link
Member

fpistm commented Sep 8, 2022

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 fpistm moved this from To do to In progress in STM32 core based on ST HAL Sep 12, 2022
matthijskooijman added a commit to stm32duino/STM32LoRaWAN that referenced this issue Sep 12, 2022
The workaround is not perfect, but makes debug output reasonbly
workable. See See stm32duino/Arduino_Core_STM32#1789
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 21, 2022
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 22, 2022
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.
Moreover, it avoid to disable the U(S)ART IRQ which prevent to
receive data.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 22, 2022
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.
Moreover, it avoid to disable the U(S)ART IRQ which prevent to
receive data.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
fpistm added a commit to fpistm/Arduino_Core_STM32 that referenced this issue Sep 23, 2022
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.
Moreover, it avoid to disable the U(S)ART IRQ which prevent to
receive data.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
STM32 core based on ST HAL automation moved this from In progress to Done Sep 26, 2022
cparata pushed a commit to cparata/Arduino_Core_STM32 that referenced this issue Jan 31, 2023
Like state is ready not need to loop on the blocking
HAL_UART_Transmit(). If not ok it can be HAL_ERROR or HAL_TIMEOUT.
Moreover, it avoid to disable the U(S)ART IRQ which prevent to
receive data.

Fixes stm32duino#1789

Signed-off-by: Frederic Pillon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

3 participants