Buffered serial hangs my application

Hello all, I am having and issue regarding the stdio configuration in a custom target using STM32F091VC.
My printf(“Hello World!\r\n”) hangs if I config “platform.stdio-buffered-serial”: 1 in mbed_app.json, but works when I dissable it, “platform.stdio-buffered-serial”: 0.

This is my mbed_app.json:

{
    "target_overrides": {
      "*": {                      
        "platform.stdio-baud-rate": 115200,
        "platform.stdio-buffered-serial": 0, 
        "target.printf_lib": "std"
      }
    }
}

Any idea?

Thank you very much

Hello,

“platform.stdio-buffered-serial”: 1 = BufferedSerial is used for printf
“platform.stdio-buffered-serial”: 0 = UnbufferedSerial is used for printf

So I believe when you will use BufferedSerial - API references and tutorials | Mbed OS 6 Documentation, then the program also hangs.

I do not know what differences are between F091RC and F091VC, but when BufferedSerial is not working then it could be about IRQ settings or Memory settings I think. Hard to say, just from this.

If you have NUCLEO_F091RC, then you can verified if the behavior is also on regular target.

BR, Jan

Thank you Jan, I will manage to get that board and give it a try.

I remembered that I use it in MbedCE like default settings without an issue, so I did some tests.

I do not know what tool you used, but the issue has something together with KeilStudioCloud probably.

  • MbedStudio - always OK
  • KeilStudioCloud - issue is there and MbedOS version has no impact

BR, Jan

Hello, I haved tested it using Mbed Studio GCC-ARM and Mbed-CE using CLion and the results are the same, let see what happens with the nucleo as soon it arrives.
Thank you.

looks like you are experiencing an issue with the stdio configuration in a custom target using STM32F091VC. When you set the “platform.stdio-buffered-serial” to 1 in mbed_app.json, the printf(“Hello World!\r\n”) hangs, but it works when you disable it and set “platform.stdio-buffered-serial” to 0.

One possible reason for this issue could be that the buffer size allocated for the serial port may not be enough to hold the entire message “Hello World!\r\n”. When “platform.stdio-buffered-serial” is set to 1, it enables buffered I/O for serial output, which can cause this issue if the buffer size is too small.

You can try increasing the buffer size allocated for the serial port by setting “platform.stdio-buffer-size”: in mbed_app.json, where is the size of the buffer in bytes. This might help resolve the issue.

Alternatively, you can also try using a different printf library instead of “std” by setting “target.printf_lib” to the appropriate library for your target, as some libraries may handle buffered I/O differently.

I hope this helps you resolve the issue.

Hello,

from where this information come from?

BR, Jan

I do research and found .

I did not ask about what you do, but about a source of this information. It must be somewhere here on Mbed web. So, be so kind and please, share your source, thank you.

BR, Jan

i work and check from chat gpt

That is very funny :slight_smile:
After I placed the settings, suggedsted by you and your GPT friend, into mbed_app.json, then the Mbed compiler throws an error

Attempt to override undefined parameter 'platform.stdio-buffer-size' in 'application[*]'
Internal error.
Build failed

So that setting does not exist (Google also does not know this).
Correct settings are here and also with default values. That means, the buffer size is already set to 255.

So, how you can see, your suggestion is wrong and without any relevant sources.

BR, Jan

Hello all, I have tried with the NUCLEO-F091RC and works fine, to be honest I don´t think it is a matter of my custom target (F091VC) as in this case it is extremely easy as it is quite similar to the F091RC even both boards has 8Mhz crystal, so I will try to look at the serial_device.c and related code and debug to see where crashes.
Thank you to all of you.