Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7604

SDK • hardware/flash.h for PC build in pico-sdk 2.1.0 (pico/version.h: No such file or directory)

$
0
0
I've had PC (MINGW64 Wndows) program that compiled fine during pico-sdk 1.4.0. In that program, I have:

Code:

#include "hardware/flash.h"
... only because I need accurate FLASH_PAGE_SIZE in this program, and I did not want to hardcode it.

This PC program is also built via CMake, and during pico-sdk 1.4.0, all I've had to is (roughly):

Code:

set_source_files_properties(../my_pc_program.c     COMPILE_FLAGS "-I${PICO_SDK_PATH}/src/rp2_common/hardware_flash/include ...")
... and I could get the program to build fine ...

Now I've upgraded to pico-sdk 2.1.0, and I have the problem, that the PC program will not compile, due to the following error:

Code:

[ 76%] Building C object CMakeFiles/my_pc_program.dir/.../my_pc_program.c.objIn file included from C:/src/pico-sdk/src/rp2_common/hardware_flash/include/hardware/flash.h:10,                 from C:/..../my_pc_program.c:92:C:/src/pico-sdk/src/common/pico_base_headers/include/pico.h:27:10: fatal error: pico/version.h: No such file or directory   27 | #include "pico/version.h"      |          ^~~~~~~~~~~~~~~~compilation terminated.
So, now hardware/flash.h seems to require/include pico/version.h - however the problem is that there is no pico/version.h by default in pico-sd 2.1.0; instead there is ${PICO_SDK_PATH}/src/common/pico_base_headers/include/pico/version.h.in; and as mentioned in Cannot open `stdlib.h` on WSL 2 with VSCode/CMake · Issue #148 · raspberrypi/pico-feedback:
it may just be because you have not built yet... that file is generated by the build.
And indeed - apparently pico/version.h is generated by ${PICO_SDK_PATH}/src/common/pico_base_headers/generate_config_header.cmake; and that cmake file is added to PICO_SDK_POST_LIST_FILES by ${PICO_SDK_PATH}/src/common/pico_base_headers/CMakeLists.txt, and it seems header generation via PICO_SDK_POST_LIST_FILES is triggered by ${PICO_SDK_PATH}/pico_sdk_init.cmake .

So, apparently I need to call pico_sdk_init() in my program's CMakeLists.txt... But, if I do that, then the C compiler is determined to be arm-none-eabi-gcc - NOT the "vanilla" PC gcc - and since arm-none-eabi-gcc build for ARM, not for PC (in this case, Windows via MINGW64), compilation goes to hell and I cannot build the PC program.

So, what would be a recommended way to include "hardware/flash.h" in a PC C program managed by CMake, so I can just have access to FLASH_PAGE_SIZE (and possibly other defines) - but without having to call pico_sdk_init(), so I can still compile this program for PC?

Statistics: Posted by sdbbs — Wed Feb 12, 2025 6:37 am



Viewing all articles
Browse latest Browse all 7604

Trending Articles