Hi all,
Quite basic question but the answer eludes me. How to sanely use FreeRTOS with the TinyUSB that is shipped with
pico-sdk?
So
pico-sdk contains TinyUSB as part of its distribution. If you clone
pico-sdk, you will find it under
pico-sdk\lib\tinyusb.
However, here's the catch: If we look in
pico-sdk\lib\tinyusb\hw\bsp\rp2040\family.cmake (note it is a git submodule), which is the file that specifies compilation options for the RP2040 MCU, we find that
CFG_TUSB_OS is hardcoded to
OPT_OS_PICO:
target_compile_definitions(tinyusb_common_base INTERFACE
CFG_TUSB_MCU=OPT_MCU_RP2040
CFG_TUSB_OS=OPT_OS_PICO
#CFG_TUSB_DEBUG=${TINYUSB_DEBUG_LEVEL}
)
Which is fine for all normal purposes. However, I'd like to use FreeRTOS in my app, and consequently (atleast, it would seem to me) that I need to set this to be
OPT_OS_FREERTOS in place of
OPT_OS_PICO. Unfortunately, it does not seem to be a configurable option (for the time being I can ofcourse change it directly in the sdk source code.)
Now what I *could* do instead is supply my own
tusb_config.h file, and override
CFG_TUSB_OS in there instead. I can confirm that the compiler picks up my header file, because I see lots of warnings like
warning: "CFG_TUSB_OS" redefined
46 | #define CFG_TUSB_OS OPT_OS_FREERTOS
|
Which is "good" since it implies it's picking up my option (but also not good because it's clearly not the right way to go about it!)
However the build fails, I think because it picks it up my header file "too late" so to speak. I get
unknown type name and
implicit declaration of function errors, which suggests that some object files are being compiled with
OPT_OS_PICO while others with
OPT_OS_FREERTOS, and consequently some C files are trying to use symbols which haven't been compiled.
I want to know, what is the "correct" way of doing what I'm trying to do? Obviously its trivial to modify the SDK directly, but I really don't want to drag a slightly-custom
pico-sdk together with my project.
I seem to have some kind of faint memory of seeing FreeRTOS <-> "Pico OS" interop, atleast as far as the various synchronization primitives go, which would mean that what I'm trying to do is completely needless. But I can't remember where I got this impression from.