RP2350 FreeRTOS - usb stdio printf() doesn't work (but usb works fine) if tinyusb is locked to core 1 #2803
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk#2803
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This is a weird one.
tinyusb is set up to be device-only and present two CDC interfaces. The first one is the usual stdio related stuff, and the second one just prints out the messages received over the queue.
If I do not set the core affinity of
tud_taskit works as expected. However if I do set it, or set it and then set it back to the default (no affinity) then usb still works great, I still see the messages on the second CDC interface, but none of the printf() messages come out. I'm certain that FreeRTOS is working since if it wasn't, or iftud_taskwas hanging or otherwise misbehaving then I would not have either CDC interface (and the queue system wouldn't be working either.I've played with
configRUN_MULTIPLE_PRIORITIESwithout any change, and if I setconfigTASK_DEFAULT_CORE_AFFINITYso both tasks run on the same core, printf/stdio is still broken. In my actual codebase I have a few more tasks and they are all running fine, as are the FreeRTOS timers and so on... it feels like the stdio system or maybe something deeper in tinyusb is making an assumption about the system that it shouldn't be.Bit of an update.
vTaskCoreAffinitySet(), leaveconfigTASK_DEFAULT_CORE_AFFINITYto default (tskNO_AFFINITY) - works finevTaskCoreAffinitySet(), but setconfigTASK_DEFAULT_CORE_AFFINITYto (1 << 0) - works fine (everything runs on core 0)vTaskCoreAffinitySet(), but setconfigTASK_DEFAULT_CORE_AFFINITYto (1 << 1) - broken behaviour (everything runs on core 1)It looks like the stdio library (or something in tinyusb) does not like core 1.
Another interesting datapoint -- it appears to be something going sideways during initialization. If I move
tud_init(0)andstdio_init_all()to the code running on core 0, I can still pintud_threadto core1 andprintf()and friends work as expected.e.g.
works without issue even though
tud_task()is running on core1.could you maybe attach the rest of the files, so it's quicker for me to reproduce
moving to 2.3.1 as the initialize from core 0 is a reasonable workaround
note, i wonder if you are using a release build, as there is an assertion about stdio_usb init being done from core 0 which you're probably supposed to be hitting