Closed leondisctech closed 4 hours ago
I've stumbled upon this too. It looks like I need to add more include directories because there are two such files:
sakhnik@pangea /u/s/pico-sdk [1]> find -name runtime_init.h
./src/rp2_common/pico_runtime_init/include/pico/runtime_init.h
./src/host/pico_runtime/include/pico/runtime_init.h
But I wonder what's the official way to configure the build system?
The include directories should be correct by default, so there is something else messed up with your build environment(s)
can you post CMakeLists.txt
Sure. k40-rpi-pico.zip I'm trying to build example from the the article: https://embeddedcomputing.com/technology/open-source/linux-freertos-related/using-freertos-with-the-raspberry-pi-pico, but with FetchContent.
Hmm, can you try with https://github.com/raspberrypi/FreeRTOS-Kernel instead (the upstream does not have latest fixes or SDK 2.0.0 related changes, but i wasn't aware it was broken with SDK 2.0.0)
Unfortunately, still the same error.
Even if I manually specify the include path include_directories($ENV{PICO_SDK_PATH}/src/host/pico_runtime/include)
, there are still compilation errors.
Even if I manually specify the include path include_directories($ENV{PICO_SDK_PATH}/src/host/pico_runtime/include),
yeah, i mean that shouldn't be the fix
Oh, well, yeah.. not sure where people came up with that method of pulling in FreeRTOS_Kernel
You should use FreeRTOS_Kernel_Import.cmake (like pico-sdk-import)
Here's my CmakeLists.txt
(library and directory names changed for privacy):
cmake_minimum_required(VERSION 3.20...3.27)
# initialize pico-sdk from submodule
# note: this must happen before project()
include(pico-sdk/pico_sdk_init.cmake)
project(my_project)
set(CMAKE_CXX_STANDARD 23)
# initialize the Raspberry Pi Pico SDK
pico_sdk_init()
# gcc spits about a bunch of inactionable ABI warnings about strings. no-psabi supresses them.
add_compile_options(-Wno-psabi)
add_subdirectory(dir1)
add_subdirectory(dir2)
add_subdirectory(dir3)
add_subdirectory(dir4)
add_executable(main
main.cpp
other.cpp
)
# Add pico_stdlib library which aggregates commonly used features
target_link_libraries(main
lib1
lib2
lib3
lib4
lib5
lib6
lib7
lib8
lib9
lib10
lib11
pico_stdlib
lib12
)
# enable usb output, enable uart output
pico_enable_stdio_usb(main 1)
pico_enable_stdio_uart(main 1)
# create map/bin/hex/uf2 file in addition to ELF.
pico_add_extra_outputs(main)
And just to reiterate: the above CMakeLists works with SDK 1.5.1 but not with 2.0.0. If I upgrade to 2.0.0, it doesn't work. If I downgrade back to 1.5.1, it works. I can't share the whole codebase, but I can try to cook up something that I can share (closer to a minimal working example).
@kilograham Here's an example of the problem. It compiles with SDK 1.5.1 but not with 2.0.0. The failure with SDK 2.0.0 is the same as the one above
/Users/me/sdk_problem/pico-sdk/src/common/pico_sync/mutex.c:9:10: fatal error: pico/runtime_init.h: No such file or directory
9 | #include "pico/runtime_init.h"
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
This probably isn't not a truly minimal working example; it's a pared down version of what I started with. I could try making a truly minimal example, but hopefully the example is close enough.
Same issue with this library we wrote here actually. Compilation works just fine under 1.5.1 but fails with the same error above in 2.0.0.
[ 1%] Building C object build/CMakeFiles/usb_desc.dir/src/usb_descriptors.c.obj
[ 1%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/dcd_rp2040.c.obj
[ 1%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040/rp2040_usb.c.obj
[ 1%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/device/usbd.c.obj
[ 2%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/device/usbd_control.c.obj
[ 2%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/audio/audio_device.c.obj
[ 2%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/cdc/cdc_device.c.obj
[ 3%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/dfu/dfu_device.c.obj
[ 3%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/dfu/dfu_rt_device.c.obj
[ 3%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/hid/hid_device.c.obj
[ 3%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/midi/midi_device.c.obj
[ 4%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/msc/msc_device.c.obj
[ 4%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/net/ecm_rndis_device.c.obj
[ 4%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/net/ncm_device.c.obj
[ 4%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/usbtmc/usbtmc_device.c.obj
[ 5%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/vendor/vendor_device.c.obj
[ 5%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/class/video/video_device.c.obj
[ 5%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/tusb.c.obj
[ 6%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/lib/tinyusb/src/common/tusb_fifo.c.obj
[ 6%] Building C object build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj
/home/poofjunior/external_projects/pico-sdk/src/rp2_common/hardware_irq/irq.c:8:10: fatal error: pico/runtime_init.h: No such file or directory
8 | #include "pico/runtime_init.h"
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [build/CMakeFiles/usb_desc.dir/build.make:342: build/CMakeFiles/usb_desc.dir/home/poofjunior/external_projects/pico-sdk/src/rp2_common/hardware_irq/irq.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:2013: build/CMakeFiles/usb_desc.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
It's worth mentioning that we are invoking TinyUSB calls directly and needed to pull out usb_descriptors.c in the process.
I'm now able to build with both pico SDK 1.5.1 and 2.0.0. I use FetchContent_Populate to get pico SDK and FreeRTOS SDK. I include their import cmake files before declaring my project and everything works out. k40-rpi-pico-1.zip
@sakhnik Glad you got it working! Do you have any insight into why those changes help? (I'm trying to figure out if there are any lessons for how to do this without FetchContent.)
@leondisctech, nothing specific. I just followed the README from freertos RP2040 port. They suggest including their cmake module before project(), and that's it. I didn't try without FetchContent.
Ok, it looks like tweaking the parent library's CMakeLists.txt fixed it.
# old
target_link_libraries(usb_desc tinyusb_device pico_unique_id)
# new
target_link_libraries(usb_desc tinyusb_device pico_unique_id pico_stdlib)
It looks like we did something eyebrow-raising by ripping out usb_desc and trying to compile its dependencies alone, but adding pico_stdlib
as a dependency appears to have fixed it.
@Poofjunior Thanks for the tip! Adding pico_stdlib did the trick.
@kilograham Any idea why this file now needs both pico_sync
and pico_stdlib
in CMakeLists under pico-sdk 2.0.0 while it only needed pico_sync
under pico-sdk 1.5.1?
It needs pico_runtime_init
... it is a bug that it doesn't depend on it directly
I hit the same issue, I've made PR #1956 that fixes these compile errors in my testing
latest PR merged into develop
I have a project where I have the Pico SDK in a git submodule. I recently tried upgrading the SDK from version 1.5.1 to version 2.0.0, and now I have compilation issues where runtime_init.h isn't found. The following is from running cmake and make in a clean build directory. (I deleted the build directory as instructed in the SDK 2.0.0 release notes.) The error is about 7 lines from the bottom. (
/Users/foo/bar/pico-sdk/src/common/pico_sync/mutex.c:9:10: fatal error: pico/runtime_init.h: No such file or directory
)Running cmake/build thru visual studio has some different flags but produces similar output except that it gives the error both in mutex.c and time.c.
I'm guessing this is just me goosing up git submodules and/or cmake somehow, but I'd appreciate any guidance.