raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.26k stars 838 forks source link

No way to disable pico_stdio function wrapping, just pico_printf #1634

Open gemarcano opened 4 months ago

gemarcano commented 4 months ago

I have a personal project using tinyusb to expose a CDC device and an HID device. I wanted to reimplement the read, write, and open newlib syscalls, but looking through the source code of pico_stdio, I noticed that I would not be able to just copy their implementation, as stdio_get_until and stdio_put_string are static and thus private functions to the stdio.c source file. So I just reimplemented the syscalls using my own output routines... and started seeing my application crash, as printf and putchar were being wrapped by the pico-sdk and sending the input data through pico_stdio. pico_set_printf_implementation(${name} compiler) almost does what I want, but it only manages the functions defined in pico_printf, which excludes putchar. The current pico-sdk is missing something similar for pico_stdio.

I tried using SKIP_PICO_STDIO, but that completely avoids the entire library including includes, which blows up other dependencies of pico_stdlib.

I have a PR I'll place momentarily that does what I want by borrowing exactly what pico_printf does, requiring the use of a cmake property to change the default stdio library.