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

Closed
opened 2024-02-14 16:27:07 -06:00 by gemarcano · 1 comment
gemarcano commented 2024-02-14 16:27:07 -06:00 (Migrated from github.com)

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.

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.
kilograham commented 2024-08-09 15:13:33 -05:00 (Migrated from github.com)

You can now add PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS=0 to your compile options

You can now add `PICO_STDIO_SHORT_CIRCUIT_CLIB_FUNCS=0` to your compile options
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-raspberrypi/pico-sdk#1634
No description provided.